Search in sources :

Example 11 with TreeNode

use of org.apache.jasper.xmlparser.TreeNode in project tomcat70 by apache.

the class TagLibraryInfoImpl method createAttribute.

TagAttributeInfo createAttribute(TreeNode elem, String jspVersion) {
    String name = null;
    String type = null;
    String expectedType = null;
    String methodSignature = null;
    boolean required = false, rtexprvalue = false, isFragment = false, deferredValue = false, deferredMethod = false;
    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 ("required".equals(tname)) {
            String s = element.getBody();
            if (s != null)
                required = JspUtil.booleanValue(s);
        } else if ("rtexprvalue".equals(tname)) {
            String s = element.getBody();
            if (s != null)
                rtexprvalue = JspUtil.booleanValue(s);
        } else if ("type".equals(tname)) {
            type = element.getBody();
            if ("1.2".equals(jspVersion) && (type.equals("Boolean") || type.equals("Byte") || type.equals("Character") || type.equals("Double") || type.equals("Float") || type.equals("Integer") || type.equals("Long") || type.equals("Object") || type.equals("Short") || type.equals("String"))) {
                type = "java.lang." + type;
            }
        } else if ("fragment".equals(tname)) {
            String s = element.getBody();
            if (s != null) {
                isFragment = JspUtil.booleanValue(s);
            }
        } else if ("deferred-value".equals(tname)) {
            deferredValue = true;
            type = "javax.el.ValueExpression";
            TreeNode child = element.findChild("type");
            if (child != null) {
                expectedType = child.getBody();
                if (expectedType != null) {
                    expectedType = expectedType.trim();
                }
            } else {
                expectedType = "java.lang.Object";
            }
        } else if ("deferred-method".equals(tname)) {
            deferredMethod = true;
            type = "javax.el.MethodExpression";
            TreeNode child = element.findChild("method-signature");
            if (child != null) {
                methodSignature = child.getBody();
                if (methodSignature != null) {
                    methodSignature = methodSignature.trim();
                }
            } else {
                methodSignature = "java.lang.Object method()";
            }
        } else if ("description".equals(tname) || false) {
        // Ignored elements
        } else {
            if (log.isWarnEnabled()) {
                log.warn(Localizer.getMessage("jsp.warning.unknown.element.in.attribute", tname));
            }
        }
    }
    if (isFragment) {
        /*
             * According to JSP.C-3 ("TLD Schema Element Structure - tag"),
             * 'type' and 'rtexprvalue' must not be specified if 'fragment' has
             * been specified (this will be enforced by validating parser).
             * Also, if 'fragment' is TRUE, 'type' is fixed at
             * javax.servlet.jsp.tagext.JspFragment, and 'rtexprvalue' is fixed
             * at true. See also JSP.8.5.2.
             */
        type = "javax.servlet.jsp.tagext.JspFragment";
        rtexprvalue = true;
    }
    if (!rtexprvalue && type == null) {
        // According to JSP spec, for static values (those determined at
        // translation time) the type is fixed at java.lang.String.
        type = "java.lang.String";
    }
    return new TagAttributeInfo(name, required, type, rtexprvalue, isFragment, null, deferredValue, deferredMethod, expectedType, methodSignature);
}
Also used : TreeNode(org.apache.jasper.xmlparser.TreeNode) TagAttributeInfo(javax.servlet.jsp.tagext.TagAttributeInfo)

Example 12 with TreeNode

use of org.apache.jasper.xmlparser.TreeNode in project tomcat70 by apache.

the class TagLibraryInfoImpl method createInitParam.

String[] createInitParam(TreeNode elem) {
    String[] initParam = new String[2];
    Iterator<TreeNode> list = elem.findChildren();
    while (list.hasNext()) {
        TreeNode element = list.next();
        String tname = element.getName();
        if ("param-name".equals(tname)) {
            initParam[0] = element.getBody();
        } else if ("param-value".equals(tname)) {
            initParam[1] = element.getBody();
        } else if ("description".equals(tname)) {
        // Do nothing
        } else {
            if (log.isWarnEnabled()) {
                log.warn(Localizer.getMessage("jsp.warning.unknown.element.in.initParam", tname));
            }
        }
    }
    return initParam;
}
Also used : TreeNode(org.apache.jasper.xmlparser.TreeNode)

Aggregations

TreeNode (org.apache.jasper.xmlparser.TreeNode)12 JasperException (org.apache.jasper.JasperException)5 ParserUtils (org.apache.jasper.xmlparser.ParserUtils)5 Vector (java.util.Vector)3 TagInfo (javax.servlet.jsp.tagext.TagInfo)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Hashtable (java.util.Hashtable)2 FunctionInfo (javax.servlet.jsp.tagext.FunctionInfo)2 TagAttributeInfo (javax.servlet.jsp.tagext.TagAttributeInfo)2 TagFileInfo (javax.servlet.jsp.tagext.TagFileInfo)2 TagVariableInfo (javax.servlet.jsp.tagext.TagVariableInfo)2 ServletContext (javax.servlet.ServletContext)1 TagExtraInfo (javax.servlet.jsp.tagext.TagExtraInfo)1 TagLibraryValidator (javax.servlet.jsp.tagext.TagLibraryValidator)1 TagPlugin (org.apache.jasper.compiler.tagplugin.TagPlugin)1