javax.servlet.jsp.tagext.TagVariableInfo源码实例Demo

类javax.servlet.jsp.tagext.TagVariableInfo源码实例Demo

下面列出了javax.servlet.jsp.tagext.TagVariableInfo 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Tomcat8-Source-Read   文件: JasperTagInfo.java
public JasperTagInfo(String tagName,
        String tagClassName,
        String bodyContent,
        String infoString,
        TagLibraryInfo taglib,
        TagExtraInfo tagExtraInfo,
        TagAttributeInfo[] attributeInfo,
        String displayName,
        String smallIcon,
        String largeIcon,
        TagVariableInfo[] tvi,
        String mapName) {

    super(tagName, tagClassName, bodyContent, infoString, taglib,
            tagExtraInfo, attributeInfo, displayName, smallIcon, largeIcon,
            tvi);

    this.dynamicAttrsMapName = mapName;
}
 
源代码2 项目: Tomcat8-Source-Read   文件: TagFileProcessor.java
public TagInfo getTagInfo() throws JasperException {

            if (name == null) {
                // XXX Get it from tag file name
            }

            if (bodycontent == null) {
                bodycontent = TagInfo.BODY_CONTENT_SCRIPTLESS;
            }

            String tagClassName = JspUtil.getTagHandlerClassName(
                    path, tagLibInfo.getReliableURN(), err);

            TagVariableInfo[] tagVariableInfos = new TagVariableInfo[variableVector
                    .size()];
            variableVector.copyInto(tagVariableInfos);

            TagAttributeInfo[] tagAttributeInfo = new TagAttributeInfo[attributeVector
                    .size()];
            attributeVector.copyInto(tagAttributeInfo);

            return new JasperTagInfo(name, tagClassName, bodycontent,
                    description, tagLibInfo, null, tagAttributeInfo,
                    displayName, smallIcon, largeIcon, tagVariableInfos,
                    dynamicAttrsMapName);
        }
 
源代码3 项目: Tomcat7.0.67   文件: JasperTagInfo.java
public JasperTagInfo(String tagName,
        String tagClassName,
        String bodyContent,
        String infoString,
        TagLibraryInfo taglib,
        TagExtraInfo tagExtraInfo,
        TagAttributeInfo[] attributeInfo,
        String displayName,
        String smallIcon,
        String largeIcon,
        TagVariableInfo[] tvi,
        String mapName) {

    super(tagName, tagClassName, bodyContent, infoString, taglib,
            tagExtraInfo, attributeInfo, displayName, smallIcon, largeIcon,
            tvi);
    
    this.dynamicAttrsMapName = mapName;
}
 
源代码4 项目: Tomcat7.0.67   文件: TagFileProcessor.java
public TagInfo getTagInfo() throws JasperException {

            if (name == null) {
                // XXX Get it from tag file name
            }

            if (bodycontent == null) {
                bodycontent = TagInfo.BODY_CONTENT_SCRIPTLESS;
            }

            String tagClassName = JspUtil.getTagHandlerClassName(
                    path, tagLibInfo.getReliableURN(), err);

            TagVariableInfo[] tagVariableInfos = new TagVariableInfo[variableVector
                    .size()];
            variableVector.copyInto(tagVariableInfos);

            TagAttributeInfo[] tagAttributeInfo = new TagAttributeInfo[attributeVector
                    .size()];
            attributeVector.copyInto(tagAttributeInfo);

            return new JasperTagInfo(name, tagClassName, bodycontent,
                    description, tagLibInfo, tei, tagAttributeInfo,
                    displayName, smallIcon, largeIcon, tagVariableInfos,
                    dynamicAttrsMapName);
        }
 
源代码5 项目: tomcatsrc   文件: JasperTagInfo.java
public JasperTagInfo(String tagName,
        String tagClassName,
        String bodyContent,
        String infoString,
        TagLibraryInfo taglib,
        TagExtraInfo tagExtraInfo,
        TagAttributeInfo[] attributeInfo,
        String displayName,
        String smallIcon,
        String largeIcon,
        TagVariableInfo[] tvi,
        String mapName) {

    super(tagName, tagClassName, bodyContent, infoString, taglib,
            tagExtraInfo, attributeInfo, displayName, smallIcon, largeIcon,
            tvi);
    
    this.dynamicAttrsMapName = mapName;
}
 
源代码6 项目: tomcatsrc   文件: TagFileProcessor.java
public TagInfo getTagInfo() throws JasperException {

            if (name == null) {
                // XXX Get it from tag file name
            }

            if (bodycontent == null) {
                bodycontent = TagInfo.BODY_CONTENT_SCRIPTLESS;
            }

            String tagClassName = JspUtil.getTagHandlerClassName(
                    path, tagLibInfo.getReliableURN(), err);

            TagVariableInfo[] tagVariableInfos = new TagVariableInfo[variableVector
                    .size()];
            variableVector.copyInto(tagVariableInfos);

            TagAttributeInfo[] tagAttributeInfo = new TagAttributeInfo[attributeVector
                    .size()];
            attributeVector.copyInto(tagAttributeInfo);

            return new JasperTagInfo(name, tagClassName, bodycontent,
                    description, tagLibInfo, tei, tagAttributeInfo,
                    displayName, smallIcon, largeIcon, tagVariableInfos,
                    dynamicAttrsMapName);
        }
 
源代码7 项目: Tomcat8-Source-Read   文件: Generator.java
private void declareScriptingVars(Node.CustomTag n, int scope) {
    if (isFragment) {
        // No need to declare Java variables, if we inside a
        // JspFragment, because a fragment is always scriptless.
        return;
    }

    List<Object> vec = n.getScriptingVars(scope);
    if (vec != null) {
        for (int i = 0; i < vec.size(); i++) {
            Object elem = vec.get(i);
            if (elem instanceof VariableInfo) {
                VariableInfo varInfo = (VariableInfo) elem;
                if (varInfo.getDeclare()) {
                    out.printin(varInfo.getClassName());
                    out.print(" ");
                    out.print(varInfo.getVarName());
                    out.println(" = null;");
                }
            } else {
                TagVariableInfo tagVarInfo = (TagVariableInfo) elem;
                if (tagVarInfo.getDeclare()) {
                    String varName = tagVarInfo.getNameGiven();
                    if (varName == null) {
                        varName = n.getTagData().getAttributeString(
                                tagVarInfo.getNameFromAttribute());
                    } else if (tagVarInfo.getNameFromAttribute() != null) {
                        // alias
                        continue;
                    }
                    out.printin(tagVarInfo.getClassName());
                    out.print(" ");
                    out.print(varName);
                    out.println(" = null;");
                }
            }
        }
    }
}
 
源代码8 项目: Tomcat8-Source-Read   文件: Generator.java
/**
 * Generate code to create a map for the alias variables
 *
 * @return the name of the map
 */
private String generateAliasMap(Node.CustomTag n,
        String tagHandlerVar) {

    TagVariableInfo[] tagVars = n.getTagVariableInfos();
    String aliasMapVar = null;

    boolean aliasSeen = false;
    for (int i = 0; i < tagVars.length; i++) {

        String nameFrom = tagVars[i].getNameFromAttribute();
        if (nameFrom != null) {
            String aliasedName = n.getAttributeValue(nameFrom);
            if (aliasedName == null)
                continue;

            if (!aliasSeen) {
                out.printin("java.util.HashMap ");
                aliasMapVar = tagHandlerVar + "_aliasMap";
                out.print(aliasMapVar);
                out.println(" = new java.util.HashMap();");
                aliasSeen = true;
            }
            out.printin(aliasMapVar);
            out.print(".put(");
            out.print(quote(tagVars[i].getNameGiven()));
            out.print(", ");
            out.print(quote(aliasedName));
            out.println(");");
        }
    }
    return aliasMapVar;
}
 
源代码9 项目: Tomcat7.0.67   文件: Generator.java
private void declareScriptingVars(Node.CustomTag n, int scope) {
    if (isFragment) {
        // No need to declare Java variables, if we inside a
        // JspFragment, because a fragment is always scriptless.
        return;
    }

    List<Object> vec = n.getScriptingVars(scope);
    if (vec != null) {
        for (int i = 0; i < vec.size(); i++) {
            Object elem = vec.get(i);
            if (elem instanceof VariableInfo) {
                VariableInfo varInfo = (VariableInfo) elem;
                if (varInfo.getDeclare()) {
                    out.printin(varInfo.getClassName());
                    out.print(" ");
                    out.print(varInfo.getVarName());
                    out.println(" = null;");
                }
            } else {
                TagVariableInfo tagVarInfo = (TagVariableInfo) elem;
                if (tagVarInfo.getDeclare()) {
                    String varName = tagVarInfo.getNameGiven();
                    if (varName == null) {
                        varName = n.getTagData().getAttributeString(
                                tagVarInfo.getNameFromAttribute());
                    } else if (tagVarInfo.getNameFromAttribute() != null) {
                        // alias
                        continue;
                    }
                    out.printin(tagVarInfo.getClassName());
                    out.print(" ");
                    out.print(varName);
                    out.println(" = null;");
                }
            }
        }
    }
}
 
源代码10 项目: Tomcat7.0.67   文件: Generator.java
/**
 * Generate code to create a map for the alias variables
 *
 * @return the name of the map
 */
private String generateAliasMap(Node.CustomTag n,
        String tagHandlerVar) {

    TagVariableInfo[] tagVars = n.getTagVariableInfos();
    String aliasMapVar = null;

    boolean aliasSeen = false;
    for (int i = 0; i < tagVars.length; i++) {

        String nameFrom = tagVars[i].getNameFromAttribute();
        if (nameFrom != null) {
            String aliasedName = n.getAttributeValue(nameFrom);
            if (aliasedName == null)
                continue;

            if (!aliasSeen) {
                out.printin("java.util.HashMap ");
                aliasMapVar = tagHandlerVar + "_aliasMap";
                out.print(aliasMapVar);
                out.println(" = new java.util.HashMap();");
                aliasSeen = true;
            }
            out.printin(aliasMapVar);
            out.print(".put(");
            out.print(quote(tagVars[i].getNameGiven()));
            out.print(", ");
            out.print(quote(aliasedName));
            out.println(");");
        }
    }
    return aliasMapVar;
}
 
源代码11 项目: Tomcat7.0.67   文件: TagFileProcessor.java
public TagFileDirectiveVisitor(Compiler compiler,
        TagLibraryInfo tagLibInfo, String name, String path) {
    err = compiler.getErrorDispatcher();
    this.tagLibInfo = tagLibInfo;
    this.name = name;
    this.path = path;
    attributeVector = new Vector<TagAttributeInfo>();
    variableVector = new Vector<TagVariableInfo>();
}
 
源代码12 项目: tomcatsrc   文件: Generator.java
private void declareScriptingVars(Node.CustomTag n, int scope) {
    if (isFragment) {
        // No need to declare Java variables, if we inside a
        // JspFragment, because a fragment is always scriptless.
        return;
    }

    List<Object> vec = n.getScriptingVars(scope);
    if (vec != null) {
        for (int i = 0; i < vec.size(); i++) {
            Object elem = vec.get(i);
            if (elem instanceof VariableInfo) {
                VariableInfo varInfo = (VariableInfo) elem;
                if (varInfo.getDeclare()) {
                    out.printin(varInfo.getClassName());
                    out.print(" ");
                    out.print(varInfo.getVarName());
                    out.println(" = null;");
                }
            } else {
                TagVariableInfo tagVarInfo = (TagVariableInfo) elem;
                if (tagVarInfo.getDeclare()) {
                    String varName = tagVarInfo.getNameGiven();
                    if (varName == null) {
                        varName = n.getTagData().getAttributeString(
                                tagVarInfo.getNameFromAttribute());
                    } else if (tagVarInfo.getNameFromAttribute() != null) {
                        // alias
                        continue;
                    }
                    out.printin(tagVarInfo.getClassName());
                    out.print(" ");
                    out.print(varName);
                    out.println(" = null;");
                }
            }
        }
    }
}
 
源代码13 项目: tomcatsrc   文件: Generator.java
/**
 * Generate code to create a map for the alias variables
 *
 * @return the name of the map
 */
private String generateAliasMap(Node.CustomTag n,
        String tagHandlerVar) {

    TagVariableInfo[] tagVars = n.getTagVariableInfos();
    String aliasMapVar = null;

    boolean aliasSeen = false;
    for (int i = 0; i < tagVars.length; i++) {

        String nameFrom = tagVars[i].getNameFromAttribute();
        if (nameFrom != null) {
            String aliasedName = n.getAttributeValue(nameFrom);
            if (aliasedName == null)
                continue;

            if (!aliasSeen) {
                out.printin("java.util.HashMap ");
                aliasMapVar = tagHandlerVar + "_aliasMap";
                out.print(aliasMapVar);
                out.println(" = new java.util.HashMap();");
                aliasSeen = true;
            }
            out.printin(aliasMapVar);
            out.print(".put(");
            out.print(quote(tagVars[i].getNameGiven()));
            out.print(", ");
            out.print(quote(aliasedName));
            out.println(");");
        }
    }
    return aliasMapVar;
}
 
源代码14 项目: tomcatsrc   文件: TagFileProcessor.java
public TagFileDirectiveVisitor(Compiler compiler,
        TagLibraryInfo tagLibInfo, String name, String path) {
    err = compiler.getErrorDispatcher();
    this.tagLibInfo = tagLibInfo;
    this.name = name;
    this.path = path;
    attributeVector = new Vector<TagAttributeInfo>();
    variableVector = new Vector<TagVariableInfo>();
}
 
源代码15 项目: packagedrone   文件: Generator.java
private void declareScriptingVars(Node.CustomTag n, int scope) {

            // Skip if the page is scriptless
            if (pageInfo.isScriptless()) return;

            ArrayList<Object> vec = n.getScriptingVars(scope);
            if (vec != null) {
                for (int i = 0; i < vec.size(); i++) {
                    Object elem = vec.get(i);
                    if (elem instanceof VariableInfo) {
                        VariableInfo varInfo = (VariableInfo)elem;
                        if (varInfo.getDeclare()) {
                            out.printin(varInfo.getClassName());
                            out.print(" ");
                            out.print(varInfo.getVarName());
                            out.println(" = null;");
                        }
                    } else {
                        TagVariableInfo tagVarInfo = (TagVariableInfo)elem;
                        if (tagVarInfo.getDeclare()) {
                            String varName = tagVarInfo.getNameGiven();
                            if (varName == null) {
                                varName =
                                    n.getTagData().getAttributeString(
                                        tagVarInfo.getNameFromAttribute());
                            } else if (
                                tagVarInfo.getNameFromAttribute() != null) {
                                // alias
                                continue;
                            }
                            out.printin(tagVarInfo.getClassName());
                            out.print(" ");
                            out.print(varName);
                            out.println(" = null;");
                        }
                    }
                }
            }
        }
 
源代码16 项目: packagedrone   文件: Generator.java
/**
 * Generate code to create a map for the alias variables
 * @return the name of the map
 */
private String generateAliasMap(Node.CustomTag n, String tagHandlerVar)
    throws JasperException {

    TagVariableInfo[] tagVars = n.getTagVariableInfos();
    String aliasMapVar = null;

    boolean aliasSeen = false;
    for (int i = 0; i < tagVars.length; i++) {

        String nameFrom = tagVars[i].getNameFromAttribute();
        if (nameFrom != null) {
            String aliasedName = n.getAttributeValue(nameFrom);
            if (aliasedName == null)
                continue;

            if (!aliasSeen) {
                out.printin("java.util.HashMap ");
                aliasMapVar = tagHandlerVar + "_aliasMap";
                out.print(aliasMapVar);
                out.println(" = new java.util.HashMap();");
                aliasSeen = true;
            }
            out.printin(aliasMapVar);
            out.print(".put(");
            out.print(quote(tagVars[i].getNameGiven()));
            out.print(", ");
            out.print(quote(aliasedName));
            out.println(");");
        }
    }
    return aliasMapVar;
}
 
源代码17 项目: packagedrone   文件: TagFileProcessor.java
public TagFileDirectiveVisitor(Compiler compiler,
                               TagLibraryInfo tagLibInfo,
                               String name,
                               String path) {
    err = compiler.getErrorDispatcher();
    this.tagLibInfo = tagLibInfo;
    this.name = name;
    this.path = path;
    attributeVector = new ArrayList<TagAttributeInfo>();
    variableVector = new ArrayList<TagVariableInfo>();

    jspVersionDouble = Double.valueOf(tagLibInfo.getRequiredVersion());
}
 
源代码18 项目: packagedrone   文件: TagFileProcessor.java
public TagInfo getTagInfo() throws JasperException {

            if (name == null) {
                // XXX Get it from tag file name
            }

            if (bodycontent == null) {
                bodycontent = TagInfo.BODY_CONTENT_SCRIPTLESS;
            }

            String tagClassName = JspUtil.getTagHandlerClassName(path, err);

            TagVariableInfo[] tagVariableInfos
                = variableVector.toArray(new TagVariableInfo[0]);

            TagAttributeInfo[] tagAttributeInfo
                = attributeVector.toArray(new TagAttributeInfo[0]);

            return new JasperTagInfo(name,
			       tagClassName,
			       bodycontent,
			       description,
			       tagLibInfo,
			       tei,
			       tagAttributeInfo,
			       displayName,
			       smallIcon,
			       largeIcon,
			       tagVariableInfos,
			       dynamicAttrsMapName);
        }
 
源代码19 项目: Tomcat8-Source-Read   文件: TldRuleSet.java
public TagVariableInfo toTagVariableInfo() {
    return new TagVariableInfo(nameGiven, nameFromAttribute, className, declare, scope);
}
 
源代码20 项目: Tomcat8-Source-Read   文件: TagXml.java
public List<TagVariableInfo> getVariables() {
    return variables;
}
 
源代码21 项目: Tomcat8-Source-Read   文件: Node.java
public TagVariableInfo[] getTagVariableInfos() {
    return tagInfo.getTagVariableInfos();
}
 
源代码22 项目: Tomcat8-Source-Read   文件: Generator.java
private void syncScriptingVars(Node.CustomTag n, int scope) {
    if (isFragment) {
        // No need to declare Java variables, if we inside a
        // JspFragment, because a fragment is always scriptless.
        // Thus, there is no need to save/ restore/ sync them.
        // Note, that JspContextWrapper.syncFoo() methods will take
        // care of saving/ restoring/ sync'ing of JspContext attributes.
        return;
    }

    TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
    VariableInfo[] varInfos = n.getVariableInfos();

    if ((varInfos.length == 0) && (tagVarInfos.length == 0)) {
        return;
    }

    if (varInfos.length > 0) {
        for (int i = 0; i < varInfos.length; i++) {
            if (varInfos[i].getScope() == scope) {
                out.printin(varInfos[i].getVarName());
                out.print(" = (");
                out.print(varInfos[i].getClassName());
                out.print(") _jspx_page_context.findAttribute(");
                out.print(quote(varInfos[i].getVarName()));
                out.println(");");
            }
        }
    } else {
        for (int i = 0; i < tagVarInfos.length; i++) {
            if (tagVarInfos[i].getScope() == scope) {
                String name = tagVarInfos[i].getNameGiven();
                if (name == null) {
                    name = n.getTagData().getAttributeString(
                            tagVarInfos[i].getNameFromAttribute());
                } else if (tagVarInfos[i].getNameFromAttribute() != null) {
                    // alias
                    continue;
                }
                out.printin(name);
                out.print(" = (");
                out.print(tagVarInfos[i].getClassName());
                out.print(") _jspx_page_context.findAttribute(");
                out.print(quote(name));
                out.println(");");
            }
        }
    }
}
 
源代码23 项目: Tomcat8-Source-Read   文件: Generator.java
private void generateSetJspContext(TagInfo tagInfo) {

        boolean nestedSeen = false;
        boolean atBeginSeen = false;
        boolean atEndSeen = false;

        // Determine if there are any aliases
        boolean aliasSeen = false;
        TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
        for (int i = 0; i < tagVars.length; i++) {
            if (tagVars[i].getNameFromAttribute() != null
                    && tagVars[i].getNameGiven() != null) {
                aliasSeen = true;
                break;
            }
        }

        if (aliasSeen) {
            out.printil("public void setJspContext(javax.servlet.jsp.JspContext ctx, java.util.Map aliasMap) {");
        } else {
            out.printil("public void setJspContext(javax.servlet.jsp.JspContext ctx) {");
        }
        out.pushIndent();
        out.printil("super.setJspContext(ctx);");
        out.printil("java.util.ArrayList _jspx_nested = null;");
        out.printil("java.util.ArrayList _jspx_at_begin = null;");
        out.printil("java.util.ArrayList _jspx_at_end = null;");

        for (int i = 0; i < tagVars.length; i++) {

            switch (tagVars[i].getScope()) {
            case VariableInfo.NESTED:
                if (!nestedSeen) {
                    out.printil("_jspx_nested = new java.util.ArrayList();");
                    nestedSeen = true;
                }
                out.printin("_jspx_nested.add(");
                break;

            case VariableInfo.AT_BEGIN:
                if (!atBeginSeen) {
                    out.printil("_jspx_at_begin = new java.util.ArrayList();");
                    atBeginSeen = true;
                }
                out.printin("_jspx_at_begin.add(");
                break;

            case VariableInfo.AT_END:
                if (!atEndSeen) {
                    out.printil("_jspx_at_end = new java.util.ArrayList();");
                    atEndSeen = true;
                }
                out.printin("_jspx_at_end.add(");
                break;
            } // switch

            out.print(quote(tagVars[i].getNameGiven()));
            out.println(");");
        }
        if (aliasSeen) {
            out.printil("this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(this, ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, aliasMap);");
        } else {
            out.printil("this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(this, ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);");
        }
        out.popIndent();
        out.printil("}");
        out.println();
        out.printil("public javax.servlet.jsp.JspContext getJspContext() {");
        out.pushIndent();
        out.printil("return this.jspContext;");
        out.popIndent();
        out.printil("}");
    }
 
源代码24 项目: Tomcat8-Source-Read   文件: TagFileProcessor.java
@Override
public void visit(Node.VariableDirective n) throws JasperException {

    JspUtil.checkAttributes("Variable directive", n,
            variableDirectiveAttrs, err);

    String nameGiven = n.getAttributeValue("name-given");
    String nameFromAttribute = n
            .getAttributeValue("name-from-attribute");
    if (nameGiven == null && nameFromAttribute == null) {
        err.jspError("jsp.error.variable.either.name");
    }

    if (nameGiven != null && nameFromAttribute != null) {
        err.jspError("jsp.error.variable.both.name");
    }

    String alias = n.getAttributeValue("alias");
    if (nameFromAttribute != null && alias == null
            || nameFromAttribute == null && alias != null) {
        err.jspError("jsp.error.variable.alias");
    }

    String className = n.getAttributeValue("variable-class");
    if (className == null)
        className = "java.lang.String";

    String declareStr = n.getAttributeValue("declare");
    boolean declare = true;
    if (declareStr != null)
        declare = JspUtil.booleanValue(declareStr);

    int scope = VariableInfo.NESTED;
    String scopeStr = n.getAttributeValue("scope");
    if (scopeStr != null) {
        if ("NESTED".equals(scopeStr)) {
            // Already the default
        } else if ("AT_BEGIN".equals(scopeStr)) {
            scope = VariableInfo.AT_BEGIN;
        } else if ("AT_END".equals(scopeStr)) {
            scope = VariableInfo.AT_END;
        }
    }

    if (nameFromAttribute != null) {
        /*
         * An alias has been specified. We use 'nameGiven' to hold the
         * value of the alias, and 'nameFromAttribute' to hold the name
         * of the attribute whose value (at invocation-time) denotes the
         * name of the variable that is being aliased
         */
        nameGiven = alias;
        checkUniqueName(nameFromAttribute, VAR_NAME_FROM, n);
        checkUniqueName(alias, VAR_ALIAS, n);
    } else {
        // name-given specified
        checkUniqueName(nameGiven, VAR_NAME_GIVEN, n);
    }

    variableVector.addElement(new TagVariableInfo(nameGiven,
            nameFromAttribute, className, declare, scope));
}
 
源代码25 项目: Tomcat8-Source-Read   文件: TestTldParser.java
@Test
public void testTld() throws Exception {
    TaglibXml xml = parse("test/tld/test.tld");
    Assert.assertEquals("1.0", xml.getTlibVersion());
    Assert.assertEquals("2.1", xml.getJspVersion());
    Assert.assertEquals("test", xml.getShortName());
    Assert.assertEquals("http://tomcat.apache.org/TldTests", xml.getUri());
    Assert.assertEquals(1, xml.getFunctions().size());

    ValidatorXml validator = xml.getValidator();
    Assert.assertEquals("com.example.Validator", validator.getValidatorClass());
    Assert.assertEquals(1, validator.getInitParams().size());
    Assert.assertEquals("value", validator.getInitParams().get("name"));

    Assert.assertEquals(1, xml.getTags().size());
    TagXml tag = xml.getTags().get(0);
    Assert.assertEquals("org.apache.jasper.compiler.TestValidator$Echo", tag.getTagClass());
    Assert.assertEquals("empty", tag.getBodyContent());
    Assert.assertTrue(tag.hasDynamicAttributes());

    Assert.assertEquals(1, tag.getVariables().size());
    TagVariableInfo variableInfo = tag.getVariables().get(0);
    Assert.assertEquals("var", variableInfo.getNameGiven());
    Assert.assertEquals("java.lang.Object", variableInfo.getClassName());
    Assert.assertTrue(variableInfo.getDeclare());
    Assert.assertEquals(VariableInfo.AT_END, variableInfo.getScope());

    Assert.assertEquals(4, tag.getAttributes().size());
    TagAttributeInfo attributeInfo = tag.getAttributes().get(0);
    Assert.assertEquals("Echo Tag", tag.getInfo());
    Assert.assertEquals("Echo", tag.getDisplayName());
    Assert.assertEquals("small", tag.getSmallIcon());
    Assert.assertEquals("large", tag.getLargeIcon());
    Assert.assertEquals("echo", attributeInfo.getName());
    Assert.assertTrue(attributeInfo.isRequired());
    Assert.assertTrue(attributeInfo.canBeRequestTime());

    attributeInfo = tag.getAttributes().get(1);
    Assert.assertEquals("fragment", attributeInfo.getName());
    Assert.assertTrue(attributeInfo.isFragment());
    Assert.assertTrue(attributeInfo.canBeRequestTime());
    Assert.assertEquals("javax.servlet.jsp.tagext.JspFragment", attributeInfo.getTypeName());

    attributeInfo = tag.getAttributes().get(2);
    Assert.assertEquals("deferredValue", attributeInfo.getName());
    Assert.assertEquals("javax.el.ValueExpression", attributeInfo.getTypeName());
    Assert.assertEquals("java.util.Date", attributeInfo.getExpectedTypeName());

    attributeInfo = tag.getAttributes().get(3);
    Assert.assertEquals("deferredMethod", attributeInfo.getName());
    Assert.assertEquals("javax.el.MethodExpression", attributeInfo.getTypeName());
    Assert.assertEquals("java.util.Date getDate()", attributeInfo.getMethodSignature());

    Assert.assertEquals(1, xml.getTagFiles().size());
    TagFileXml tagFile = xml.getTagFiles().get(0);
    Assert.assertEquals("Echo", tag.getDisplayName());
    Assert.assertEquals("small", tag.getSmallIcon());
    Assert.assertEquals("large", tag.getLargeIcon());
    Assert.assertEquals("Echo2", tagFile.getName());
    Assert.assertEquals("/echo.tag", tagFile.getPath());

    Assert.assertEquals(1, xml.getFunctions().size());
    FunctionInfo fn = xml.getFunctions().get(0);
    Assert.assertEquals("trim", fn.getName());
    Assert.assertEquals("org.apache.el.TesterFunctions", fn.getFunctionClass());
    Assert.assertEquals("java.lang.String trim(java.lang.String)", fn.getFunctionSignature());
}
 
源代码26 项目: Tomcat7.0.67   文件: Node.java
public TagVariableInfo[] getTagVariableInfos() {
    return tagInfo.getTagVariableInfos();
}
 
源代码27 项目: Tomcat7.0.67   文件: Generator.java
private void syncScriptingVars(Node.CustomTag n, int scope) {
    if (isFragment) {
        // No need to declare Java variables, if we inside a
        // JspFragment, because a fragment is always scriptless.
        // Thus, there is no need to save/ restore/ sync them.
        // Note, that JspContextWrapper.syncFoo() methods will take
        // care of saving/ restoring/ sync'ing of JspContext attributes.
        return;
    }

    TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
    VariableInfo[] varInfos = n.getVariableInfos();

    if ((varInfos.length == 0) && (tagVarInfos.length == 0)) {
        return;
    }

    if (varInfos.length > 0) {
        for (int i = 0; i < varInfos.length; i++) {
            if (varInfos[i].getScope() == scope) {
                out.printin(varInfos[i].getVarName());
                out.print(" = (");
                out.print(varInfos[i].getClassName());
                out.print(") _jspx_page_context.findAttribute(");
                out.print(quote(varInfos[i].getVarName()));
                out.println(");");
            }
        }
    } else {
        for (int i = 0; i < tagVarInfos.length; i++) {
            if (tagVarInfos[i].getScope() == scope) {
                String name = tagVarInfos[i].getNameGiven();
                if (name == null) {
                    name = n.getTagData().getAttributeString(
                            tagVarInfos[i].getNameFromAttribute());
                } else if (tagVarInfos[i].getNameFromAttribute() != null) {
                    // alias
                    continue;
                }
                out.printin(name);
                out.print(" = (");
                out.print(tagVarInfos[i].getClassName());
                out.print(") _jspx_page_context.findAttribute(");
                out.print(quote(name));
                out.println(");");
            }
        }
    }
}
 
源代码28 项目: Tomcat7.0.67   文件: Generator.java
private void generateSetJspContext(TagInfo tagInfo) {

        boolean nestedSeen = false;
        boolean atBeginSeen = false;
        boolean atEndSeen = false;

        // Determine if there are any aliases
        boolean aliasSeen = false;
        TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
        for (int i = 0; i < tagVars.length; i++) {
            if (tagVars[i].getNameFromAttribute() != null
                    && tagVars[i].getNameGiven() != null) {
                aliasSeen = true;
                break;
            }
        }

        if (aliasSeen) {
            out.printil("public void setJspContext(javax.servlet.jsp.JspContext ctx, java.util.Map aliasMap) {");
        } else {
            out.printil("public void setJspContext(javax.servlet.jsp.JspContext ctx) {");
        }
        out.pushIndent();
        out.printil("super.setJspContext(ctx);");
        out.printil("java.util.ArrayList _jspx_nested = null;");
        out.printil("java.util.ArrayList _jspx_at_begin = null;");
        out.printil("java.util.ArrayList _jspx_at_end = null;");

        for (int i = 0; i < tagVars.length; i++) {

            switch (tagVars[i].getScope()) {
            case VariableInfo.NESTED:
                if (!nestedSeen) {
                    out.printil("_jspx_nested = new java.util.ArrayList();");
                    nestedSeen = true;
                }
                out.printin("_jspx_nested.add(");
                break;

            case VariableInfo.AT_BEGIN:
                if (!atBeginSeen) {
                    out.printil("_jspx_at_begin = new java.util.ArrayList();");
                    atBeginSeen = true;
                }
                out.printin("_jspx_at_begin.add(");
                break;

            case VariableInfo.AT_END:
                if (!atEndSeen) {
                    out.printil("_jspx_at_end = new java.util.ArrayList();");
                    atEndSeen = true;
                }
                out.printin("_jspx_at_end.add(");
                break;
            } // switch

            out.print(quote(tagVars[i].getNameGiven()));
            out.println(");");
        }
        if (aliasSeen) {
            out.printil("this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, aliasMap);");
        } else {
            out.printil("this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);");
        }
        out.popIndent();
        out.printil("}");
        out.println();
        out.printil("public javax.servlet.jsp.JspContext getJspContext() {");
        out.pushIndent();
        out.printil("return this.jspContext;");
        out.popIndent();
        out.printil("}");
    }
 
源代码29 项目: Tomcat7.0.67   文件: TagFileProcessor.java
@Override
public void visit(Node.VariableDirective n) throws JasperException {

    JspUtil.checkAttributes("Variable directive", n,
            variableDirectiveAttrs, err);

    String nameGiven = n.getAttributeValue("name-given");
    String nameFromAttribute = n
            .getAttributeValue("name-from-attribute");
    if (nameGiven == null && nameFromAttribute == null) {
        err.jspError("jsp.error.variable.either.name");
    }

    if (nameGiven != null && nameFromAttribute != null) {
        err.jspError("jsp.error.variable.both.name");
    }

    String alias = n.getAttributeValue("alias");
    if (nameFromAttribute != null && alias == null
            || nameFromAttribute == null && alias != null) {
        err.jspError("jsp.error.variable.alias");
    }

    String className = n.getAttributeValue("variable-class");
    if (className == null)
        className = "java.lang.String";

    String declareStr = n.getAttributeValue("declare");
    boolean declare = true;
    if (declareStr != null)
        declare = JspUtil.booleanValue(declareStr);

    int scope = VariableInfo.NESTED;
    String scopeStr = n.getAttributeValue("scope");
    if (scopeStr != null) {
        if ("NESTED".equals(scopeStr)) {
            // Already the default
        } else if ("AT_BEGIN".equals(scopeStr)) {
            scope = VariableInfo.AT_BEGIN;
        } else if ("AT_END".equals(scopeStr)) {
            scope = VariableInfo.AT_END;
        }
    }

    if (nameFromAttribute != null) {
        /*
         * An alias has been specified. We use 'nameGiven' to hold the
         * value of the alias, and 'nameFromAttribute' to hold the name
         * of the attribute whose value (at invocation-time) denotes the
         * name of the variable that is being aliased
         */
        nameGiven = alias;
        checkUniqueName(nameFromAttribute, VAR_NAME_FROM, n);
        checkUniqueName(alias, VAR_ALIAS, n);
    } else {
        // name-given specified
        checkUniqueName(nameGiven, VAR_NAME_GIVEN, n);
    }

    variableVector.addElement(new TagVariableInfo(nameGiven,
            nameFromAttribute, className, declare, scope));
}
 
源代码30 项目: tomcatsrc   文件: Node.java
public TagVariableInfo[] getTagVariableInfos() {
    return tagInfo.getTagVariableInfos();
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法