📄 taglibraryinfoimpl.java
字号:
Constants.message("jsp.message.copyinguri",
new Object[] { uri, jarFileName },
Logger.DEBUG);
if (relativeURL)
copy(getResourceAsStream(uri),
jarFileName);
else
copy(url.openStream(), jarFileName);
ctxt.addJar(jarFileName);
}
*/ // END NOT COMPILED
boolean tldFound = false;
ZipEntry entry;
while ((entry = zin.getNextEntry()) != null) {
if (entry.getName().equals(TLD)) {
/*******
* This hack is necessary because XML reads until the end
* of an inputstream -- does not use available()
* -- and closes the inputstream when it can't
* read no more.
*/
// BEGIN HACK
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int b;
while (zin.available() != 0) {
b = zin.read();
if (b == -1)
break;
baos.write(b);
}
baos.close();
ByteArrayInputStream bais
= new ByteArrayInputStream(baos.toByteArray());
// END HACK
tldFound = true;
parseTLD(bais);
} else {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int b;
while (zin.available() != 0) {
b = zin.read();
if (b == -1)
break;
baos.write(b);
}
baos.close();
jarEntries.put(entry.getName(), baos.toByteArray());
}
zin.closeEntry();
}
if (!tldFound)
throw new JasperException(Constants.getString("jsp.error.tld_not_found",
new Object[] {
TLD
}
));
} // Take this out (END of if(endsWith("jar")))
}
/** Returns true if the given URI is relative in this web application, false if it is an internet URI.
*/
private boolean isRelativeURI(String uri) {
return (uri.indexOf(':') == -1);
}
private void parseTLD(InputStream in)
throws JasperException
{
tld = JspUtil.parseXMLDoc(in,
Constants.TAGLIB_DTD_RESOURCE,
Constants.TAGLIB_DTD_PUBLIC_ID);
Vector tagVector = new Vector();
NodeList list = tld.getElementsByTagName("taglib");
if (list.getLength() != 1)
throw new JasperException(Constants.getString("jsp.error.more.than.one.taglib"));
Element elem = (Element) list.item(0);
list = elem.getChildNodes();
for(int i = 0; i < list.getLength(); i++) {
Node tmp = list.item(i);
if (! (tmp instanceof Element)) continue;
Element e = (Element) tmp;
String tname = e.getTagName();
if (tname.equals("tlibversion")) {
Text t = (Text) e.getFirstChild();
if (t != null)
this.tlibversion = t.getData().trim();
} else if (tname.equals("jspversion")) {
Text t = (Text) e.getFirstChild();
if (t != null)
this.jspversion = t.getData().trim();
} else if (tname.equals("shortname")) {
Text t = (Text) e.getFirstChild();
if (t != null)
this.shortname = t.getData().trim();
} else if (tname.equals("uri")) {
Text t = (Text) e.getFirstChild();
if (t != null)
this.urn = t.getData().trim();
} else if (tname.equals("info")) {
Text t = (Text) e.getFirstChild();
if (t != null)
this.info = t.getData().trim();
} else if (tname.equals("tag"))
tagVector.addElement(createTagInfo(e));
else
Constants.message("jsp.warning.unknown.element.in.TLD",
new Object[] {
e.getTagName()
},
Logger.WARNING
);
}
this.tags = new TagInfo[tagVector.size()];
tagVector.copyInto (this.tags);
}
private TagInfo createTagInfo(Element elem) throws JasperException {
String name = null, tagclass = null, teiclass = null;
String bodycontent = "JSP"; // Default body content is JSP
String info = null;
Vector attributeVector = new Vector();
NodeList list = elem.getChildNodes();
for(int i = 0; i < list.getLength(); i++) {
Node tmp = list.item(i);
if (! (tmp instanceof Element)) continue;
Element e = (Element) tmp;
String tname = e.getTagName();
if (tname.equals("name")) {
Text t = (Text) e.getFirstChild();
if (t != null)
name = t.getData().trim();
} else if (tname.equals("tagclass")) {
Text t = (Text) e.getFirstChild();
if (t != null)
tagclass = t.getData().trim();
} else if (tname.equals("teiclass")) {
Text t = (Text) e.getFirstChild();
if (t != null)
teiclass = t.getData().trim();
} else if (tname.equals("bodycontent")) {
Text t = (Text) e.getFirstChild();
if (t != null)
bodycontent = t.getData().trim();
} else if (tname.equals("info")) {
Text t = (Text) e.getFirstChild();
if (t != null)
info = t.getData().trim();
} else if (tname.equals("attribute"))
attributeVector.addElement(createAttribute(e));
else
Constants.message("jsp.warning.unknown.element.in.tag",
new Object[] {
e.getTagName()
},
Logger.WARNING
);
}
TagAttributeInfo[] tagAttributeInfo
= new TagAttributeInfo[attributeVector.size()];
attributeVector.copyInto (tagAttributeInfo);
TagExtraInfo tei = null;
if (teiclass != null && !teiclass.equals(""))
try {
Class teiClass = ctxt.getClassLoader().loadClass(teiclass);
tei = (TagExtraInfo) teiClass.newInstance();
} catch (ClassNotFoundException cex) {
Constants.message("jsp.warning.teiclass.is.null",
new Object[] {
teiclass, cex.getMessage()
},
Logger.WARNING
);
} catch (IllegalAccessException iae) {
Constants.message("jsp.warning.teiclass.is.null",
new Object[] {
teiclass, iae.getMessage()
},
Logger.WARNING
);
} catch (InstantiationException ie) {
Constants.message("jsp.warning.teiclass.is.null",
new Object[] {
teiclass, ie.getMessage()
},
Logger.WARNING
);
}
TagInfo taginfo = new TagInfo(name, tagclass, bodycontent,
info, this,
tei,
tagAttributeInfo);
return taginfo;
}
TagAttributeInfo createAttribute(Element elem) {
String name = null;
boolean required = false, rtexprvalue = false, reqTime = false;
String type = null;
NodeList list = elem.getChildNodes();
for(int i = 0; i < list.getLength(); i++) {
Node tmp = list.item(i);
if (! (tmp instanceof Element)) continue;
Element e = (Element) tmp;
String tname = e.getTagName();
if (tname.equals("name")) {
Text t = (Text) e.getFirstChild();
if (t != null)
name = t.getData().trim();
} else if (tname.equals("required")) {
Text t = (Text) e.getFirstChild();
if (t != null) {
required = Boolean.valueOf(t.getData().trim()).booleanValue();
if( t.getData().equalsIgnoreCase("yes") )
required = true;
}
} else if (tname.equals("rtexprvalue")) {
Text t = (Text) e.getFirstChild();
if (t != null) {
rtexprvalue = Boolean.valueOf(t.getData().trim()).booleanValue();
if( t.getData().equalsIgnoreCase("yes") )
rtexprvalue = true;
}
} else if (tname.equals("type")) {
Text t = (Text) e.getFirstChild();
if (t != null)
type = t.getData().trim();
} else
Constants.message("jsp.warning.unknown.element.in.attribute",
new Object[] {
e.getTagName()
},
Logger.WARNING
);
}
// return new TagAttributeInfo(name, required, rtexprvalue, type);
return new TagAttributeInfo(name, required, type, rtexprvalue);
}
static void copy(InputStream in, String fileName)
throws IOException, FileNotFoundException
{
byte[] buf = new byte[1024];
FileOutputStream out = new FileOutputStream(fileName);
int nRead;
while ((nRead = in.read(buf, 0, buf.length)) != -1)
out.write(buf, 0, nRead);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -