Example usage for javax.servlet.jsp.tagext TagInfo TagInfo

List of usage examples for javax.servlet.jsp.tagext TagInfo TagInfo

Introduction

In this page you can find the example usage for javax.servlet.jsp.tagext TagInfo TagInfo.

Prototype

public TagInfo(String tagName, String tagClassName, String bodycontent, String infoString,
        TagLibraryInfo taglib, TagExtraInfo tagExtraInfo, TagAttributeInfo[] attributeInfo, String displayName,
        String smallIcon, String largeIcon, TagVariableInfo[] tvi, boolean dynamicAttributes) 

Source Link

Document

Constructor for TagInfo from data in the JSP 2.0 format for TLD.

Usage

From source file:org.apache.jasper.compiler.TagLibraryInfoImpl.java

private TagInfo createTagInfo(TreeNode elem) throws JasperException {
    String tagName = null;//from  www .  java 2  s  .  co m
    String tagClassName = null;
    String teiClassName = null;

    /*
     * Default body content for JSP 1.2 tag handlers (<body-content> has
     * become mandatory in JSP 2.0, because the default would be invalid
     * for simple tag handlers)
     */
    String bodycontent = "JSP";

    String info = null;
    String displayName = null;
    String smallIcon = null;
    String largeIcon = null;
    boolean dynamicAttributes = false;

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

        if ("name".equals(tname)) {
            tagName = element.getBody();
        } else if ("tagclass".equals(tname) || "tag-class".equals(tname)) {
            tagClassName = element.getBody();
        } else if ("teiclass".equals(tname) || "tei-class".equals(tname)) {
            teiClassName = element.getBody();
        } else if ("bodycontent".equals(tname) || "body-content".equals(tname)) {
            bodycontent = element.getBody();
        } else if ("display-name".equals(tname)) {
            displayName = element.getBody();
        } else if ("small-icon".equals(tname)) {
            smallIcon = element.getBody();
        } else if ("large-icon".equals(tname)) {
            largeIcon = element.getBody();
        } else if ("info".equals(tname) || "description".equals(tname)) {
            info = element.getBody();
        } else if ("variable".equals(tname)) {
            variableVector.addElement(createVariable(element));
        } else if ("attribute".equals(tname)) {
            attributeVector.addElement(createAttribute(element));
        } else if ("dynamic-attributes".equals(tname)) {
            dynamicAttributes = JspUtil.booleanValue(element.getBody());
        } else if ("example".equals(tname)) {
            // Ignored elements
        } else if ("tag-extension".equals(tname)) {
            // Ignored
        } else {
            if (log.isWarnEnabled()) {
                log.warn(Localizer.getMessage("jsp.warning.unknown.element.in.tag", tname));
            }
        }
    }

    TagExtraInfo tei = null;
    if (teiClassName != null && !teiClassName.equals("")) {
        try {
            Class teiClass = ctxt.getClassLoader().loadClass(teiClassName);
            tei = (TagExtraInfo) teiClass.newInstance();
        } catch (Exception e) {
            err.jspError("jsp.error.teiclass.instantiation", teiClassName, e);
        }
    }

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

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

    TagInfo taginfo = new TagInfo(tagName, tagClassName, bodycontent, info, this, tei, tagAttributeInfo,
            displayName, smallIcon, largeIcon, tagVariableInfos, dynamicAttributes);
    return taginfo;
}

From source file:org.tinygroup.jspengine.compiler.TagLibraryInfoImpl.java

/**
 * Constructor which populates a TagLibraryInfoImpl from a given
 * TagLibraryInfoImpl, and associates the new TagLibraryInfoImpl with the
 * given translation unit (pageInfo)./*  ww  w .  ja  v a2  s . co m*/
 *
 * @param prefix The taglib's namespace prefix
 * @param uri The taglib's uri
 * @param delegate The taglib from which the new TagLibraryInfoImpl is
 * populated
 * @pageInfo The translation unit with which the new TagLibraryInfoImpl is
 * to be associated
 */
public TagLibraryInfoImpl(String prefix, String uri, TagLibraryInfoImpl delegate, PageInfo pageInfo) {

    super(prefix, uri);

    this.pageInfo = pageInfo;

    this.tagFiles = delegate.getTagFiles();
    this.functions = delegate.getFunctions();
    this.jspversion = delegate.getRequiredVersion();
    this.shortname = delegate.getShortName();
    this.urn = delegate.getReliableURN();
    this.info = delegate.getInfoString();
    this.tagLibraryValidator = delegate.getTagLibraryValidator();

    TagInfo[] otherTags = delegate.getTags();
    if (otherTags != null) {
        this.tags = new TagInfo[otherTags.length];
        for (int i = 0; i < otherTags.length; i++) {
            this.tags[i] = new TagInfo(otherTags[i].getTagName(), otherTags[i].getTagClassName(),
                    otherTags[i].getBodyContent(), otherTags[i].getInfoString(), this,
                    otherTags[i].getTagExtraInfo(), otherTags[i].getAttributes(), otherTags[i].getDisplayName(),
                    otherTags[i].getSmallIcon(), otherTags[i].getLargeIcon(),
                    otherTags[i].getTagVariableInfos(), otherTags[i].hasDynamicAttributes());
        }
    }
}

From source file:org.tinygroup.jspengine.compiler.TagLibraryInfoImpl.java

private TagInfo createTagInfo(TreeNode elem, String jspVersion) throws JasperException {
    String tagName = null;//from w  w  w  .j a  v  a  2  s  .co  m
    String tagClassName = null;
    String teiClassName = null;

    /*
     * Default body content for JSP 1.2 tag handlers (<body-content> has
     * become mandatory in JSP 2.0, because the default would be invalid
     * for simple tag handlers)
     */
    String bodycontent = "JSP";

    String info = null;
    String displayName = null;
    String smallIcon = null;
    String largeIcon = null;
    boolean dynamicAttributes = false;

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

        if ("name".equals(tname)) {
            tagName = element.getBody();
        } else if ("tagclass".equals(tname) || "tag-class".equals(tname)) {
            tagClassName = element.getBody();
        } else if ("teiclass".equals(tname) || "tei-class".equals(tname)) {
            teiClassName = element.getBody();
        } else if ("bodycontent".equals(tname) || "body-content".equals(tname)) {
            bodycontent = element.getBody();
        } else if ("display-name".equals(tname)) {
            displayName = element.getBody();
        } else if ("small-icon".equals(tname)) {
            smallIcon = element.getBody();
        } else if ("large-icon".equals(tname)) {
            largeIcon = element.getBody();
        } else if ("icon".equals(tname)) {
            TreeNode icon = element.findChild("small-icon");
            if (icon != null) {
                smallIcon = icon.getBody();
            }
            icon = element.findChild("large-icon");
            if (icon != null) {
                largeIcon = icon.getBody();
            }
        } else if ("info".equals(tname) || "description".equals(tname)) {
            info = element.getBody();
        } else if ("variable".equals(tname)) {
            variableVector.addElement(createVariable(element));
        } else if ("attribute".equals(tname)) {
            attributeVector.addElement(createAttribute(element, jspVersion));
        } else if ("dynamic-attributes".equals(tname)) {
            dynamicAttributes = JspUtil.booleanValue(element.getBody());
        } else if ("example".equals(tname)) {
            // Ignored elements
        } else if ("tag-extension".equals(tname)) {
            // Ignored
        } else {
            err.jspError("jsp.error.unknown.element.in.tag", tname);
        }
    }

    // JSP 2.0 removed the capital versions of TAGDEPENDENT, EMPTY, and
    // SCRIPTLESS enumerations in body-contentType, see JSP.E.2 ("Changes
    // between JSP 2.0 PFD2 and JSP 2.0 PFD3"), section "Changes to Tag
    // Library Descriptor (TLD)". Enforce that from JSP 2.0 and up, only
    // "JSP", "tagdependent", "empty", and "scriptless" may be specified
    // as body-content values.
    Double jspVersionDouble = Double.valueOf(jspversion);
    if (Double.compare(jspVersionDouble, Constants.JSP_VERSION_2_0) >= 0) {
        if (!bodycontent.equals(TagInfo.BODY_CONTENT_JSP) && !bodycontent.equals(TagInfo.BODY_CONTENT_EMPTY)
                && !bodycontent.equals(TagInfo.BODY_CONTENT_TAG_DEPENDENT)
                && !bodycontent.equals(TagInfo.BODY_CONTENT_SCRIPTLESS)) {
            err.jspError("jsp.error.tld.badbodycontent", bodycontent, tagName);
        }
    }

    TagExtraInfo tei = null;
    if (teiClassName != null && !teiClassName.equals("")) {
        try {
            Class teiClass = ctxt.getClassLoader().loadClass(teiClassName);
            tei = (TagExtraInfo) teiClass.newInstance();
        } catch (Exception e) {
            err.jspError("jsp.error.teiclass.instantiation", teiClassName, e);
        }
    }

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

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

    TagInfo taginfo = new TagInfo(tagName, tagClassName, bodycontent, info, this, tei, tagAttributeInfo,
            displayName, smallIcon, largeIcon, tagVariableInfos, dynamicAttributes);
    return taginfo;
}