org.apache.avalon.framework.configuration
Class DefaultConfigurationSerializer

java.lang.Object
  |
  +--org.apache.avalon.framework.configuration.DefaultConfigurationSerializer

public class DefaultConfigurationSerializer
extends java.lang.Object

A ConfigurationSerializer serializes configurations via SAX2 compliant parser.

Version:
1.0
Author:
Berin Loritsch

Constructor Summary
DefaultConfigurationSerializer()
          Build a ConfigurationSerializer
 
Method Summary
protected  javax.xml.transform.sax.SAXTransformerFactory getTransformerFactory()
          Get the SAXTransformerFactory so we can get a serializer without being tied to one vendor.
protected  void serialize(Configuration source)
          Start the serialization process.
 void serialize(java.io.OutputStream outputStream, Configuration source)
          Serialize the configuration object to an output stream.
 void serialize(java.lang.String uri, Configuration source)
          Serialize the configuration object to an output stream derived from an URI.
protected  void serializeElement(Configuration element)
          Serialize each Configuration element.
 void serializeToFile(java.io.File file, Configuration source)
          Serialize the configuration object to a file using a File object.
 void serializeToFile(java.lang.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.
protected  void setOutputStream(java.io.OutputStream out)
          Internally set the output strream we will be using.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultConfigurationSerializer

public DefaultConfigurationSerializer()
Build a ConfigurationSerializer
Method Detail

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 - a boolean value

setOutputStream

protected void setOutputStream(java.io.OutputStream out)
Internally set the output strream we will be using.
Parameters:
out - an OutputStream value

getTransformerFactory

protected javax.xml.transform.sax.SAXTransformerFactory getTransformerFactory()
Get the SAXTransformerFactory so we can get a serializer without being tied to one vendor.
Returns:
a SAXTransformerFactory value

serialize

protected void serialize(Configuration source)
                  throws org.xml.sax.SAXException,
                         ConfigurationException
Start the serialization process. The output stream must be set before calling this method.
Parameters:
source - a Configuration value
Throws:
org.xml.sax.SAXException - if an error occurs
ConfigurationException - if an error occurs

serializeElement

protected void serializeElement(Configuration element)
                         throws org.xml.sax.SAXException,
                                ConfigurationException
Serialize each Configuration element. This method is called recursively.
Parameters:
element - a Configuration value
Throws:
org.xml.sax.SAXException - if an error occurs
ConfigurationException - if an error occurs

serializeToFile

public void serializeToFile(java.lang.String filename,
                            Configuration source)
                     throws org.xml.sax.SAXException,
                            java.io.IOException,
                            ConfigurationException
Serialize the configuration object to a file using a filename.
Parameters:
filename - a String value
source - a Configuration value
Throws:
org.xml.sax.SAXException - if an error occurs
java.io.IOException - if an error occurs
ConfigurationException - if an error occurs

serializeToFile

public void serializeToFile(java.io.File file,
                            Configuration source)
                     throws org.xml.sax.SAXException,
                            java.io.IOException,
                            ConfigurationException
Serialize the configuration object to a file using a File object.
Parameters:
file - a File value
source - a Configuration value
Throws:
org.xml.sax.SAXException - if an error occurs
java.io.IOException - if an error occurs
ConfigurationException - if an error occurs

serialize

public void serialize(java.io.OutputStream outputStream,
                      Configuration source)
               throws org.xml.sax.SAXException,
                      java.io.IOException,
                      ConfigurationException
Serialize the configuration object to an output stream.
Parameters:
outputStream - an OutputStream value
source - a Configuration value
Throws:
org.xml.sax.SAXException - if an error occurs
java.io.IOException - if an error occurs
ConfigurationException - if an error occurs

serialize

public void serialize(java.lang.String uri,
                      Configuration source)
               throws org.xml.sax.SAXException,
                      java.io.IOException,
                      ConfigurationException
Serialize the configuration object to an output stream derived from an URI. The URI must be resolveable by the java.net.URL object.
Parameters:
uri - a String value
source - a Configuration value
Throws:
org.xml.sax.SAXException - if an error occurs
java.io.IOException - if an error occurs
ConfigurationException - if an error occurs


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.