Methods Summary |
---|
public void | addInitParam(InitParam initParam)
initParamList.add(initParam);
|
public void | addSecurityRoleRef(SecurityRoleRef securityRoleRef)
securityRoleRefList.add(securityRoleRef);
|
public void | characters(char[] ch, int start, int len)
// Feed this to the correct ContentHandler
Unmarshallable current = getCurrentUNode();
if (current != this) {
current.characters(ch, start, len);
return;
}
String text = new String(ch, start, len);
text = text.trim();
if (zeus_inServletName) {
if (this.servletName == null) {
this.servletName = text;
} else {
this.servletName = new StringBuffer(this.servletName).append(text).toString();
}
return;
}
if (zeus_inDisplayName) {
if (this.displayName == null) {
this.displayName = text;
} else {
this.displayName = new StringBuffer(this.displayName).append(text).toString();
}
return;
}
if (zeus_inDescription) {
if (this.description == null) {
this.description = text;
} else {
this.description = new StringBuffer(this.description).append(text).toString();
}
return;
}
if (zeus_inServletClass) {
if (this.servletClass == null) {
this.servletClass = text;
} else {
this.servletClass = new StringBuffer(this.servletClass).append(text).toString();
}
return;
}
if (zeus_inJspFile) {
if (this.jspFile == null) {
this.jspFile = text;
} else {
this.jspFile = new StringBuffer(this.jspFile).append(text).toString();
}
return;
}
if (zeus_inLoadOnStartup) {
if (this.loadOnStartup == null) {
this.loadOnStartup = text;
} else {
this.loadOnStartup = new StringBuffer(this.loadOnStartup).append(text).toString();
}
return;
}
|
public void | comment(char[] ch, int start, int len)
// Currently no-op
|
public void | endCDATA()
// Currently no-op
|
public void | endDTD()
// Currently no-op
|
public void | endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
Unmarshallable current = getCurrentUNode();
if (current != this) {
current.endElement(namespaceURI, localName, qName);
return;
}
if (localName.equals("servlet-name")) {
this.zeus_inServletName = false;
return;
}
if (localName.equals("display-name")) {
this.zeus_inDisplayName = false;
return;
}
if (localName.equals("description")) {
this.zeus_inDescription = false;
return;
}
if (localName.equals("servlet-class")) {
this.zeus_inServletClass = false;
return;
}
if (localName.equals("jsp-file")) {
this.zeus_inJspFile = false;
return;
}
if (localName.equals("load-on-startup")) {
this.zeus_inLoadOnStartup = false;
return;
}
Unmarshallable parent = getCurrentUNode().getParentUNode();
if (parent != null) {
parent.setCurrentUNode(parent);
}
|
public void | endEntity(java.lang.String name)
// Currently no-op
|
public void | error(org.xml.sax.SAXParseException e)
if ((validate) && (!hasDTD)) {
throw new SAXException("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference.");
}
if (errorHandler != null) {
errorHandler.error(e);
}
|
private java.lang.String | escapeAttributeValue(java.lang.String attributeValue)
String returnValue = attributeValue;
for (int i = 0; i < returnValue.length(); i++) {
char ch = returnValue.charAt(i);
if (ch == '"") {
returnValue = new StringBuffer()
.append(returnValue.substring(0, i))
.append(""")
.append(returnValue.substring(i+1))
.toString();
}
}
return returnValue;
|
private java.lang.String | escapeTextValue(java.lang.String textValue)
String returnValue = textValue;
for (int i = 0; i < returnValue.length(); i++) {
char ch = returnValue.charAt(i);
if (ch == '<") {
returnValue = new StringBuffer()
.append(returnValue.substring(0, i))
.append("<")
.append(returnValue.substring(i+1))
.toString();
} else if (ch == '>") {
returnValue = new StringBuffer()
.append(returnValue.substring(0, i))
.append(">")
.append(returnValue.substring(i+1))
.toString();
}
}
return returnValue;
|
public void | fatalError(org.xml.sax.SAXParseException e)
if ((validate) && (!hasDTD)) {
throw new SAXException("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference.");
}
if (errorHandler != null) {
errorHandler.fatalError(e);
}
|
public Unmarshallable | getCurrentUNode()
return zeus_currentUNode;
|
public java.lang.String | getDescription()
return description;
|
public java.lang.String | getDisplayName()
return displayName;
|
public Icon | getIcon()
return icon;
|
public java.lang.String | getId()
return id;
|
public java.util.List | getInitParamList()
return initParamList;
|
public java.lang.String | getJspFile()
return jspFile;
|
public java.lang.String | getLoadOnStartup()
return loadOnStartup;
|
public Unmarshallable | getParentUNode()
return zeus_parentUNode;
|
public java.util.List | getSecurityRoleRefList()
return securityRoleRefList;
|
public java.lang.String | getServletClass()
return servletClass;
|
public java.lang.String | getServletName()
return servletName;
|
public void | marshal(java.io.File file)
// Delegate to the marshal(Writer) method
marshal(new FileWriter(file));
|
public void | marshal(java.io.OutputStream outputStream)
// Delegate to the marshal(Writer) method
marshal(new OutputStreamWriter(outputStream));
|
public void | marshal(java.io.Writer writer)
// Write out the XML declaration
writer.write("<?xml version=\"1.0\" ");
if (outputEncoding != null) {
writer.write("encoding=\"");
writer.write(outputEncoding);
writer.write("\"?>\n\n");
} else {
writer.write("encoding=\"UTF-8\"?>\n\n");
}
// Handle DOCTYPE declaration
writer.write(docTypeString);
writer.write("\n");
// Now start the recursive writing
writeXMLRepresentation(writer, "");
// Close up
writer.flush();
writer.close();
|
public void | removeInitParam(InitParam initParam)
initParamList.remove(initParam);
|
public void | removeSecurityRoleRef(SecurityRoleRef securityRoleRef)
securityRoleRefList.remove(securityRoleRef);
|
public void | setCurrentUNode(Unmarshallable currentUNode)
this.zeus_currentUNode = currentUNode;
|
public void | setDescription(java.lang.String description)
this.description = description;
zeus_DescriptionSet = true;
|
public void | setDisplayName(java.lang.String displayName)
this.displayName = displayName;
zeus_DisplayNameSet = true;
|
public void | setDocType(java.lang.String name, java.lang.String publicID, java.lang.String systemID)
try {
startDTD(name, publicID, systemID);
} catch (SAXException neverHappens) { }
|
public void | setDocumentLocator(org.xml.sax.Locator locator)
// no-op
|
public static void | setEntityResolver(org.xml.sax.EntityResolver resolver)
This sets a SAX EntityResolver for this unmarshalling process.
entityResolver = resolver;
|
public static void | setErrorHandler(org.xml.sax.ErrorHandler handler)
This sets a SAX ErrorHandler for this unmarshalling process.
errorHandler = handler;
|
public void | setIcon(Icon icon)
this.icon = icon;
|
public void | setId(java.lang.String id)
this.id = id;
zeus_IdSet = true;
|
public void | setInitParamList(java.util.List initParamList)
this.initParamList = initParamList;
|
public void | setJspFile(java.lang.String jspFile)
this.jspFile = jspFile;
zeus_JspFileSet = true;
|
public void | setLoadOnStartup(java.lang.String loadOnStartup)
this.loadOnStartup = loadOnStartup;
zeus_LoadOnStartupSet = true;
|
public void | setOutputEncoding(java.lang.String outputEncoding)
this.outputEncoding = outputEncoding;
|
public void | setParentUNode(Unmarshallable parentUNode)
this.zeus_parentUNode = parentUNode;
|
public void | setSecurityRoleRefList(java.util.List securityRoleRefList)
this.securityRoleRefList = securityRoleRefList;
|
public void | setServletClass(java.lang.String servletClass)
this.servletClass = servletClass;
zeus_ServletClassSet = true;
|
public void | setServletName(java.lang.String servletName)
this.servletName = servletName;
zeus_ServletNameSet = true;
|
public void | setValidating(boolean validate)
this.validate = validate;
|
public void | startCDATA()
// Currently no-op
|
public void | startDTD(java.lang.String name, java.lang.String publicID, java.lang.String systemID)
if ((name == null) || (name.equals(""))) {
docTypeString = "";
return;
}
hasDTD = true;
StringBuffer docTypeSB = new StringBuffer();
boolean hasPublic = false;
docTypeSB.append("<!DOCTYPE ")
.append(name);
if ((publicID != null) && (!publicID.equals(""))) {
docTypeSB.append(" PUBLIC \"")
.append(publicID)
.append("\"");
hasPublic = true;
}
if ((systemID != null) && (!systemID.equals(""))) {
if (!hasPublic) {
docTypeSB.append(" SYSTEM");
}
docTypeSB.append(" \"")
.append(systemID)
.append("\"");
}
docTypeSB.append(">");
docTypeString = docTypeSB.toString();
|
public void | startDocument()
// no-op
|
public void | startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
// Feed this to the correct ContentHandler
Unmarshallable current = getCurrentUNode();
if (current != this) {
current.startElement(namespaceURI, localName, qName, atts);
return;
}
// See if we handle, or we delegate
if ((localName.equals("servlet")) && (!zeus_thisNodeHandled)) {
// Handle ourselves
for (int i=0, len=atts.getLength(); i<len; i++) {
String attName= atts.getLocalName(i);
String attValue = atts.getValue(i);
if (attName.equals("id")) {
setId(attValue);
}
}
zeus_thisNodeHandled = true;
return;
} else {
// Delegate handling
if (localName.equals("icon")) {
IconImpl icon = new IconImpl();
current = getCurrentUNode();
icon.setParentUNode(current);
icon.setCurrentUNode(icon);
this.setCurrentUNode(icon);
icon.startElement(namespaceURI, localName, qName, atts);
// Add this value in
this.icon = icon;
return;
}
if (localName.equals("servlet-name")) {
this.zeus_inServletName = true;
return;
}
if (localName.equals("display-name")) {
this.zeus_inDisplayName = true;
return;
}
if (localName.equals("description")) {
this.zeus_inDescription = true;
return;
}
if (localName.equals("servlet-class")) {
this.zeus_inServletClass = true;
return;
}
if (localName.equals("jsp-file")) {
this.zeus_inJspFile = true;
return;
}
if (localName.equals("init-param")) {
InitParamImpl initParam = new InitParamImpl();
current = getCurrentUNode();
initParam.setParentUNode(current);
initParam.setCurrentUNode(initParam);
this.setCurrentUNode(initParam);
initParam.startElement(namespaceURI, localName, qName, atts);
// Add this value in
initParamList.add(initParam);
return;
}
if (localName.equals("load-on-startup")) {
this.zeus_inLoadOnStartup = true;
return;
}
if (localName.equals("security-role-ref")) {
SecurityRoleRefImpl securityRoleRef = new SecurityRoleRefImpl();
current = getCurrentUNode();
securityRoleRef.setParentUNode(current);
securityRoleRef.setCurrentUNode(securityRoleRef);
this.setCurrentUNode(securityRoleRef);
securityRoleRef.startElement(namespaceURI, localName, qName, atts);
// Add this value in
securityRoleRefList.add(securityRoleRef);
return;
}
}
|
public void | startEntity(java.lang.String name)
// Currently no-op
|
public void | startPrefixMapping(java.lang.String prefix, java.lang.String uri)
namespaceMappings.put(prefix, uri);
|
public static Servlet | unmarshal(java.io.File file)
// Delegate to the unmarshal(Reader) method
return unmarshal(new FileReader(file));
|
public static Servlet | unmarshal(java.io.File file, boolean validate)
// Delegate to the unmarshal(Reader) method
return unmarshal(new FileReader(file), validate);
|
public static Servlet | unmarshal(java.io.InputStream inputStream)
// Delegate to the unmarshal(Reader) method
return unmarshal(new InputStreamReader(inputStream));
|
public static Servlet | unmarshal(java.io.InputStream inputStream, boolean validate)
// Delegate to the unmarshal(Reader) method
return unmarshal(new InputStreamReader(inputStream), validate);
|
public static Servlet | unmarshal(java.io.Reader reader)
// Delegate with default validation value
return unmarshal(reader, false);
|
public static Servlet | unmarshal(java.io.Reader reader, boolean validate)
ServletImpl servlet = new ServletImpl();
servlet.setValidating(validate);
servlet.setCurrentUNode(servlet);
servlet.setParentUNode(null);
// Load the XML parser
XMLReader parser = null;
String parserClass = System.getProperty("org.xml.sax.driver",
"org.apache.xerces.parsers.SAXParser");
try {
parser = XMLReaderFactory.createXMLReader(parserClass);
// Set entity resolver, if needed
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
// Set error handler
parser.setErrorHandler(servlet);
// Register lexical handler
parser.setProperty("http://xml.org/sax/properties/lexical-handler", servlet);
// Register content handler
parser.setContentHandler(servlet);
} catch (SAXException e) {
throw new IOException("Could not load XML parser: " +
e.getMessage());
}
InputSource inputSource = new InputSource(reader);
try {
parser.setFeature("http://xml.org/sax/features/validation", new Boolean(validate).booleanValue());
parser.setFeature("http://xml.org/sax/features/namespaces", true);
parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
parser.parse(inputSource);
} catch (SAXException e) {
throw new IOException("Error parsing XML document: " +
e.getMessage());
}
// Return the resultant object
return servlet;
|
public void | warning(org.xml.sax.SAXParseException e)
if (errorHandler != null) {
errorHandler.warning(e);
}
|
protected void | writeXMLRepresentation(java.io.Writer writer, java.lang.String indent)
writer.write(indent);
writer.write("<servlet");
// Handle namespace mappings (if needed)
for (Iterator i = namespaceMappings.keySet().iterator(); i.hasNext(); ) {
String prefix = (String)i.next();
String uri = (String)namespaceMappings.get(prefix);
writer.write(" xmlns");
if (!prefix.trim().equals("")) {
writer.write(":");
writer.write(prefix);
}
writer.write("=\"");
writer.write(uri);
writer.write("\"\n ");
}
// Handle attributes (if needed)
if (zeus_IdSet) {
writer.write(" id=\"");
writer.write(escapeAttributeValue(id));
writer.write("\"");
}
writer.write(">");
writer.write("\n");
// Handle child elements
if (icon != null) {
((IconImpl)icon).writeXMLRepresentation(writer,
new StringBuffer(indent).append(" ").toString());
}
if (servletName != null) {
writer.write(new StringBuffer(indent).append(" ").toString());
writer.write("<servlet-name>");
writer.write(this.servletName);
writer.write("</servlet-name>\n");
}
if (displayName != null) {
writer.write(new StringBuffer(indent).append(" ").toString());
writer.write("<display-name>");
writer.write(this.displayName);
writer.write("</display-name>\n");
}
if (description != null) {
writer.write(new StringBuffer(indent).append(" ").toString());
writer.write("<description>");
writer.write(this.description);
writer.write("</description>\n");
}
if (servletClass != null) {
writer.write(new StringBuffer(indent).append(" ").toString());
writer.write("<servlet-class>");
writer.write(this.servletClass);
writer.write("</servlet-class>\n");
}
if (jspFile != null) {
writer.write(new StringBuffer(indent).append(" ").toString());
writer.write("<jsp-file>");
writer.write(this.jspFile);
writer.write("</jsp-file>\n");
}
for (Iterator i=initParamList.iterator(); i.hasNext(); ) {
InitParamImpl initParam = (InitParamImpl)i.next();
initParam.writeXMLRepresentation(writer,
new StringBuffer(indent).append(" ").toString());
}
if (loadOnStartup != null) {
writer.write(new StringBuffer(indent).append(" ").toString());
writer.write("<load-on-startup>");
writer.write(this.loadOnStartup);
writer.write("</load-on-startup>\n");
}
for (Iterator i=securityRoleRefList.iterator(); i.hasNext(); ) {
SecurityRoleRefImpl securityRoleRef = (SecurityRoleRefImpl)i.next();
securityRoleRef.writeXMLRepresentation(writer,
new StringBuffer(indent).append(" ").toString());
}
writer.write(indent);
writer.write("</servlet>\n");
|