MCPcopy Create free account
hub / github.com/apache/tomcat / parse

Method parse

java/org/apache/tomcat/util/descriptor/tld/TldParser.java:76–102  ·  view source on GitHub ↗

Parses a TLD from the given resource path. @param path the TLD resource path @return the parsed tag library XML @throws IOException if an I/O error occurs @throws SAXException if a parsing error occurs

(TldResourcePath path)

Source from the content-addressed store, hash-verified

74 * @throws SAXException if a parsing error occurs
75 */
76 public TaglibXml parse(TldResourcePath path) throws IOException, SAXException {
77 Thread currentThread = Thread.currentThread();
78 ClassLoader original = currentThread.getContextClassLoader();
79 try (InputStream is = path.openStream()) {
80 currentThread.setContextClassLoader(TldParser.class.getClassLoader());
81 XmlErrorHandler handler = new XmlErrorHandler();
82 digester.setErrorHandler(handler);
83
84 TaglibXml taglibXml = new TaglibXml();
85 digester.push(taglibXml);
86
87 InputSource source = new InputSource(path.toExternalForm());
88 source.setByteStream(is);
89 digester.parse(source);
90 if (!handler.getWarnings().isEmpty() || !handler.getErrors().isEmpty()) {
91 handler.logFindings(log, source.getSystemId());
92 if (!handler.getErrors().isEmpty()) {
93 // throw the first to indicate there was an error during processing
94 throw handler.getErrors().iterator().next();
95 }
96 }
97 return taglibXml;
98 } finally {
99 digester.reset();
100 currentThread.setContextClassLoader(original);
101 }
102 }
103
104 /**
105 * Sets the class loader used for parsing.

Callers 1

Calls 12

getWarningsMethod · 0.95
getErrorsMethod · 0.95
logFindingsMethod · 0.95
toExternalFormMethod · 0.80
openStreamMethod · 0.65
getClassLoaderMethod · 0.65
pushMethod · 0.65
nextMethod · 0.65
resetMethod · 0.65
setErrorHandlerMethod · 0.45
isEmptyMethod · 0.45
iteratorMethod · 0.45

Tested by

no test coverage detected