Class DefaultConfigurationSerializer
java.lang.Object
org.apache.avalon.framework.configuration.DefaultConfigurationSerializer
A ConfigurationSerializer serializes configurations via SAX2 compliant parser.
- Version:
- CVS $Revision: 1.26 $ $Date: 2004/02/11 14:34:25 $
- Author:
- Avalon Development Team
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ContentHandler
createContentHandler
(Result result) Create a ContentHandler for an OutputStreamprotected SAXTransformerFactory
Get the SAXTransformerFactory so we can get a serializer without being tied to one vendor.void
serialize
(OutputStream outputStream, Configuration source) Serialize the configuration object to an output stream.void
serialize
(String uri, Configuration source) Serialize the configuration object to an output stream derived from an URI.serialize
(Configuration source) Serialize the configuration object to a stringvoid
serialize
(ContentHandler handler, Configuration source) Serialize the configuration to a ContentHandlerprotected void
serializeElement
(ContentHandler handler, NamespaceSupport namespaceSupport, Configuration element) Serialize each Configuration element.void
serializeToFile
(File file, Configuration source) Serialize the configuration object to a file using a File object.void
serializeToFile
(String filename, Configuration source) Serialize the configuration object to a file using a filename.void
setIndent
(boolean indent) Sets the Serializer's use of indentation.
-
Constructor Details
-
DefaultConfigurationSerializer
public DefaultConfigurationSerializer()
-
-
Method Details
-
setIndent
public void setIndent(boolean indent) Sets the Serializer's use of indentation. This will cause linefeeds to be added after each element, but it does not add any indentation via spaces.- Parameters:
indent
- aboolean
value
-
createContentHandler
Create a ContentHandler for an OutputStream- Parameters:
result
- the result- Returns:
- contenthandler that goes to specified OutputStream
-
getTransformerFactory
Get the SAXTransformerFactory so we can get a serializer without being tied to one vendor.- Returns:
- a
SAXTransformerFactory
value
-
serialize
public void serialize(ContentHandler handler, Configuration source) throws SAXException, ConfigurationException Serialize the configuration to a ContentHandler- Parameters:
handler
- aContentHandler
to serialize tosource
- aConfiguration
value- Throws:
SAXException
- if an error occursConfigurationException
- if an error occurs
-
serializeElement
protected void serializeElement(ContentHandler handler, NamespaceSupport namespaceSupport, Configuration element) throws SAXException, ConfigurationException Serialize each Configuration element. This method is called recursively.- Parameters:
handler
- aContentHandler
to usenamespaceSupport
- aNamespaceSupport
to useelement
- aConfiguration
value- Throws:
SAXException
- if an error occursConfigurationException
- if an error occurs
-
serializeToFile
public void serializeToFile(String filename, Configuration source) throws SAXException, IOException, ConfigurationException Serialize the configuration object to a file using a filename.- Parameters:
filename
- aString
valuesource
- aConfiguration
value- Throws:
SAXException
- if an error occursIOException
- if an error occursConfigurationException
- if an error occurs
-
serializeToFile
public void serializeToFile(File file, Configuration source) throws SAXException, IOException, ConfigurationException Serialize the configuration object to a file using a File object.- Parameters:
file
- aFile
valuesource
- aConfiguration
value- Throws:
SAXException
- if an error occursIOException
- if an error occursConfigurationException
- if an error occurs
-
serialize
public void serialize(OutputStream outputStream, Configuration source) throws SAXException, IOException, ConfigurationException Serialize the configuration object to an output stream.- Parameters:
outputStream
- anOutputStream
valuesource
- aConfiguration
value- Throws:
SAXException
- if an error occursIOException
- if an error occursConfigurationException
- if an error occurs
-
serialize
public void serialize(String uri, Configuration source) throws SAXException, IOException, ConfigurationException Serialize the configuration object to an output stream derived from an URI. The URI must be resolveable by thejava.net.URL
object.- Parameters:
uri
- aString
valuesource
- aConfiguration
value- Throws:
SAXException
- if an error occursIOException
- if an error occursConfigurationException
- if an error occurs
-
serialize
Serialize the configuration object to a string- Parameters:
source
- aConfiguration
value- Returns:
- configuration serialized as a string.
- Throws:
SAXException
- if an error occursConfigurationException
- if an error occurs
-