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

下面列出了怎么用javax.servlet.jsp.tagext.TagFileInfo的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Tomcat8-Source-Read   文件: Node.java
public CustomTag(String qName, String prefix, String localName,
        String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs,
        Attributes taglibAttrs, Mark start, Node parent,
        TagFileInfo tagFileInfo) {

    super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs,
            start, parent);

    this.uri = uri;
    this.prefix = prefix;
    this.tagFileInfo = tagFileInfo;
    this.tagInfo = tagFileInfo.getTagInfo();
    this.customNestingLevel = makeCustomNestingLevel();
    this.childInfo = new ChildInfo();

    this.implementsIterationTag = false;
    this.implementsBodyTag = false;
    this.implementsTryCatchFinally = false;
    this.implementsSimpleTag = true;
    this.implementsJspIdConsumer = false;
    this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes();
}
 
源代码2 项目: Tomcat8-Source-Read   文件: TagLibraryInfoImpl.java
@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();
}
 
源代码3 项目: Tomcat8-Source-Read   文件: TagLibraryInfoImpl.java
private TagFileInfo createTagFileInfo(TagFileXml tagFileXml, Jar jar) throws JasperException {

        String name = tagFileXml.getName();
        String path = tagFileXml.getPath();

        if (path == null) {
            // path is required
            err.jspError("jsp.error.tagfile.missingPath");
        } else if (!path.startsWith("/META-INF/tags") && !path.startsWith("/WEB-INF/tags")) {
            err.jspError("jsp.error.tagfile.illegalPath", path);
        }

        TagInfo tagInfo =
                TagFileProcessor.parseTagFileDirectives(parserController, name, path, jar, this);
        return new TagFileInfo(name, path, tagInfo);
    }
 
源代码4 项目: netbeans   文件: JspHyperlinkProvider.java
private FileObject getTagFile(TokenSequence<?> tokenSequence, JspSyntaxSupport jspSup) {
    Token token = tokenSequence.token();
    if (token.id() == JspTokenId.TAG) {
        String image = token.text().toString().trim();
        if (image.startsWith("<")) {                                 // NOI18N
            image = image.substring(1).trim();
        }
        if (!image.startsWith("jsp:") && image.indexOf(':') != -1) {  // NOI18N
            List l = jspSup.getTags(image);
            if (l.size() == 1) {
                TagLibraryInfo libInfo = ((TagInfo) l.get(0)).getTagLibrary();
                if (libInfo != null) {
                    TagFileInfo fileInfo = libInfo.getTagFile(getTagName(image));
                    if (fileInfo != null) {
                        return JspUtils.getFileObject(jspSup.getDocument(),
                                fileInfo.getPath());
                    }
                }
            }
        }
    }
    return null;
}
 
源代码5 项目: Tomcat7.0.67   文件: Node.java
public CustomTag(String qName, String prefix, String localName,
        String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs,
        Attributes taglibAttrs, Mark start, Node parent,
        TagFileInfo tagFileInfo) {

    super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs,
            start, parent);

    this.uri = uri;
    this.prefix = prefix;
    this.tagFileInfo = tagFileInfo;
    this.tagInfo = tagFileInfo.getTagInfo();
    this.customNestingLevel = makeCustomNestingLevel();
    this.childInfo = new ChildInfo();

    this.implementsIterationTag = false;
    this.implementsBodyTag = false;
    this.implementsTryCatchFinally = false;
    this.implementsSimpleTag = true;
    this.implementsJspIdConsumer = false;
    this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes();
}
 
源代码6 项目: tomcatsrc   文件: Node.java
public CustomTag(String qName, String prefix, String localName,
        String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs,
        Attributes taglibAttrs, Mark start, Node parent,
        TagFileInfo tagFileInfo) {

    super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs,
            start, parent);

    this.uri = uri;
    this.prefix = prefix;
    this.tagFileInfo = tagFileInfo;
    this.tagInfo = tagFileInfo.getTagInfo();
    this.customNestingLevel = makeCustomNestingLevel();
    this.childInfo = new ChildInfo();

    this.implementsIterationTag = false;
    this.implementsBodyTag = false;
    this.implementsTryCatchFinally = false;
    this.implementsSimpleTag = true;
    this.implementsJspIdConsumer = false;
    this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes();
}
 
源代码7 项目: packagedrone   文件: Node.java
public CustomTag(String jspVersion,
                        String qName, String prefix, String localName,
		 String uri, Attributes attrs,
		 Attributes nonTaglibXmlnsAttrs,
		 Attributes taglibAttrs,
		 Mark start, Node parent, TagFileInfo tagFileInfo) {

           super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs,
                 start, parent);

           this.jspVersion = Double.valueOf(jspVersion).doubleValue();
    this.uri = uri;
    this.prefix = prefix;
    this.tagFileInfo = tagFileInfo;
    this.tagInfo = tagFileInfo.getTagInfo();
    this.customNestingLevel = makeCustomNestingLevel();
           this.childInfo = new ChildInfo();

    this.implementsIterationTag = false;
    this.implementsBodyTag = false;
    this.implementsTryCatchFinally = false;
    this.implementsSimpleTag = true;
    this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes();
}
 
源代码8 项目: packagedrone   文件: TagFileProcessor.java
public void visit(Node.CustomTag n) throws JasperException {
          TagFileInfo tagFileInfo = n.getTagFileInfo();
          if (tagFileInfo != null) {
              String tagFilePath = tagFileInfo.getPath();
              if (tagFilePath.startsWith("/META-INF/")) {
                  // For tags in JARs, add the TLD and the tag as a dependency
                  String[] location =
                      compiler.getCompilationContext().getTldLocation(
                          tagFileInfo.getTagInfo().getTagLibrary().getURI());
                  // Add TLD
                  pageInfo.addDependant("jar:" + location[0] + "!/" +
                          location[1]);
                  // Add Tag
                  pageInfo.addDependant("jar:" + location[0] + "!" +
                          tagFilePath);
              } else {
                  pageInfo.addDependant(tagFilePath);
}
              Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
                                    pageInfo);
              n.setTagHandlerClass(c);
          }
          visitBody(n);
      }
 
源代码9 项目: Tomcat8-Source-Read   文件: TagFileProcessor.java
@Override
public void visit(Node.CustomTag n) throws JasperException {
    TagFileInfo tagFileInfo = n.getTagFileInfo();
    if (tagFileInfo != null) {
        String tagFilePath = tagFileInfo.getPath();
        if (tagFilePath.startsWith("/META-INF/")) {
            // For tags in JARs, add the TLD and the tag as a dependency
            TldResourcePath tldResourcePath =
                compiler.getCompilationContext().getTldResourcePath(
                    tagFileInfo.getTagInfo().getTagLibrary().getURI());

            try (Jar jar = tldResourcePath.openJar()) {

                if (jar != null) {
                    // Add TLD
                    pageInfo.addDependant(jar.getURL(tldResourcePath.getEntryName()),
                                          Long.valueOf(jar.getLastModified(tldResourcePath.getEntryName())));
                    // Add Tag
                    pageInfo.addDependant(jar.getURL(tagFilePath.substring(1)),
                                          Long.valueOf(jar.getLastModified(tagFilePath.substring(1))));
                } else {
                    pageInfo.addDependant(tagFilePath,
                                          compiler.getCompilationContext().getLastModified(tagFilePath));
                }
            } catch (IOException ioe) {
                throw new JasperException(ioe);
            }
        } else {
            pageInfo.addDependant(tagFilePath,
                    compiler.getCompilationContext().getLastModified(tagFilePath));
        }
        Class<?> c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
                pageInfo);
        n.setTagHandlerClass(c);
    }
    visitBody(n);
}
 
源代码10 项目: Tomcat8-Source-Read   文件: TestTagPluginManager.java
@Test
public void testBug54240() throws Exception {
    Tomcat tomcat = getTomcatInstanceTestWebapp(false, true);



    ServletContext context = ((Context) tomcat.getHost().findChildren()[0]).getServletContext();

    TagPluginManager manager = new TagPluginManager(context);

    Node.Nodes nodes = new Node.Nodes();
    Node.CustomTag c = new Node.CustomTag("test:ATag", "test", "ATag",
            "http://tomcat.apache.org/jasper", null, null, null, null, null,
            new TagFileInfo("ATag", "http://tomcat.apache.org/jasper",
                    tagInfo));
    c.setTagHandlerClass(TesterTag.class);
    nodes.add(c);
    manager.apply(nodes, null, null);

    Node n = nodes.getNode(0);
    Assert.assertNotNull(n);
    Assert.assertTrue(n instanceof Node.CustomTag);

    Node.CustomTag t = (Node.CustomTag)n;
    Assert.assertNotNull(t.getAtSTag());

    Node.Nodes sTag = c.getAtSTag();
    Node scriptlet = sTag.getNode(0);
    Assert.assertNotNull(scriptlet);
    Assert.assertTrue(scriptlet instanceof Node.Scriptlet);
    Node.Scriptlet s = (Node.Scriptlet)scriptlet;
    Assert.assertEquals("//Just a comment", s.getText());
}
 
源代码11 项目: netbeans   文件: PageInfo.java
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();
}
 
源代码12 项目: Tomcat7.0.67   文件: TagFileProcessor.java
@Override
public void visit(Node.CustomTag n) throws JasperException {
    TagFileInfo tagFileInfo = n.getTagFileInfo();
    if (tagFileInfo != null) {
        String tagFilePath = tagFileInfo.getPath();
        if (tagFilePath.startsWith("/META-INF/")) {
            // For tags in JARs, add the TLD and the tag as a dependency
            TldLocation location =
                compiler.getCompilationContext().getTldLocation(
                    tagFileInfo.getTagInfo().getTagLibrary().getURI());
            JarResource jarResource = location.getJarResource();
            if (jarResource != null) {
                try {
                    // Add TLD
                    pageInfo.addDependant(jarResource.getEntry(location.getName()).toString(),
                            Long.valueOf(jarResource.getJarFile().getEntry(location.getName()).getTime()));
                    // Add Tag
                    pageInfo.addDependant(jarResource.getEntry(tagFilePath.substring(1)).toString(),
                            Long.valueOf(jarResource.getJarFile().getEntry(tagFilePath.substring(1)).getTime()));
                } catch (IOException ioe) {
                    throw new JasperException(ioe);
                }
            }
            else {
                pageInfo.addDependant(tagFilePath,
                        compiler.getCompilationContext().getLastModified(
                                tagFilePath));
            }
        } else {
            pageInfo.addDependant(tagFilePath,
                    compiler.getCompilationContext().getLastModified(
                            tagFilePath));
        }
        Class<?> c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
                pageInfo);
        n.setTagHandlerClass(c);
    }
    visitBody(n);
}
 
源代码13 项目: Tomcat7.0.67   文件: TestTagPluginManager.java
@Test
public void testBug54240() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
    tomcat.start();

    ServletContext context = ctx.getServletContext();

    TagPluginManager manager = new TagPluginManager(context);

    Node.Nodes nodes = new Node.Nodes();
    Node.CustomTag c = new Node.CustomTag("test:ATag", "test", "ATag",
            "http://tomcat.apache.org/jasper", null, null, null, null, null,
            new TagFileInfo("ATag", "http://tomcat.apache.org/jasper",
                    tagInfo));
    c.setTagHandlerClass(TesterTag.class);
    nodes.add(c);
    manager.apply(nodes, null, null);

    Node n = nodes.getNode(0);
    Assert.assertNotNull(n);
    Assert.assertTrue(n instanceof Node.CustomTag);

    Node.CustomTag t = (Node.CustomTag)n;
    Assert.assertNotNull(t.getAtSTag());

    Node.Nodes sTag = c.getAtSTag();
    Node scriptlet = sTag.getNode(0);
    Assert.assertNotNull(scriptlet);
    Assert.assertTrue(scriptlet instanceof Node.Scriptlet);
    Node.Scriptlet s = (Node.Scriptlet)scriptlet;
    Assert.assertEquals("//Just a comment", s.getText());
}
 
源代码14 项目: lams   文件: TagLibraryInfo.java
/**
 * Get the TagFileInfo for a given tag name, looking through all the
 * tag files in this tag library.
 *
 * @param shortname The short name (no prefix) of the tag
 * @return the TagFileInfo for the specified Tag file, or null
 *         if no Tag file is found
 * @since JSP 2.0
 */
public TagFileInfo getTagFile(String shortname) {
    TagFileInfo tagFiles[] = getTagFiles();

    if (tagFiles == null || tagFiles.length == 0) {
        return null;
    }

    for (int i=0; i < tagFiles.length; i++) {
        if (tagFiles[i].getName().equals(shortname)) {
            return tagFiles[i];
        }
    }
    return null;
}
 
源代码15 项目: tomcatsrc   文件: TagFileProcessor.java
@Override
public void visit(Node.CustomTag n) throws JasperException {
    TagFileInfo tagFileInfo = n.getTagFileInfo();
    if (tagFileInfo != null) {
        String tagFilePath = tagFileInfo.getPath();
        if (tagFilePath.startsWith("/META-INF/")) {
            // For tags in JARs, add the TLD and the tag as a dependency
            TldLocation location =
                compiler.getCompilationContext().getTldLocation(
                    tagFileInfo.getTagInfo().getTagLibrary().getURI());
            JarResource jarResource = location.getJarResource();
            if (jarResource != null) {
                try {
                    // Add TLD
                    pageInfo.addDependant(jarResource.getEntry(location.getName()).toString(),
                            Long.valueOf(jarResource.getJarFile().getEntry(location.getName()).getTime()));
                    // Add Tag
                    pageInfo.addDependant(jarResource.getEntry(tagFilePath.substring(1)).toString(),
                            Long.valueOf(jarResource.getJarFile().getEntry(tagFilePath.substring(1)).getTime()));
                } catch (IOException ioe) {
                    throw new JasperException(ioe);
                }
            }
            else {
                pageInfo.addDependant(tagFilePath,
                        compiler.getCompilationContext().getLastModified(
                                tagFilePath));
            }
        } else {
            pageInfo.addDependant(tagFilePath,
                    compiler.getCompilationContext().getLastModified(
                            tagFilePath));
        }
        Class<?> c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
                pageInfo);
        n.setTagHandlerClass(c);
    }
    visitBody(n);
}
 
源代码16 项目: tomcatsrc   文件: TestTagPluginManager.java
@Test
public void testBug54240() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    Context ctx = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
    tomcat.start();

    ServletContext context = ctx.getServletContext();

    TagPluginManager manager = new TagPluginManager(context);

    Node.Nodes nodes = new Node.Nodes();
    Node.CustomTag c = new Node.CustomTag("test:ATag", "test", "ATag",
            "http://tomcat.apache.org/jasper", null, null, null, null, null,
            new TagFileInfo("ATag", "http://tomcat.apache.org/jasper",
                    tagInfo));
    c.setTagHandlerClass(TesterTag.class);
    nodes.add(c);
    manager.apply(nodes, null, null);

    Node n = nodes.getNode(0);
    Assert.assertNotNull(n);
    Assert.assertTrue(n instanceof Node.CustomTag);

    Node.CustomTag t = (Node.CustomTag)n;
    Assert.assertNotNull(t.getAtSTag());

    Node.Nodes sTag = c.getAtSTag();
    Node scriptlet = sTag.getNode(0);
    Assert.assertNotNull(scriptlet);
    Assert.assertTrue(scriptlet instanceof Node.Scriptlet);
    Node.Scriptlet s = (Node.Scriptlet)scriptlet;
    Assert.assertEquals("//Just a comment", s.getText());
}
 
源代码17 项目: packagedrone   文件: Node.java
public CustomTag(String jspVersion,
                        String qName, String prefix, String localName,
		 String uri, Attributes attrs, Mark start, Node parent,
		 TagFileInfo tagFileInfo) {
    this(jspVersion, qName, prefix, localName, uri, attrs, null, null,
                start, parent, tagFileInfo);
}
 
源代码18 项目: Tomcat8-Source-Read   文件: JspDocumentParser.java
private Node parseCustomAction(
    String qName,
    String localName,
    String uri,
    Attributes nonTaglibAttrs,
    Attributes nonTaglibXmlnsAttrs,
    Attributes taglibAttrs,
    Mark start,
    Node parent)
    throws SAXException {

    // Check if this is a user-defined (custom) tag
    TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);
    if (tagLibInfo == null) {
        return null;
    }

    TagInfo tagInfo = tagLibInfo.getTag(localName);
    TagFileInfo tagFileInfo = tagLibInfo.getTagFile(localName);
    if (tagInfo == null && tagFileInfo == null) {
        throw new SAXParseException(
            Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri),
            locator);
    }
    Class<?> tagHandlerClass = null;
    if (tagInfo != null) {
        String handlerClassName = tagInfo.getTagClassName();
        try {
            tagHandlerClass =
                ctxt.getClassLoader().loadClass(handlerClassName);
        } catch (Exception e) {
            throw new SAXParseException(
                Localizer.getMessage("jsp.error.loadclass.taghandler",
                                     handlerClassName,
                                     qName),
                locator, e);
        }
    }

    String prefix = getPrefix(qName);

    Node.CustomTag ret = null;
    if (tagInfo != null) {
        ret =
            new Node.CustomTag(
                qName,
                prefix,
                localName,
                uri,
                nonTaglibAttrs,
                nonTaglibXmlnsAttrs,
                taglibAttrs,
                start,
                parent,
                tagInfo,
                tagHandlerClass);
    } else {
        ret =
            new Node.CustomTag(
                qName,
                prefix,
                localName,
                uri,
                nonTaglibAttrs,
                nonTaglibXmlnsAttrs,
                taglibAttrs,
                start,
                parent,
                tagFileInfo);
    }

    return ret;
}
 
源代码19 项目: Tomcat8-Source-Read   文件: Node.java
public CustomTag(String qName, String prefix, String localName,
        String uri, Attributes attrs, Mark start, Node parent,
        TagFileInfo tagFileInfo) {
    this(qName, prefix, localName, uri, attrs, null, null, start,
            parent, tagFileInfo);
}
 
源代码20 项目: Tomcat8-Source-Read   文件: Node.java
public TagFileInfo getTagFileInfo() {
    return tagFileInfo;
}
 
源代码21 项目: netbeans   文件: GetParseData.java
public TagFileInfoCacheRecord(long time, TagFileInfo info){
    tagFileInfo = info;
    this.time = time;
}
 
源代码22 项目: netbeans   文件: PageInfo.java
@Override
public int compare(TagFileInfo o1, TagFileInfo o2) {
    return o1.getPath().compareTo(o2.getPath());
}
 
源代码23 项目: netbeans   文件: PageInfo.java
public String tagFileToString(TagFileInfo tagFile, String indent) {
    StringBuilder sb = new StringBuilder();
    sb.append(indent).append("tagfile path : ").append(tagFile.getPath()).append('\n');  // NOI18N
    sb.append(tagInfoToString(tagFile.getTagInfo(), indent));
    return sb.toString();
}
 
源代码24 项目: Tomcat7.0.67   文件: JspDocumentParser.java
private Node parseCustomAction(
    String qName,
    String localName,
    String uri,
    Attributes nonTaglibAttrs,
    Attributes nonTaglibXmlnsAttrs,
    Attributes taglibAttrs,
    Mark start,
    Node parent)
    throws SAXException {

    // Check if this is a user-defined (custom) tag
    TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);
    if (tagLibInfo == null) {
        return null;
    }

    TagInfo tagInfo = tagLibInfo.getTag(localName);
    TagFileInfo tagFileInfo = tagLibInfo.getTagFile(localName);
    if (tagInfo == null && tagFileInfo == null) {
        throw new SAXParseException(
            Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri),
            locator);
    }
    Class<?> tagHandlerClass = null;
    if (tagInfo != null) {
        String handlerClassName = tagInfo.getTagClassName();
        try {
            tagHandlerClass =
                ctxt.getClassLoader().loadClass(handlerClassName);
        } catch (Exception e) {
            throw new SAXParseException(
                Localizer.getMessage("jsp.error.loadclass.taghandler",
                                     handlerClassName,
                                     qName),
                locator, e);
        }
    }

    String prefix = getPrefix(qName);

    Node.CustomTag ret = null;
    if (tagInfo != null) {
        ret =
            new Node.CustomTag(
                qName,
                prefix,
                localName,
                uri,
                nonTaglibAttrs,
                nonTaglibXmlnsAttrs,
                taglibAttrs,
                start,
                parent,
                tagInfo,
                tagHandlerClass);
    } else {
        ret =
            new Node.CustomTag(
                qName,
                prefix,
                localName,
                uri,
                nonTaglibAttrs,
                nonTaglibXmlnsAttrs,
                taglibAttrs,
                start,
                parent,
                tagFileInfo);
    }

    return ret;
}
 
源代码25 项目: Tomcat7.0.67   文件: Parser.java
private void parseTaglibDirective(Node parent) throws JasperException {

        Attributes attrs = parseAttributes();
        String uri = attrs.getValue("uri");
        String prefix = attrs.getValue("prefix");
        if (prefix != null) {
            Mark prevMark = pageInfo.getNonCustomTagPrefix(prefix);
            if (prevMark != null) {
                err.jspError(reader.mark(), "jsp.error.prefix.use_before_dcl",
                        prefix, prevMark.getFile(), ""
                                + prevMark.getLineNumber());
            }
            if (uri != null) {
                String uriPrev = pageInfo.getURI(prefix);
                if (uriPrev != null && !uriPrev.equals(uri)) {
                    err.jspError(reader.mark(), "jsp.error.prefix.refined",
                            prefix, uri, uriPrev);
                }
                if (pageInfo.getTaglib(uri) == null) {
                    TagLibraryInfoImpl impl = null;
                    if (ctxt.getOptions().isCaching()) {
                        impl = (TagLibraryInfoImpl) ctxt.getOptions()
                                .getCache().get(uri);
                    }
                    if (impl == null) {
                        TldLocation location = ctxt.getTldLocation(uri);
                        impl = new TagLibraryInfoImpl(ctxt, parserController,
                                pageInfo, prefix, uri, location, err,
                                reader.mark());
                        if (ctxt.getOptions().isCaching()) {
                            ctxt.getOptions().getCache().put(uri, impl);
                        }
                    } else {
                        // Current compilation context needs location of cached
                        // tag files
                        for (TagFileInfo info : impl.getTagFiles()) {
                            ctxt.setTagFileJarResource(info.getPath(),
                                    ctxt.getTagFileJarResource());
                        }
                    }
                    pageInfo.addTaglib(uri, impl);
                }
                pageInfo.addPrefixMapping(prefix, uri);
            } else {
                String tagdir = attrs.getValue("tagdir");
                if (tagdir != null) {
                    String urnTagdir = URN_JSPTAGDIR + tagdir;
                    if (pageInfo.getTaglib(urnTagdir) == null) {
                        pageInfo.addTaglib(urnTagdir,
                                new ImplicitTagLibraryInfo(ctxt,
                                        parserController, pageInfo, prefix,
                                        tagdir, err));
                    }
                    pageInfo.addPrefixMapping(prefix, urnTagdir);
                }
            }
        }

        new Node.TaglibDirective(attrs, start, parent);
    }
 
源代码26 项目: Tomcat7.0.67   文件: Parser.java
private boolean parseCustomTag(Node parent) throws JasperException {

        if (reader.peekChar() != '<') {
            return false;
        }

        // Parse 'CustomAction' production (tag prefix and custom action name)
        reader.nextChar(); // skip '<'
        String tagName = reader.parseToken(false);
        int i = tagName.indexOf(':');
        if (i == -1) {
            reader.reset(start);
            return false;
        }

        String prefix = tagName.substring(0, i);
        String shortTagName = tagName.substring(i + 1);

        // Check if this is a user-defined tag.
        String uri = pageInfo.getURI(prefix);
        if (uri == null) {
            if (pageInfo.isErrorOnUndeclaredNamespace()) {
                err.jspError(start, "jsp.error.undeclared_namespace", prefix);
            } else {
                reader.reset(start);
                // Remember the prefix for later error checking
                pageInfo.putNonCustomTagPrefix(prefix, reader.mark());
                return false;
            }
        }

        TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);
        TagInfo tagInfo = tagLibInfo.getTag(shortTagName);
        TagFileInfo tagFileInfo = tagLibInfo.getTagFile(shortTagName);
        if (tagInfo == null && tagFileInfo == null) {
            err.jspError(start, "jsp.error.bad_tag", shortTagName, prefix);
        }
        Class<?> tagHandlerClass = null;
        if (tagInfo != null) {
            // Must be a classic tag, load it here.
            // tag files will be loaded later, in TagFileProcessor
            String handlerClassName = tagInfo.getTagClassName();
            try {
                tagHandlerClass = ctxt.getClassLoader().loadClass(
                        handlerClassName);
            } catch (Exception e) {
                err.jspError(start, "jsp.error.loadclass.taghandler",
                        handlerClassName, tagName);
            }
        }

        // Parse 'CustomActionBody' production:
        // At this point we are committed - if anything fails, we produce
        // a translation error.

        // Parse 'Attributes' production:
        Attributes attrs = parseAttributes();
        reader.skipSpaces();

        // Parse 'CustomActionEnd' production:
        if (reader.matches("/>")) {
            if (tagInfo != null) {
                new Node.CustomTag(tagName, prefix, shortTagName, uri, attrs,
                        start, parent, tagInfo, tagHandlerClass);
            } else {
                new Node.CustomTag(tagName, prefix, shortTagName, uri, attrs,
                        start, parent, tagFileInfo);
            }
            return true;
        }

        // Now we parse one of 'CustomActionTagDependent',
        // 'CustomActionJSPContent', or 'CustomActionScriptlessContent'.
        // depending on body-content in TLD.

        // Looking for a body, it still can be empty; but if there is a
        // a tag body, its syntax would be dependent on the type of
        // body content declared in the TLD.
        String bc;
        if (tagInfo != null) {
            bc = tagInfo.getBodyContent();
        } else {
            bc = tagFileInfo.getTagInfo().getBodyContent();
        }

        Node tagNode = null;
        if (tagInfo != null) {
            tagNode = new Node.CustomTag(tagName, prefix, shortTagName, uri,
                    attrs, start, parent, tagInfo, tagHandlerClass);
        } else {
            tagNode = new Node.CustomTag(tagName, prefix, shortTagName, uri,
                    attrs, start, parent, tagFileInfo);
        }

        parseOptionalBody(tagNode, tagName, bc);

        return true;
    }
 
源代码27 项目: Tomcat7.0.67   文件: Node.java
public CustomTag(String qName, String prefix, String localName,
        String uri, Attributes attrs, Mark start, Node parent,
        TagFileInfo tagFileInfo) {
    this(qName, prefix, localName, uri, attrs, null, null, start,
            parent, tagFileInfo);
}
 
源代码28 项目: Tomcat7.0.67   文件: Node.java
public TagFileInfo getTagFileInfo() {
    return tagFileInfo;
}
 
源代码29 项目: Tomcat7.0.67   文件: TagLibraryInfoImpl.java
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();
    }
}
 
源代码30 项目: Tomcat7.0.67   文件: TagLibraryInfoImpl.java
private TagFileInfo createTagFileInfo(TreeNode elem, JarResource jarResource)
        throws JasperException {

    String name = null;
    String path = null;

    Iterator<TreeNode> list = elem.findChildren();
    while (list.hasNext()) {
        TreeNode child = list.next();
        String tname = child.getName();
        if ("name".equals(tname)) {
            name = child.getBody();
        } else if ("path".equals(tname)) {
            path = child.getBody();
        } else if ("example".equals(tname)) {
            // Ignore <example> element: Bugzilla 33538
        } else if ("tag-extension".equals(tname)) {
            // Ignore <tag-extension> element: Bugzilla 33538
        } else if ("icon".equals(tname) 
                || "display-name".equals(tname) 
                || "description".equals(tname)) {
            // Ignore these elements: Bugzilla 38015
        } else {
            if (log.isWarnEnabled()) {
                log.warn(Localizer.getMessage(
                        "jsp.warning.unknown.element.in.tagfile", tname));
            }
        }
    }

    if (path.startsWith("/META-INF/tags")) {
        // Tag file packaged in JAR
        // See https://bz.apache.org/bugzilla/show_bug.cgi?id=46471
        // This needs to be removed once all the broken code that depends on
        // it has been removed
        ctxt.setTagFileJarResource(path, jarResource);
    } else if (!path.startsWith("/WEB-INF/tags")) {
        err.jspError("jsp.error.tagfile.illegalPath", path);
    }

    TagInfo tagInfo = TagFileProcessor.parseTagFileDirectives(
            parserController, name, path, jarResource, this);
    return new TagFileInfo(name, path, tagInfo);
}
 
 类所在包
 类方法
 同包方法