Package org.codehaus.cargo.module
Class AbstractDescriptorIo
- java.lang.Object
-
- org.codehaus.cargo.module.AbstractDescriptorIo
-
- All Implemented Interfaces:
DescriptorIo
- Direct Known Subclasses:
ApplicationXmlIo,EjbJarXmlIo,IbmEjbJarBndXmiIo,IbmWebBndXmiIo,JBossWebXmlIo,JBossXmlIo,OrionEjbJarXmlIo,OrionWebXmlIo,ResinWebXmlIo,TomcatContextXmlIo,WeblogicEjbJarXmlIo,WeblogicXmlIo,WebXmlIo
public abstract class AbstractDescriptorIo extends Object implements DescriptorIo
Provides convenience methods for reading and writing descriptors.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDescriptorIo(DescriptorType descriptorType)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.jdom2.input.SAXBuildercreateDocumentBuilder()Create a document builder.org.jdom2.input.SAXBuildercreateDocumentBuilder(EntityResolver theEntityResolver)protected EntityResolvergetEntityResolver()Get the default entity resolver for this type.org.jdom2.DocumentparseXml(InputStream input)Parse XML into a document.org.jdom2.DocumentparseXml(InputStream input, EntityResolver resolver)Create a document from the input stream and resolver.static File[]writeAll(J2eeDescriptor descriptor, String dir)Writes the WebXml and its associated vendor descriptors to the specified directory.static voidwriteDescriptor(Descriptor descriptor, File file)Writes the specified document to a file.static voidwriteDescriptor(Descriptor descriptor, File file, Charset encoding)Writes the specified document to a file.static voidwriteDescriptor(Descriptor descriptor, File file, Charset encoding, boolean isIndent)Writes the specified document to a file.static voidwriteDescriptor(Descriptor descriptor, OutputStream out, Charset encoding, boolean isIndent)Writes the specified document to an output stream.
-
-
-
Constructor Detail
-
AbstractDescriptorIo
protected AbstractDescriptorIo(DescriptorType descriptorType)
Constructor.- Parameters:
descriptorType- the descriptor type.
-
-
Method Detail
-
createDocumentBuilder
public org.jdom2.input.SAXBuilder createDocumentBuilder()
Create a document builder.- Specified by:
createDocumentBuilderin interfaceDescriptorIo- Returns:
- new document builder
-
createDocumentBuilder
public org.jdom2.input.SAXBuilder createDocumentBuilder(EntityResolver theEntityResolver)
- Specified by:
createDocumentBuilderin interfaceDescriptorIo- Parameters:
theEntityResolver- entity resolver or null- Returns:
- a new non-validating, non-namespace-aware
DocumentBuilderinstance
-
getEntityResolver
protected EntityResolver getEntityResolver()
Get the default entity resolver for this type.- Returns:
- default resolver, or null if none
-
parseXml
public org.jdom2.Document parseXml(InputStream input) throws org.jdom2.JDOMException, IOException
Description copied from interface:DescriptorIoParse XML into a document.- Specified by:
parseXmlin interfaceDescriptorIo- Parameters:
input- the input stream- Returns:
- JDOM Document
- Throws:
IOException- if problem reading the streamorg.jdom2.JDOMException- if problem parsing the stream
-
parseXml
public org.jdom2.Document parseXml(InputStream input, EntityResolver resolver) throws org.jdom2.JDOMException, IOException
Create a document from the input stream and resolver.- Specified by:
parseXmlin interfaceDescriptorIo- Parameters:
input- the input streamresolver- entity resolver, or null- Returns:
- JDOM Document
- Throws:
IOException- if problem reading the streamorg.jdom2.JDOMException- if problem parsing the stream
-
writeDescriptor
public static void writeDescriptor(Descriptor descriptor, File file) throws IOException
Writes the specified document to a file.- Parameters:
descriptor- The descriptor to serializefile- The file to write to- Throws:
IOException- If an I/O error occurs
-
writeDescriptor
public static void writeDescriptor(Descriptor descriptor, File file, Charset encoding) throws IOException
Writes the specified document to a file.- Parameters:
descriptor- The descriptor to serializefile- The file to write toencoding- The character encoding to use- Throws:
IOException- If an I/O error occurs
-
writeDescriptor
public static void writeDescriptor(Descriptor descriptor, File file, Charset encoding, boolean isIndent) throws IOException
Writes the specified document to a file.- Parameters:
descriptor- The descriptor to serializefile- The file to write toencoding- The character encoding to useisIndent- Whether the written XML should be indented- Throws:
IOException- If an I/O error occurs
-
writeDescriptor
public static void writeDescriptor(Descriptor descriptor, OutputStream out, Charset encoding, boolean isIndent) throws IOException
Writes the specified document to an output stream.- Parameters:
descriptor- The descriptor to serializeout- The output stream to write toencoding- The character encoding to useisIndent- Whether the written XML should be indented- Throws:
IOException- If an I/O error occurs
-
writeAll
public static File[] writeAll(J2eeDescriptor descriptor, String dir) throws IOException
Writes the WebXml and its associated vendor descriptors to the specified directory.- Parameters:
descriptor- The descriptor to serializedir- Directory to store the descriptors in- Returns:
- Array of files for every created file
- Throws:
IOException- if a I/O error occurs
-
-