Provides convenience methods for reading and writing web deployment
descriptors.
| Method from org.apache.cactus.integration.ant.deployment.webapp.WebXmlIo Detail: |
public static WebXml newWebXml(WebXmlVersion theVersion) throws ParserConfigurationException {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
DocumentType docType = null;
if (theVersion != null)
{
docType =
builder.getDOMImplementation().createDocumentType("web-app",
theVersion.getPublicId(), theVersion.getSystemId());
}
Document doc = builder.getDOMImplementation().createDocument(
"", "web-app", docType);
return new WebXml(doc);
}
Creates a new empty deployment descriptor. |
public static WebXml parseWebXml(InputStream theInput,
EntityResolver theEntityResolver) throws IOException, SAXException, ParserConfigurationException {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
if (theEntityResolver != null)
{
builder.setEntityResolver(theEntityResolver);
}
else
{
builder.setEntityResolver(new WebXmlEntityResolver());
}
return new WebXml(builder.parse(theInput));
}
Parses a deployment descriptor provided as input stream. |
public static WebXml parseWebXmlFromFile(File theFile,
EntityResolver theEntityResolver) throws IOException, SAXException, ParserConfigurationException {
InputStream in = null;
try
{
in = new FileInputStream(theFile);
return parseWebXml(in, theEntityResolver);
}
finally
{
if (in != null)
{
try
{
in.close();
}
catch (IOException ioe)
{
// we'll pass on the original IO error, so ignore this one
}
}
}
}
Parses a deployment descriptor stored in a regular file. |
public static void writeWebXml(WebXml theWebXml,
File theFile) throws IOException {
writeWebXml(theWebXml, theFile, null, false);
}
Writes the specified document to a file. |
public static void writeWebXml(WebXml theWebXml,
File theFile,
String theEncoding) throws IOException {
writeWebXml(theWebXml, theFile, theEncoding, false);
}
Writes the specified document to a file. |
public static void writeWebXml(WebXml theWebXml,
File theFile,
String theEncoding,
boolean isIndent) throws IOException {
OutputStream out = null;
try
{
out = new FileOutputStream(theFile);
writeWebXml(theWebXml, out, theEncoding, isIndent);
}
finally
{
if (out != null)
{
try
{
out.close();
}
catch (IOException ioe)
{
// we'll pass on the original IO error, so ignore this one
}
}
}
}
Writes the specified document to a file. |
public static void writeWebXml(WebXml theWebXml,
OutputStream theOutput,
String theEncoding,
boolean isIndent) throws IOException {
OutputFormat outputFormat =
new OutputFormat(theWebXml.getDocument());
if (theEncoding != null)
{
outputFormat.setEncoding(theEncoding);
}
outputFormat.setIndenting(isIndent);
outputFormat.setPreserveSpace(false);
XMLSerializer serializer = new XMLSerializer(theOutput, outputFormat);
serializer.serialize(theWebXml.getDocument());
}
Writes the specified document to an output stream. |