本文整理汇总了Java中org.apache.jasper.xmlparser.ParserUtils类的典型用法代码示例。如果您正苦于以下问题:Java ParserUtils类的具体用法?Java ParserUtils怎么用?Java ParserUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParserUtils类属于org.apache.jasper.xmlparser包,在下文中一共展示了ParserUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUriFromTld
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
private String getUriFromTld(String resourcePath, InputStream in)
throws JasperException
{
// Parse the tag library descriptor at the specified resource path
TreeNode tld = new ParserUtils().parseXMLDocument(resourcePath, in);
TreeNode uri = tld.findChild("uri");
if (uri != null) {
String body = uri.getBody();
if (body != null)
return body;
}
return null;
}
示例2: tldScanStream
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
private void tldScanStream(String resourcePath, String entryName, InputStream stream) throws IOException {
try {
// Parse the tag library descriptor at the specified resource path
String uri = null;
boolean validate = Boolean.parseBoolean(ctxt.getInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM));
String blockExternalString = ctxt.getInitParameter(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
boolean blockExternal;
if (blockExternalString == null) {
blockExternal = true;
} else {
blockExternal = Boolean.parseBoolean(blockExternalString);
}
ParserUtils pu = new ParserUtils(validate, blockExternal);
TreeNode tld = pu.parseXMLDocument(resourcePath, stream);
TreeNode uriNode = tld.findChild("uri");
if (uriNode != null) {
String body = uriNode.getBody();
if (body != null)
uri = body;
}
// Add implicit map entry only if its uri is not already
// present in the map
if (uri != null && mappings.get(uri) == null) {
TldLocation location;
if (entryName == null) {
location = new TldLocation(resourcePath);
} else {
location = new TldLocation(entryName, resourcePath);
}
mappings.put(uri, location);
}
} catch (JasperException e) {
// Hack - makes exception handling simpler
throw new IOException(e);
}
}
示例3: tldScanStream
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
private void tldScanStream(String resourcePath, String entryName,
InputStream stream) throws IOException {
try {
// Parse the tag library descriptor at the specified resource path
String uri = null;
TreeNode tld =
new ParserUtils().parseXMLDocument(resourcePath, stream);
TreeNode uriNode = tld.findChild("uri");
if (uriNode != null) {
String body = uriNode.getBody();
if (body != null)
uri = body;
}
// Add implicit map entry only if its uri is not already
// present in the map
if (uri != null && mappings.get(uri) == null) {
TldLocation location;
if (entryName == null) {
location = new TldLocation(resourcePath);
} else {
location = new TldLocation(entryName, resourcePath);
}
mappings.put(uri, location);
}
} catch (JasperException e) {
// Hack - makes exception handling simpler
throw new IOException(e);
}
}
示例4: tldScanWebXml
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
private void tldScanWebXml() throws Exception {
WebXml webXml = null;
try {
webXml = new WebXml(ctxt);
if (webXml.getInputSource() == null) {
return;
}
boolean validate = Boolean.parseBoolean(
ctxt.getInitParameter(
Constants.XML_VALIDATION_INIT_PARAM));
String blockExternalString = ctxt.getInitParameter(
Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
boolean blockExternal;
if (blockExternalString == null) {
blockExternal = true;
} else {
blockExternal = Boolean.parseBoolean(blockExternalString);
}
// Parse the web application deployment descriptor
ParserUtils pu = new ParserUtils(validate, blockExternal);
TreeNode webtld = null;
webtld = pu.parseXMLDocument(webXml.getSystemId(),
webXml.getInputSource());
// Allow taglib to be an element of the root or jsp-config (JSP2.0)
TreeNode jspConfig = webtld.findChild("jsp-config");
if (jspConfig != null) {
webtld = jspConfig;
}
Iterator<TreeNode> taglibs = webtld.findChildren("taglib");
while (taglibs.hasNext()) {
// Parse the next <taglib> element
TreeNode taglib = taglibs.next();
String tagUri = null;
String tagLoc = null;
TreeNode child = taglib.findChild("taglib-uri");
if (child != null)
tagUri = child.getBody();
child = taglib.findChild("taglib-location");
if (child != null)
tagLoc = child.getBody();
// Save this location if appropriate
if (tagLoc == null)
continue;
if (uriType(tagLoc) == NOROOT_REL_URI)
tagLoc = "/WEB-INF/" + tagLoc;
TldLocation location;
if (tagLoc.endsWith(JAR_EXT)) {
location = new TldLocation("META-INF/taglib.tld", ctxt.getResource(tagLoc).toString());
} else {
location = new TldLocation(tagLoc);
}
mappings.put(tagUri, location);
}
} finally {
if (webXml != null) {
webXml.close();
}
}
}
示例5: tldScanStream
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
private void tldScanStream(String resourcePath, String entryName,
InputStream stream) throws IOException {
try {
// Parse the tag library descriptor at the specified resource path
String uri = null;
boolean validate = Boolean.parseBoolean(
ctxt.getInitParameter(
Constants.XML_VALIDATION_TLD_INIT_PARAM));
String blockExternalString = ctxt.getInitParameter(
Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
boolean blockExternal;
if (blockExternalString == null) {
blockExternal = true;
} else {
blockExternal = Boolean.parseBoolean(blockExternalString);
}
ParserUtils pu = new ParserUtils(validate, blockExternal);
TreeNode tld = pu.parseXMLDocument(resourcePath, stream);
TreeNode uriNode = tld.findChild("uri");
if (uriNode != null) {
String body = uriNode.getBody();
if (body != null)
uri = body;
}
// Add implicit map entry only if its uri is not already
// present in the map
if (uri != null && mappings.get(uri) == null) {
TldLocation location;
if (entryName == null) {
location = new TldLocation(resourcePath);
} else {
location = new TldLocation(entryName, resourcePath);
}
mappings.put(uri, location);
}
} catch (JasperException e) {
// Hack - makes exception handling simpler
throw new IOException(e);
}
}
示例6: tldScanWebXml
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
private void tldScanWebXml() throws Exception {
WebXml webXml = null;
try {
webXml = new WebXml(ctxt);
if (webXml.getInputSource() == null) {
return;
}
boolean validate = Boolean.parseBoolean(ctxt.getInitParameter(Constants.XML_VALIDATION_INIT_PARAM));
String blockExternalString = ctxt.getInitParameter(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
boolean blockExternal;
if (blockExternalString == null) {
blockExternal = true;
} else {
blockExternal = Boolean.parseBoolean(blockExternalString);
}
// Parse the web application deployment descriptor
ParserUtils pu = new ParserUtils(validate, blockExternal);
TreeNode webtld = null;
webtld = pu.parseXMLDocument(webXml.getSystemId(), webXml.getInputSource());
// Allow taglib to be an element of the root or jsp-config (JSP2.0)
TreeNode jspConfig = webtld.findChild("jsp-config");
if (jspConfig != null) {
webtld = jspConfig;
}
Iterator<TreeNode> taglibs = webtld.findChildren("taglib");
while (taglibs.hasNext()) {
// Parse the next <taglib> element
TreeNode taglib = taglibs.next();
String tagUri = null;
String tagLoc = null;
TreeNode child = taglib.findChild("taglib-uri");
if (child != null)
tagUri = child.getBody();
child = taglib.findChild("taglib-location");
if (child != null)
tagLoc = child.getBody();
// Save this location if appropriate
if (tagLoc == null)
continue;
if (uriType(tagLoc) == NOROOT_REL_URI)
tagLoc = "/WEB-INF/" + tagLoc;
TldLocation location;
if (tagLoc.endsWith(JAR_EXT)) {
location = new TldLocation("META-INF/taglib.tld", ctxt.getResource(tagLoc).toString());
} else {
location = new TldLocation(tagLoc);
}
mappings.put(tagUri, location);
}
} finally {
if (webXml != null) {
webXml.close();
}
}
}
示例7: processWebDotXml
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
private void processWebDotXml() throws Exception {
InputStream is = null;
try {
// Acquire input stream to web application deployment descriptor
String altDDName = (String)ctxt.getAttribute(Constants.ALT_DD_ATTR);
URL uri = null;
if (altDDName != null) {
try {
uri = new URL(FILE_PROTOCOL+altDDName.replace('\\', '/'));
} catch (MalformedURLException e) {
if (logger.isWarnEnabled()) {
logger.warn(Localizer.getMessage(
"jsp.error.internal.filenotfound",
altDDName));
}
}
} else {
uri = ctxt.getResource(WEB_XML);
if (uri == null && logger.isWarnEnabled()) {
logger.warn(Localizer.getMessage(
"jsp.error.internal.filenotfound",
WEB_XML));
}
}
if (uri == null) {
return;
}
is = uri.openStream();
InputSource ip = new InputSource(is);
ip.setSystemId(uri.toExternalForm());
// Parse the web application deployment descriptor
TreeNode webtld = null;
// altDDName is the absolute path of the DD
if (altDDName != null) {
webtld = new ParserUtils().parseXMLDocument(altDDName, ip);
} else {
webtld = new ParserUtils().parseXMLDocument(WEB_XML, ip);
}
// Allow taglib to be an element of the root or jsp-config (JSP2.0)
TreeNode jspConfig = webtld.findChild("jsp-config");
if (jspConfig != null) {
webtld = jspConfig;
}
Iterator<?> taglibs = webtld.findChildren("taglib");
while (taglibs.hasNext()) {
// Parse the next <taglib> element
TreeNode taglib = (TreeNode) taglibs.next();
String tagUri = null;
String tagLoc = null;
TreeNode child = taglib.findChild("taglib-uri");
if (child != null)
tagUri = child.getBody();
child = taglib.findChild("taglib-location");
if (child != null)
tagLoc = child.getBody();
// Save this location if appropriate
if (tagLoc == null)
continue;
if (uriType(tagLoc) == NOROOT_REL_URI)
tagLoc = "/WEB-INF/" + tagLoc;
String tagLoc2 = null;
if (tagLoc.endsWith(JAR_FILE_SUFFIX)) {
tagLoc = ctxt.getResource(tagLoc).toString();
tagLoc2 = "META-INF/taglib.tld";
}
mappings.put(tagUri, new String[] { tagLoc, tagLoc2 });
}
} finally {
if (is != null) {
try {
is.close();
} catch (Throwable t) {}
}
}
}
示例8: processPluginWebDotXml
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
private void processPluginWebDotXml(PluginContext ctx) throws Exception{
InputStream is = null;
try {
URL urlDefault = ctx.findLocalResource("WEB-INF/web.xml");
if (urlDefault == null) {
return;
}
is = urlDefault.openStream();
InputSource ip = new InputSource(is);
ip.setSystemId(urlDefault.toExternalForm());
// Parse the web application deployment descriptor
TreeNode webtld = null;
webtld = new ParserUtils().parseXMLDocument(WEB_XML, ip);
// Allow taglib to be an element of the root or jsp-config (JSP2.0)
TreeNode jspConfig = webtld.findChild("jsp-config");
if (jspConfig != null) {
webtld = jspConfig;
}
Iterator<?> taglibs = webtld.findChildren("taglib");
while (taglibs.hasNext()) {
// Parse the next <taglib> element
TreeNode taglib = (TreeNode) taglibs.next();
String tagUri = null;
String tagLoc = null;
TreeNode child = taglib.findChild("taglib-uri");
if (child != null)
tagUri = child.getBody();
child = taglib.findChild("taglib-location");
if (child != null)
tagLoc = child.getBody();
String resourcePath ="/"+ctx.getName()+tagLoc;
Map<String,String[]> tldMapping= (Map<String,String[]>)ctx.getAttribute("tld-mapping");
tldMapping.put(tagUri, new String[] {resourcePath, tagLoc});
if(logger.isDebugEnabled()){
logger.debug("完成解析组件"+ctx.getName()+"web.xml中的tld配置");
}
}
} finally {
if (is != null) {
try {
is.close();
} catch (Throwable t) {}
}
}
}
示例9: setSchemaResourcePrefix
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
/**
* Sets the path prefix for .xsd resources
*/
public static void setSchemaResourcePrefix(String prefix) {
ParserUtils.setSchemaResourcePrefix(prefix);
}
示例10: setDtdResourcePrefix
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
/**
* Sets the path prefix for .dtd resources
*/
public static void setDtdResourcePrefix(String prefix) {
ParserUtils.setDtdResourcePrefix(prefix);
}
示例11: scanTld
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
/**
* Scan the given TLD for uri and listeners elements.
*
* @param resourcePath the resource path for the jar file or the tld file.
* @param entryName If the resource path is a jar file, then the name of
* the tld file in the jar, else should be null.
* @param stream The input stream for the tld
* @return The TldInfo for this tld
*/
private TldInfo scanTld(String resourcePath, String entryName,
InputStream stream)
throws JasperException {
try {
// Parse the tag library descriptor at the specified resource path
TreeNode tld = new ParserUtils().parseXMLDocument(
resourcePath, stream, isValidationEnabled);
String uri = null;
TreeNode uriNode = tld.findChild("uri");
if (uriNode != null) {
uri = uriNode.getBody();
}
ArrayList<String> listeners = new ArrayList<String>();
Iterator<TreeNode>listenerNodes = tld.findChildren("listener");
while (listenerNodes.hasNext()) {
TreeNode listener = listenerNodes.next();
TreeNode listenerClass = listener.findChild("listener-class");
if (listenerClass != null) {
String listenerClassName = listenerClass.getBody();
if (listenerClassName != null) {
listeners.add(listenerClassName);
}
}
}
return new TldInfo(uri, entryName,
listeners.toArray(new String[listeners.size()]));
} finally {
if (stream != null) {
try {
stream.close();
} catch (Throwable t) {
// do nothing
}
}
}
}
示例12: parseImplicitTld
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
/**
* Parses the JSP version and tlib-version from the implicit.tld at the
* given path.
*/
private void parseImplicitTld(JspCompilationContext ctxt, String path)
throws JasperException {
InputStream is = null;
TreeNode tld = null;
try {
URL uri = ctxt.getResource(path);
if (uri == null) {
// no implicit.tld
return;
}
is = uri.openStream();
/* SJSAS 6384538
tld = new ParserUtils().parseXMLDocument(IMPLICIT_TLD, is);
*/
// START SJSAS 6384538
tld = new ParserUtils().parseXMLDocument(
IMPLICIT_TLD, is, ctxt.getOptions().isValidationEnabled());
// END SJSAS 6384538
} catch (Exception ex) {
throw new JasperException(ex);
} finally {
if (is != null) {
try {
is.close();
} catch (Throwable t) {}
}
}
this.jspversion = tld.findAttribute("version");
Iterator list = tld.findChildren();
while (list.hasNext()) {
TreeNode element = (TreeNode) list.next();
String tname = element.getName();
if ("tlibversion".equals(tname)
|| "tlib-version".equals(tname)) {
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)) {
err.jspError("jsp.error.implicitTld.additionalElements",
path, tname);
}
}
// JSP version in implicit.tld must be 2.0 or greater
Double jspVersionDouble = Double.valueOf(this.jspversion);
if (Double.compare(jspVersionDouble, Constants.JSP_VERSION_2_0) < 0) {
err.jspError("jsp.error.implicitTld.jspVersion", path,
this.jspversion);
}
}
示例13: init
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
private void init(ErrorDispatcher err) throws JasperException {
if (initialized)
return;
InputStream is = ctxt.getResourceAsStream(TAG_PLUGINS_XML);
if (is == null)
return;
TreeNode root = (new ParserUtils()).parseXMLDocument(TAG_PLUGINS_XML,
is);
if (root == null) {
return;
}
if (!TAG_PLUGINS_ROOT_ELEM.equals(root.getName())) {
err.jspError("jsp.error.plugin.wrongRootElement", TAG_PLUGINS_XML,
TAG_PLUGINS_ROOT_ELEM);
}
tagPlugins = new HashMap<String, TagPlugin>();
Iterator pluginList = root.findChildren("tag-plugin");
while (pluginList.hasNext()) {
TreeNode pluginNode = (TreeNode) pluginList.next();
TreeNode tagClassNode = pluginNode.findChild("tag-class");
if (tagClassNode == null) {
// Error
return;
}
String tagClass = tagClassNode.getBody().trim();
TreeNode pluginClassNode = pluginNode.findChild("plugin-class");
if (pluginClassNode == null) {
// Error
return;
}
String pluginClassStr = pluginClassNode.getBody();
TagPlugin tagPlugin = null;
try {
Class<? extends TagPlugin> pluginClass =
Class.forName(pluginClassStr).asSubclass(TagPlugin.class);
tagPlugin = pluginClass.newInstance();
} catch (Exception e) {
throw new JasperException(e);
}
if (tagPlugin == null) {
return;
}
tagPlugins.put(tagClass, tagPlugin);
}
initialized = true;
}
示例14: scanTld
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
/**
* Scan the given TLD for uri and listeners elements.
*
* @param resourcePath the resource path for the jar file or the tld file.
* @param entryName If the resource path is a jar file, then the name of
* the tld file in the jar, else should be null.
* @param stream The input stream for the tld
* @return The TldInfo for this tld
*/
private TldInfo scanTld(String resourcePath, String entryName,
InputStream stream)
throws JasperException {
try {
// Parse the tag library descriptor at the specified resource path
TreeNode tld = new ParserUtils(blockExternal).parseXMLDocument(
resourcePath, stream, isValidationEnabled);
String uri = null;
TreeNode uriNode = tld.findChild("uri");
if (uriNode != null) {
uri = uriNode.getBody();
}
ArrayList<String> listeners = new ArrayList<String>();
Iterator<TreeNode>listenerNodes = tld.findChildren("listener");
while (listenerNodes.hasNext()) {
TreeNode listener = listenerNodes.next();
TreeNode listenerClass = listener.findChild("listener-class");
if (listenerClass != null) {
String listenerClassName = listenerClass.getBody();
if (listenerClassName != null) {
listeners.add(listenerClassName);
}
}
}
return new TldInfo(uri, entryName,
listeners.toArray(new String[listeners.size()]));
} finally {
if (stream != null) {
try {
stream.close();
} catch (Throwable t) {
// do nothing
}
}
}
}
示例15: parseImplicitTld
import org.apache.jasper.xmlparser.ParserUtils; //导入依赖的package包/类
/**
* Parses the JSP version and tlib-version from the implicit.tld at the
* given path.
*/
private void parseImplicitTld(JspCompilationContext ctxt, String path)
throws JasperException {
InputStream is = null;
TreeNode tld = null;
try {
URL uri = ctxt.getResource(path);
if (uri == null) {
// no implicit.tld
return;
}
is = uri.openStream();
/* SJSAS 6384538
tld = new ParserUtils().parseXMLDocument(IMPLICIT_TLD, is);
*/
// START SJSAS 6384538
boolean blockExternal = Boolean.parseBoolean(ctxt.getServletContext()
.getInitParameter(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM));
tld = new ParserUtils(blockExternal).parseXMLDocument(
IMPLICIT_TLD, is, ctxt.getOptions().isValidationEnabled());
// END SJSAS 6384538
} catch (Exception ex) {
throw new JasperException(ex);
} finally {
if (is != null) {
try {
is.close();
} catch (Throwable t) {}
}
}
this.jspversion = tld.findAttribute("version");
Iterator list = tld.findChildren();
while (list.hasNext()) {
TreeNode element = (TreeNode) list.next();
String tname = element.getName();
if ("tlibversion".equals(tname)
|| "tlib-version".equals(tname)) {
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)) {
err.jspError("jsp.error.implicitTld.additionalElements",
path, tname);
}
}
// JSP version in implicit.tld must be 2.0 or greater
Double jspVersionDouble = Double.valueOf(this.jspversion);
if (Double.compare(jspVersionDouble, Constants.JSP_VERSION_2_0) < 0) {
err.jspError("jsp.error.implicitTld.jspVersion", path,
this.jspversion);
}
}