當前位置: 首頁>>代碼示例>>Java>>正文


Java MacroParameter類代碼示例

本文整理匯總了Java中org.radeox.macro.parameter.MacroParameter的典型用法代碼示例。如果您正苦於以下問題:Java MacroParameter類的具體用法?Java MacroParameter怎麽用?Java MacroParameter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MacroParameter類屬於org.radeox.macro.parameter包,在下文中一共展示了MacroParameter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
    throws IllegalArgumentException, IOException {
  if (params != null && params.getLength() == 1) {
    writer.write("Hello <b>");
    writer.write(params.get("0"));
    writer.write("</b>");
  } else {
    throw new IllegalArgumentException(
       "Number of arguments does not match");
  }
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:12,代碼來源:ParameterHelloWorldMacro.java

示例2: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
    throws IllegalArgumentException, IOException {
  if (params.getLength() == 0) {
    UserManager um = (UserManager)Components.getComponent(UserManager.class);
    writer.write(Integer.toString(um.getUserCount()));
  } else {
    throw new IllegalArgumentException("Number of arguments does not match");
  }
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:10,代碼來源:UserCountMacro.java

示例3: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
    throws IllegalArgumentException, IOException {
  if (params.getLength() == 1) {
    writer.write("<footnote>");
    writer.write(params.get("0"));
    writer.write("</footnote>");
  } else {
    throw new IllegalArgumentException("footnote needs exactly one argument");
  }
  return;
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:12,代碼來源:AnnotationMacro.java

示例4: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params) throws IllegalArgumentException, IOException {
  if (params instanceof SnipMacroParameter) {
    execute(writer, (SnipMacroParameter) params);
    return;
  } else {
    throw new IllegalArgumentException("Macro must be called in a SnipSnap enviroment.");
  }
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:9,代碼來源:SnipPreserved.java

示例5: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
    throws IllegalArgumentException, IOException {
  if (params.getLength() == 0) {
    writer.write(Integer.toString(SnipSpaceFactory.getInstance().getSnipCount()));
  } else {
    throw new IllegalArgumentException("Number of arguments does not match");
  }
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:9,代碼來源:SnipCountMacro.java

示例6: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
    throws IllegalArgumentException, IOException {
  if (params.getLength() == 0) {
     writer.write(version);
  } else {
    throw new IllegalArgumentException("Number of arguments does not match");
  }
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:9,代碼來源:VersionMacro.java

示例7: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
    throws IllegalArgumentException, IOException {

  snipsnap.api.snip.Snip snip = SnipSpaceFactory.getInstance().load(snipsnap.api.app.Application.get().getConfiguration().getStartSnip());
  MessageFormat mf = new MessageFormat(ResourceManager.getString("i18n.messages", "macro.onlinetime.age"),
                                       ResourceManager.getLocale("i18n.messages"));
  writer.write(mf.format(new Object[]{Modified.getNiceTime(snip.getModified().getcTime())}));
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:9,代碼來源:OnlineTimeMacro.java

示例8: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
    throws IllegalArgumentException, IOException {

  if (params.getLength() == 1) {
    User user = UserManagerFactory.getInstance().load(params.get("0"));
    writer.write("<b>");
    writer.write(ResourceManager.getString("i18n.messages", "macro.lastvisit.lastvisit"));
    writer.write("</b> ");
    writer.write(Modified.getNiceTime(user.getLastLogout()));
  } else {
    throw new IllegalArgumentException("Number of arguments does not match");
  }
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:14,代碼來源:LastVisitMacro.java

示例9: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
    throws IllegalArgumentException, IOException {

  if (params.getLength() == 1) {
    User user = UserManagerFactory.getInstance().load(params.get("0"));
    writer.write("<b>");
    writer.write(ResourceManager.getString("i18n.messages", "macro.lastlogin.lastlogin"));
    writer.write("</b> ");
    writer.write(Modified.getNiceTime(user.getLastLogin()));
  } else {
    throw new IllegalArgumentException("Number of arguments does not match");
  }
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:14,代碼來源:LastLoginMacro.java

示例10: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
  throws IllegalArgumentException, IOException {
  writer.write("hello " + params.getContent());
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:5,代碼來源:ContentHelloWorldMacro.java

示例11: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
  throws IllegalArgumentException, IOException {
  writer.write("hello world");
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:5,代碼來源:HelloWorldMacro.java

示例12: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
  throws IllegalArgumentException, IOException {
  writer.write("hello "+name);
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:5,代碼來源:InitialRenderContextHelloWorldMacro.java

示例13: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
/**
 * @see org.radeox.macro.Macro#execute(java.io.Writer, org.radeox.macro.parameter.MacroParameter)
 */
@Override
public void execute(Writer writer, MacroParameter params) throws IllegalArgumentException, IOException {

	String name = params.get(NAME);
	String address = params.get(ADDRESS);
	String height = params.get(HEIGHT);
	String width = params.get(WIDTH);
	String displayduration = params.get(DISPLAYDURATION);
	String displayname = params.getContent();

	if (address == null) {
		writer.write("<p>movieViewer: illegal format: missing attribute " + ADDRESS + "</p>");
		return;
	}
	// default values for unset optional parameter
	if (name == null) name = "remotelyControlled";
	if (width == null) width = Integer.toString(DEFAULT_WIDTH);
	if (height == null) height = Integer.toString(DEFAULT_HEIGHT);

	try {
		int iHeigt = Integer.parseInt(height);
		height = Integer.toString(iHeigt + CONTROLLER_HEIGHT);
	} catch (NumberFormatException e) {
		// using default values
		width = Integer.toString(DEFAULT_WIDTH);
		height = Integer.toString(DEFAULT_HEIGHT + CONTROLLER_HEIGHT);
	}

	writer.write("<span class=\"b_wiki_timemarker_viewer\">");
	// show popup link
	writer.write("<a href=\"javascript:void(");
	// open window a bit bitter than the movie size itself
	String args = "width=" + (Integer.parseInt(width) + WIDTH_OFFSET) + ",height=" + (Integer.parseInt(height) + HEIGHT_OFFSET) + ",resizable=yes,scrollbars=yes";
	writer.write("window.open(o_info.o_baseURI + '/movie/popup.html?maddress=' + encodeURIComponent('" + address + "') + '&mname=' + encodeURIComponent('" + name
			+ "') + '&displayname=' + encodeURIComponent('" + displayname + "') + '&displayduration=' + encodeURIComponent('" + displayduration + "') + '&width="
			+ width + "&height=" + height + "', '" + name + "', '" + args + "')");
	writer.write(")\">Open movie player");
	if (displayname != null) {
		writer.write(": ");
		writer.write(displayname);
		if (displayduration != null) {
			writer.write(": ");
		}
	}
	if (displayduration != null) {
		writer.write(displayduration);
	}
	writer.write("</a>");
	writer.write("</span>");
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:54,代碼來源:MovieViewerMacro.java

示例14: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
        throws IllegalArgumentException, IOException {

  // Names from the namespace look like
  // [0] = foo/
  // [1] = foo/bar
  // [2] = foo/barbar
  // [3] = foo/barbar/boing

  if (params.getLength() < 3) {
    Snip[] snips = space.match(params.get("0"));
    int maxDepth = -1;
    if (params.getLength() == 2) {
      try {
        maxDepth = Integer.parseInt(params.get("1"));
      } catch (NumberFormatException e) {
        // silently ignore wrong number
      }
    }

    Node root = new Node("root", false);

    for (int i = 0; i < snips.length; i++) {
      Snip snip = snips[i];
      String elements[] = snip.getName().split("/");

      // Create all nodes till leaf
      Node lastNode = root;
      for (int j = 0; j < elements.length; j++) {
        String name = elements[j];
        if (!lastNode.hasChild(name)) {
          boolean isSnip = (j == elements.length - 1);
          Node node = new Node(name, isSnip);
          if (isSnip) {
            node.setSnipName(snip.getName());
          }
          lastNode.addChild(node);
          lastNode = node;
        } else {
          lastNode = lastNode.getChild(name);
        }
      }
    }

    writer.write("<div class=\"snip-tree\">");
    writeTree(writer, root, 1, maxDepth);
    writer.write("</div>");
  } else if (params.getLength() == 3) {
    writer.write("<img src=\"/exec/namespace?name=" + params.get(0) + "\"/>");
  } else {
    throw new IllegalArgumentException("Number of arguments does not match");
  }
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:54,代碼來源:SnipTreeMacro.java

示例15: execute

import org.radeox.macro.parameter.MacroParameter; //導入依賴的package包/類
public void execute(Writer writer, MacroParameter params)
    throws IllegalArgumentException, IOException {

  RenderContext context = params.getContext();
  if (context instanceof SnipRenderContext) {
    SnipSpace space = ((SnipRenderContext) context).getSpace();

    int length = 10;
    boolean showSize = false;
    if (params.getLength() > 0) {
      try {
        length = Integer.parseInt(params.get("0"));
      } catch (NumberFormatException e) {
        Logger.warn("HotnessMacro: illegal parameter count='" + params.get("0") + "'");
      }
    }

    if (params.getLength() <= 1) {
      Collection c = space.getHot(length);
      Iterator iterator = c.iterator();
      writer.write("<div class=\"list\"><div class=\"list-title\">");
      ResourceManager.getString("i18n.messages", "macro.hotsnip.viewed");
      if (showSize) {
        writer.write(" (");
        writer.write("" + length);
        writer.write(")");
      }
      writer.write("</div><ul>");
      while (iterator.hasNext()) {
        snipsnap.api.snip.Snip hotSnip = (Snip) iterator.next();
        writer.write("<li><span class=\"count\">");
        writer.write("" + hotSnip.getViewCount());
        writer.write("</span>");
        writer.write("<span class=\"content\">");
        SnipLink.appendLink(writer, hotSnip);
        writer.write("</span></li>");
      }
      writer.write("</ul></div>");
    } else {
      throw new IllegalArgumentException("Number of arguments does not match");
    }
  }
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:44,代碼來源:HotSnipMacro.java


注:本文中的org.radeox.macro.parameter.MacroParameter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。