javax.servlet.jsp.tagext.FunctionInfo Java Examples

The following examples show how to use javax.servlet.jsp.tagext.FunctionInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Validator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Get the method name from the signature.
 */
private String getMethod(ELNode.Function func) throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();

    int start = signature.indexOf(' ');
    if (start < 0) {
        err.jspError("jsp.error.tld.fn.invalid.signature", func
                .getPrefix(), func.getName());
    }
    int end = signature.indexOf('(');
    if (end < 0) {
        err.jspError(
                "jsp.error.tld.fn.invalid.signature.parenexpected",
                func.getPrefix(), func.getName());
    }
    return signature.substring(start + 1, end).trim();
}
 
Example #2
Source File: Validator.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Get the method name from the signature.
 */
private String getMethod(ELNode.Function func) throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();

    int start = signature.indexOf(' ');
    if (start < 0) {
        err.jspError("jsp.error.tld.fn.invalid.signature", func
                .getPrefix(), func.getName());
    }
    int end = signature.indexOf('(');
    if (end < 0) {
        err.jspError(
                "jsp.error.tld.fn.invalid.signature.parenexpected",
                func.getPrefix(), func.getName());
    }
    return signature.substring(start + 1, end).trim();
}
 
Example #3
Source File: TagLibraryInfoImpl.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public String toString() {
    StringWriter sw = new StringWriter();
    PrintWriter out = new PrintWriter(sw);
    print("tlibversion", tlibversion, out);
    print("jspversion", jspversion, out);
    print("shortname", shortname, out);
    print("urn", urn, out);
    print("info", info, out);
    print("uri", uri, out);
    print("tagLibraryValidator", "" + tagLibraryValidator, out);

    for (TagInfo tag : tags) {
        out.println(tag.toString());
    }

    for (TagFileInfo tagFile : tagFiles) {
        out.println(tagFile.toString());
    }

    for (FunctionInfo function : functions) {
        out.println(function.toString());
    }

    return sw.toString();
}
 
Example #4
Source File: PageInfo.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public String tagLibraryInfoToString(TagLibraryInfo info, String indent) {
    StringBuilder sb = new StringBuilder();
    sb.append(indent).append("tlibversion : ").append(getFieldByReflection("tlibversion", info)).append('\n');  // NOI18N
    sb.append(indent).append("jspversion  : ").append(info.getRequiredVersion()).append('\n');  // NOI18N
    sb.append(indent).append("shortname   : ").append(info.getShortName()).append('\n');  // NOI18N
    sb.append(indent).append("urn         : ").append(info.getReliableURN()).append('\n');  // NOI18N
    sb.append(indent).append("info        : ").append(info.getInfoString()).append('\n');  // NOI18N
    sb.append(indent).append("uri         : ").append(info.getURI()).append('\n');  // NOI18N
    
    TagInfo tags[] = info.getTags();
    if (tags != null) {
        for (int i = 0; i < tags.length; i++)
            sb.append(tagInfoToString(tags[i], indent + "  "));  // NOI18N
    }
    
    TagFileInfo tagFiles[] = info.getTagFiles().clone();
    Arrays.sort(tagFiles, TAG_FILE_INFO_COMPARATOR);
    if (tagFiles != null) {
        for (int i = 0; i < tagFiles.length; i++)
            sb.append(tagFileToString(tagFiles[i], indent + "  "));  // NOI18N
    }
    
    FunctionInfo functions[] = info.getFunctions();
    if (functions != null) {
        for (int i = 0; i < functions.length; i++)
            sb.append(functionInfoToString(functions[i], indent + "  "));  // NOI18N
    }
    
    return sb.toString();
}
 
Example #5
Source File: Validator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Get the parameters types from the function signature.
 *
 * @return An array of parameter class names
 */
private String[] getParameters(ELNode.Function func)
        throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();
    ArrayList<String> params = new ArrayList<String>();
    // Signature is of the form
    // <return-type> S <method-name S? '('
    // < <arg-type> ( ',' <arg-type> )* )? ')'
    int start = signature.indexOf('(') + 1;
    boolean lastArg = false;
    while (true) {
        int p = signature.indexOf(',', start);
        if (p < 0) {
            p = signature.indexOf(')', start);
            if (p < 0) {
                err.jspError("jsp.error.tld.fn.invalid.signature", func
                        .getPrefix(), func.getName());
            }
            lastArg = true;
        }
        String arg = signature.substring(start, p).trim();
        if (!"".equals(arg)) {
            params.add(arg);
        }
        if (lastArg) {
            break;
        }
        start = p + 1;
    }
    return params.toArray(new String[params.size()]);
}
 
Example #6
Source File: TagLibraryInfoImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
FunctionInfo createFunctionInfo(TreeNode elem) {

        String name = null;
        String klass = null;
        String signature = null;

        Iterator<TreeNode> list = elem.findChildren();
        while (list.hasNext()) {
            TreeNode element = list.next();
            String tname = element.getName();

            if ("name".equals(tname)) {
                name = element.getBody();
            } else if ("function-class".equals(tname)) {
                klass = element.getBody();
            } else if ("function-signature".equals(tname)) {
                signature = element.getBody();
            } else if ("display-name".equals(tname) || // Ignored elements
                    "small-icon".equals(tname) || "large-icon".equals(tname)
                    || "description".equals(tname) || "example".equals(tname)) {
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage(
                            "jsp.warning.unknown.element.in.function", tname));
                }
            }
        }

        return new FunctionInfo(name, klass, signature);
    }
 
Example #7
Source File: Validator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Get the parameters types from the function signature.
 *
 * @return An array of parameter class names
 */
private String[] getParameters(ELNode.Function func)
        throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();
    ArrayList<String> params = new ArrayList<String>();
    // Signature is of the form
    // <return-type> S <method-name S? '('
    // < <arg-type> ( ',' <arg-type> )* )? ')'
    int start = signature.indexOf('(') + 1;
    boolean lastArg = false;
    while (true) {
        int p = signature.indexOf(',', start);
        if (p < 0) {
            p = signature.indexOf(')', start);
            if (p < 0) {
                err.jspError("jsp.error.tld.fn.invalid.signature", func
                        .getPrefix(), func.getName());
            }
            lastArg = true;
        }
        String arg = signature.substring(start, p).trim();
        if (!"".equals(arg)) {
            params.add(arg);
        }
        if (lastArg) {
            break;
        }
        start = p + 1;
    }
    return params.toArray(new String[params.size()]);
}
 
Example #8
Source File: PageInfo.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public String functionInfoToString(FunctionInfo function, String indent) {
    StringBuilder sb = new StringBuilder();
    if (function != null) {
        sb.append(indent).append("function name     : ").append(function.getName()).append('\n');  // NOI18N
        sb.append(indent).append("         class    : ").append(function.getFunctionClass()).append('\n');  // NOI18N
        sb.append(indent).append("         signature: ").append(function.getFunctionSignature()).append('\n');  // NOI18N
    }
    else {
        sb.append(indent).append("functioninfo is null\n");  // NOI18N
    }
    return sb.toString();
}
 
Example #9
Source File: TagLibraryInfoImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
FunctionInfo createFunctionInfo(TreeNode elem) {

        String name = null;
        String klass = null;
        String signature = null;

        Iterator<TreeNode> list = elem.findChildren();
        while (list.hasNext()) {
            TreeNode element = list.next();
            String tname = element.getName();

            if ("name".equals(tname)) {
                name = element.getBody();
            } else if ("function-class".equals(tname)) {
                klass = element.getBody();
            } else if ("function-signature".equals(tname)) {
                signature = element.getBody();
            } else if ("display-name".equals(tname) || // Ignored elements
                    "small-icon".equals(tname) || "large-icon".equals(tname)
                    || "description".equals(tname) || "example".equals(tname)) {
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage(
                            "jsp.warning.unknown.element.in.function", tname));
                }
            }
        }

        return new FunctionInfo(name, klass, signature);
    }
 
Example #10
Source File: Validator.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private void processSignature(ELNode.Function func)
	throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();
    func.setMethodName(getMethod(signature));
    func.setParameters(getParameters(signature));
}
 
Example #11
Source File: Validator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Get the parameters types from the function signature.
 *
 * @return An array of parameter class names
 */
private String[] getParameters(ELNode.Function func)
        throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();
    ArrayList<String> params = new ArrayList<>();
    // Signature is of the form
    // <return-type> S <method-name S? '('
    // < <arg-type> ( ',' <arg-type> )* )? ')'
    int start = signature.indexOf('(') + 1;
    boolean lastArg = false;
    while (true) {
        int p = signature.indexOf(',', start);
        if (p < 0) {
            p = signature.indexOf(')', start);
            if (p < 0) {
                err.jspError("jsp.error.tld.fn.invalid.signature", func
                        .getPrefix(), func.getName());
            }
            lastArg = true;
        }
        String arg = signature.substring(start, p).trim();
        if (!"".equals(arg)) {
            params.add(arg);
        }
        if (lastArg) {
            break;
        }
        start = p + 1;
    }
    return params.toArray(new String[params.size()]);
}
 
Example #12
Source File: Validator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Get the method name from the signature.
 */
private String getMethod(ELNode.Function func) throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();

    Matcher m = METHOD_NAME_PATTERN.matcher(signature);
    if (!m.matches()) {
        err.jspError("jsp.error.tld.fn.invalid.signature", func
                .getPrefix(), func.getName());
    }

    return m.group(1);
}
 
Example #13
Source File: TagLibraryInfoImpl.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private FunctionInfo createFunctionInfo(TreeNode elem)
        throws JasperException {

    String name = null;
    String klass = null;
    String signature = null;

    Iterator list = elem.findChildren();
    while (list.hasNext()) {
        TreeNode element = (TreeNode) list.next();
        String tname = element.getName();

        if ("name".equals(tname)) {
            name = element.getBody();
        } else if ("function-class".equals(tname)) {
            klass = element.getBody();
        } else if ("function-signature".equals(tname)) {
            signature = element.getBody();
        } else if ("display-name".equals(tname) ||    // Ignored elements
                 "small-icon".equals(tname) ||
                 "large-icon".equals(tname) ||
                 "description".equals(tname) || 
                 "example".equals(tname)) {
        } else {
            err.jspError("jsp.error.unknown.element.in.function",
                         tname);
 }
    }

    return new FunctionInfo(name, klass, signature);
}
 
Example #14
Source File: ELNode.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public void setFunctionInfo(FunctionInfo f) {
    this.functionInfo = f;
}
 
Example #15
Source File: ImplicitTagLibraryInfo.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
/**
    * Constructor.
    */
   public ImplicitTagLibraryInfo(JspCompilationContext ctxt,
			  ParserController pc,
			  String prefix,
			  String tagdir,
			  ErrorDispatcher err) throws JasperException {
       super(prefix, null);
this.pc = pc;
       this.err = err;
       this.pageInfo = pc.getCompiler().getPageInfo();
this.tagFileMap = new HashMap<String, String>();
this.vec = new ArrayList<TagFileInfo>();

       // Implicit tag libraries have no functions:
       this.functions = new FunctionInfo[0];

tlibversion = TLIB_VERSION;
jspversion = JSP_VERSION;

if (!tagdir.startsWith(WEB_INF_TAGS)) {
    err.jspError("jsp.error.invalid.tagdir", tagdir);
}

// Determine the value of the <short-name> subelement of the
// "imaginary" <taglib> element
if (tagdir.equals(WEB_INF_TAGS)
        || tagdir.equals( WEB_INF_TAGS + "/")) {
    shortname = TAGS_SHORTNAME;
} else {
    shortname = tagdir.substring(WEB_INF_TAGS.length());
    shortname = shortname.replace('/', '-');
}

// Populate mapping of tag names to tag file paths
Set<String> dirList = ctxt.getResourcePaths(tagdir);
if (dirList != null) {
    Iterator it = dirList.iterator();
    while (it.hasNext()) {
	String path = (String) it.next();
	if (path.endsWith(TAG_FILE_SUFFIX)
	        || path.endsWith(TAGX_FILE_SUFFIX)) {
	    /*
	     * Use the filename of the tag file, without the .tag or
	     * .tagx extension, respectively, as the <name> subelement
	     * of the "imaginary" <tag-file> element
	     */
	    String suffix = path.endsWith(TAG_FILE_SUFFIX) ?
		TAG_FILE_SUFFIX : TAGX_FILE_SUFFIX; 
	    String tagName = path.substring(path.lastIndexOf("/") + 1);
	    tagName = tagName.substring(0,
					tagName.lastIndexOf(suffix));
	    tagFileMap.put(tagName, path);
               } else if (path.endsWith(IMPLICIT_TLD)) {
                   String tldName = path.substring(path.lastIndexOf("/") + 1);
                   if (IMPLICIT_TLD.equals(tldName)) {
                       parseImplicitTld(ctxt, path);
                   }
               }    
    }
}
   }
 
Example #16
Source File: ELNode.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
public void setFunctionInfo(FunctionInfo f) {
    this.functionInfo = f;
}
 
Example #17
Source File: ELNode.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
public FunctionInfo getFunctionInfo() {
    return functionInfo;
}
 
Example #18
Source File: TagLibraryInfoImpl.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
private void parseTLD(String uri, InputStream in, JarResource jarResource)
        throws JasperException {
    Vector<TagInfo> tagVector = new Vector<TagInfo>();
    Vector<TagFileInfo> tagFileVector = new Vector<TagFileInfo>();
    Hashtable<String, FunctionInfo> functionTable = new Hashtable<String, FunctionInfo>();

    ServletContext servletContext = ctxt.getServletContext();
    boolean validate = Boolean.parseBoolean(servletContext.getInitParameter(
            Constants.XML_VALIDATION_TLD_INIT_PARAM));
    String blockExternalString = servletContext.getInitParameter(
            Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
    boolean blockExternal;
    if (blockExternalString == null) {
        blockExternal = true;
    } else {
        blockExternal = Boolean.parseBoolean(blockExternalString);
    }

    // Create an iterator over the child elements of our <taglib> element
    ParserUtils pu = new ParserUtils(validate, blockExternal);
    TreeNode tld = pu.parseXMLDocument(uri, in);

    // Check to see if the <taglib> root element contains a 'version'
    // attribute, which was added in JSP 2.0 to replace the <jsp-version>
    // subelement
    this.jspversion = tld.findAttribute("version");

    // Process each child element of our <taglib> element
    Iterator<TreeNode> list = tld.findChildren();

    while (list.hasNext()) {
        TreeNode element = list.next();
        String tname = element.getName();

        if ("tlibversion".equals(tname) // JSP 1.1
                || "tlib-version".equals(tname)) { // JSP 1.2
            this.tlibversion = element.getBody();
        } else if ("jspversion".equals(tname)
                || "jsp-version".equals(tname)) {
            this.jspversion = element.getBody();
        } else if ("shortname".equals(tname) || "short-name".equals(tname))
            this.shortname = element.getBody();
        else if ("uri".equals(tname))
            this.urn = element.getBody();
        else if ("info".equals(tname) || "description".equals(tname))
            this.info = element.getBody();
        else if ("validator".equals(tname))
            this.tagLibraryValidator = createValidator(element);
        else if ("tag".equals(tname))
            tagVector.addElement(createTagInfo(element, jspversion));
        else if ("tag-file".equals(tname)) {
            TagFileInfo tagFileInfo = createTagFileInfo(element,
                    jarResource);
            tagFileVector.addElement(tagFileInfo);
        } else if ("function".equals(tname)) { // JSP2.0
            FunctionInfo funcInfo = createFunctionInfo(element);
            String funcName = funcInfo.getName();
            if (functionTable.containsKey(funcName)) {
                err.jspError("jsp.error.tld.fn.duplicate.name", funcName,
                        uri);

            }
            functionTable.put(funcName, funcInfo);
        } else if ("display-name".equals(tname) ||
                "small-icon".equals(tname) || "large-icon".equals(tname)
                || "listener".equals(tname)) {
            // Ignored elements
        } else if ("taglib-extension".equals(tname)) {
            // Recognized but ignored
        } else {
            if (log.isWarnEnabled()) {
                log.warn(Localizer.getMessage(
                        "jsp.warning.unknown.element.in.taglib", tname));
            }
        }

    }

    if (tlibversion == null) {
        err.jspError("jsp.error.tld.mandatory.element.missing",
                "tlib-version", uri);
    }
    if (jspversion == null) {
        err.jspError("jsp.error.tld.mandatory.element.missing",
                "jsp-version", uri);
    }

    this.tags = new TagInfo[tagVector.size()];
    tagVector.copyInto(this.tags);

    this.tagFiles = new TagFileInfo[tagFileVector.size()];
    tagFileVector.copyInto(this.tagFiles);

    this.functions = new FunctionInfo[functionTable.size()];
    int i = 0;
    Enumeration<FunctionInfo> enumeration = functionTable.elements();
    while (enumeration.hasMoreElements()) {
        this.functions[i++] = enumeration.nextElement();
    }
}
 
Example #19
Source File: ELNode.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public FunctionInfo getFunctionInfo() {
    return functionInfo;
}
 
Example #20
Source File: ELNode.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
public void setFunctionInfo(FunctionInfo f) {
    this.functionInfo = f;
}
 
Example #21
Source File: TagLibraryInfoImpl.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
private void parseTLD(String uri, InputStream in, JarResource jarResource)
        throws JasperException {
    Vector<TagInfo> tagVector = new Vector<TagInfo>();
    Vector<TagFileInfo> tagFileVector = new Vector<TagFileInfo>();
    Hashtable<String, FunctionInfo> functionTable = new Hashtable<String, FunctionInfo>();

    ServletContext servletContext = ctxt.getServletContext();
    boolean validate = Boolean.parseBoolean(servletContext.getInitParameter(
            Constants.XML_VALIDATION_TLD_INIT_PARAM));
    String blockExternalString = servletContext.getInitParameter(
            Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
    boolean blockExternal;
    if (blockExternalString == null) {
        blockExternal = true;
    } else {
        blockExternal = Boolean.parseBoolean(blockExternalString);
    }

    // Create an iterator over the child elements of our <taglib> element
    ParserUtils pu = new ParserUtils(validate, blockExternal);
    TreeNode tld = pu.parseXMLDocument(uri, in);

    // Check to see if the <taglib> root element contains a 'version'
    // attribute, which was added in JSP 2.0 to replace the <jsp-version>
    // subelement
    this.jspversion = tld.findAttribute("version");

    // Process each child element of our <taglib> element
    Iterator<TreeNode> list = tld.findChildren();

    while (list.hasNext()) {
        TreeNode element = list.next();
        String tname = element.getName();

        if ("tlibversion".equals(tname) // JSP 1.1
                || "tlib-version".equals(tname)) { // JSP 1.2
            this.tlibversion = element.getBody();
        } else if ("jspversion".equals(tname)
                || "jsp-version".equals(tname)) {
            this.jspversion = element.getBody();
        } else if ("shortname".equals(tname) || "short-name".equals(tname))
            this.shortname = element.getBody();
        else if ("uri".equals(tname))
            this.urn = element.getBody();
        else if ("info".equals(tname) || "description".equals(tname))
            this.info = element.getBody();
        else if ("validator".equals(tname))
            this.tagLibraryValidator = createValidator(element);
        else if ("tag".equals(tname))
            tagVector.addElement(createTagInfo(element, jspversion));
        else if ("tag-file".equals(tname)) {
            TagFileInfo tagFileInfo = createTagFileInfo(element,
                    jarResource);
            tagFileVector.addElement(tagFileInfo);
        } else if ("function".equals(tname)) { // JSP2.0
            FunctionInfo funcInfo = createFunctionInfo(element);
            String funcName = funcInfo.getName();
            if (functionTable.containsKey(funcName)) {
                err.jspError("jsp.error.tld.fn.duplicate.name", funcName,
                        uri);

            }
            functionTable.put(funcName, funcInfo);
        } else if ("display-name".equals(tname) ||
                "small-icon".equals(tname) || "large-icon".equals(tname)
                || "listener".equals(tname)) {
            // Ignored elements
        } else if ("taglib-extension".equals(tname)) {
            // Recognized but ignored
        } else {
            if (log.isWarnEnabled()) {
                log.warn(Localizer.getMessage(
                        "jsp.warning.unknown.element.in.taglib", tname));
            }
        }

    }

    if (tlibversion == null) {
        err.jspError("jsp.error.tld.mandatory.element.missing",
                "tlib-version", uri);
    }
    if (jspversion == null) {
        err.jspError("jsp.error.tld.mandatory.element.missing",
                "jsp-version", uri);
    }

    this.tags = new TagInfo[tagVector.size()];
    tagVector.copyInto(this.tags);

    this.tagFiles = new TagFileInfo[tagFileVector.size()];
    tagFileVector.copyInto(this.tagFiles);

    this.functions = new FunctionInfo[functionTable.size()];
    int i = 0;
    Enumeration<FunctionInfo> enumeration = functionTable.elements();
    while (enumeration.hasMoreElements()) {
        this.functions[i++] = enumeration.nextElement();
    }
}
 
Example #22
Source File: ELNode.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public FunctionInfo getFunctionInfo() {
    return functionInfo;
}
 
Example #23
Source File: TaglibXml.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public void addFunction(String name, String klass, String signature) {
    functions.add(new FunctionInfo(name, klass, signature));
}
 
Example #24
Source File: ELNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FunctionInfo getFunctionInfo() {
    return functionInfo;
}
 
Example #25
Source File: ELNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void setFunctionInfo(FunctionInfo f) {
    this.functionInfo = f;
}
 
Example #26
Source File: TestTldParser.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@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());
}
 
Example #27
Source File: ELNode.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public FunctionInfo getFunctionInfo() {
    return functionInfo;
}
 
Example #28
Source File: ELNode.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public void setFunctionInfo(FunctionInfo f) {
    this.functionInfo = f;
}
 
Example #29
Source File: TaglibXml.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public List<FunctionInfo> getFunctions() {
    return functions;
}