示例#1
0
 public void visit(Node.CustomTag n) throws JasperException {
   n.setCustomTagParent(parent);
   Node.CustomTag tmpParent = parent;
   parent = n;
   visitBody(n);
   parent = tmpParent;
   n.setNumCount(new Integer(count++));
 }
示例#2
0
 TagPluginContextImpl(Node.CustomTag n, PageInfo pageInfo) {
   this.node = n;
   this.pageInfo = pageInfo;
   curNodes = new Node.Nodes();
   n.setAtETag(curNodes);
   curNodes = new Node.Nodes();
   n.setAtSTag(curNodes);
   n.setUseTagPlugin(true);
   pluginAttributes = new HashMap();
 }
示例#3
0
  /**
   * Invoke tag plugin for the given custom tag, if a plugin exists for the custom tag's tag
   * handler.
   *
   * <p>The given custom tag node will be manipulated by the plugin.
   */
  private void invokePlugin(Node.CustomTag n) {
    TagPlugin tagPlugin = (TagPlugin) tagPlugins.get(n.getTagHandlerClass().getName());
    if (tagPlugin == null) {
      return;
    }

    TagPluginContext tagPluginContext = new TagPluginContextImpl(n, pageInfo);
    n.setTagPluginContext(tagPluginContext);
    tagPlugin.doTag(tagPluginContext);
  }
示例#4
0
    private void setScriptingVars(Node.CustomTag n, int scope) throws JasperException {

      TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
      VariableInfo[] varInfos = n.getVariableInfos();
      if (tagVarInfos.length == 0 && varInfos.length == 0) {
        return;
      }

      Vector vec = new Vector();

      Integer ownRange = null;
      if (scope == VariableInfo.AT_BEGIN || scope == VariableInfo.AT_END) {
        Node.CustomTag parent = n.getCustomTagParent();
        if (parent == null) ownRange = MAX_SCOPE;
        else ownRange = parent.getNumCount();
      } else {
        // NESTED
        ownRange = n.getNumCount();
      }

      if (varInfos.length > 0) {
        for (int i = 0; i < varInfos.length; i++) {
          if (varInfos[i].getScope() != scope || !varInfos[i].getDeclare()) {
            continue;
          }
          String varName = varInfos[i].getVarName();

          Integer currentRange = scriptVars.get(varName);
          if (currentRange == null || ownRange.compareTo(currentRange) > 0) {
            scriptVars.put(varName, ownRange);
            vec.add(varInfos[i]);
          }
        }
      } else {
        for (int i = 0; i < tagVarInfos.length; i++) {
          if (tagVarInfos[i].getScope() != scope || !tagVarInfos[i].getDeclare()) {
            continue;
          }
          String varName = tagVarInfos[i].getNameGiven();
          if (varName == null) {
            varName = n.getTagData().getAttributeString(tagVarInfos[i].getNameFromAttribute());
            if (varName == null) {
              err.jspError(
                  n,
                  "jsp.error.scripting.variable.missing_name",
                  tagVarInfos[i].getNameFromAttribute());
            }
          }

          Integer currentRange = scriptVars.get(varName);
          if (currentRange == null || ownRange.compareTo(currentRange) > 0) {
            scriptVars.put(varName, ownRange);
            vec.add(tagVarInfos[i]);
          }
        }
      }

      n.setScriptingVars(vec, scope);
    }
示例#5
0
 public TagPluginContext getParentContext() {
   Node parent = node.getParent();
   if (!(parent instanceof Node.CustomTag)) {
     return null;
   }
   return ((Node.CustomTag) parent).getTagPluginContext();
 }
示例#6
0
 private Node.JspAttribute getNodeAttribute(String attribute) {
   Node.JspAttribute[] attrs = node.getJspAttributes();
   for (int i = 0; attrs != null && i < attrs.length; i++) {
     if (attrs[i].getName().equals(attribute)) {
       return attrs[i];
     }
   }
   return null;
 }
示例#7
0
 public void generateBody() {
   // Since we'll generate the body anyway, this is really a nop,
   // except for the fact that it lets us put the Java sources the
   // plugins produce in the correct order (w.r.t the body).
   curNodes = node.getAtETag();
 }
示例#8
0
 public void dontUseTagPlugin() {
   node.setUseTagPlugin(false);
 }
示例#9
0
 public void generateAttribute(String attributeName) {
   curNodes.add(new Node.AttributeGenerator(node.getStart(), attributeName, node));
 }
示例#10
0
 public void generateJavaSource(String sourceCode) {
   curNodes.add(new Node.Scriptlet(sourceCode, node.getStart(), null));
 }
示例#11
0
 public void generateDeclaration(String id, String text) {
   if (pageInfo.isPluginDeclared(id)) {
     return;
   }
   curNodes.add(new Node.Declaration(text, node.getStart(), null));
 }
示例#12
0
 public boolean isScriptless() {
   return node.getChildInfo().isScriptless();
 }