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++)); }
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(); }
/** * 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); }
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); }
public TagPluginContext getParentContext() { Node parent = node.getParent(); if (!(parent instanceof Node.CustomTag)) { return null; } return ((Node.CustomTag) parent).getTagPluginContext(); }
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; }
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(); }
public void dontUseTagPlugin() { node.setUseTagPlugin(false); }
public void generateAttribute(String attributeName) { curNodes.add(new Node.AttributeGenerator(node.getStart(), attributeName, node)); }
public void generateJavaSource(String sourceCode) { curNodes.add(new Node.Scriptlet(sourceCode, node.getStart(), null)); }
public void generateDeclaration(String id, String text) { if (pageInfo.isPluginDeclared(id)) { return; } curNodes.add(new Node.Declaration(text, node.getStart(), null)); }
public boolean isScriptless() { return node.getChildInfo().isScriptless(); }