org.apache.avalon.framework.configuration
Class DefaultConfigurationSerializer

java.lang.Object
  extended byorg.apache.avalon.framework.configuration.DefaultConfigurationSerializer

public class DefaultConfigurationSerializer
extends java.lang.Object

A ConfigurationSerializer serializes configurations via SAX2 compliant parser.

Version:
$Id: DefaultConfigurationSerializer.java 30977 2004-07-30 08:57:54Z niclas $
Author:
Avalon Development Team

Constructor Summary
DefaultConfigurationSerializer()
           
 
Method Summary
protected  org.xml.sax.ContentHandler createContentHandler(javax.xml.transform.Result result)
          Create a ContentHandler for an OutputStream
protected  javax.xml.transform.sax.SAXTransformerFactory getTransformerFactory()
          Get the SAXTransformerFactory so we can get a serializer without being tied to one vendor.
 java.lang.String serialize(Configuration source)
          Serialize the configuration object to a string
 void serialize(org.xml.sax.ContentHandler handler, Configuration source)
          Serialize the configuration to a ContentHandler
 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(org.xml.sax.ContentHandler handler, org.xml.sax.helpers.NamespaceSupport namespaceSupport, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultConfigurationSerializer

public DefaultConfigurationSerializer()
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

createContentHandler

protected org.xml.sax.ContentHandler createContentHandler(javax.xml.transform.Result result)
Create a ContentHandler for an OutputStream

Parameters:
result - the result
Returns:
contenthandler that goes to specified OutputStream

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

public void serialize(org.xml.sax.ContentHandler handler,
                      Configuration source)
               throws org.xml.sax.SAXException,
                      ConfigurationException
Serialize the configuration to a ContentHandler

Parameters:
handler - a ContentHandler to serialize to
source - a Configuration value
Throws:
org.xml.sax.SAXException - if an error occurs
ConfigurationException - if an error occurs

serializeElement

protected void serializeElement(org.xml.sax.ContentHandler handler,
                                org.xml.sax.helpers.NamespaceSupport namespaceSupport,
                                Configuration element)
                         throws org.xml.sax.SAXException,
                                ConfigurationException
Serialize each Configuration element. This method is called recursively.

Parameters:
handler - a ContentHandler to use
namespaceSupport - a NamespaceSupport to use
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

serialize

public java.lang.String serialize(Configuration source)
                           throws org.xml.sax.SAXException,
                                  ConfigurationException
Serialize the configuration object to a string

Parameters:
source - a Configuration value
Returns:
configuration serialized as a string.
Throws:
org.xml.sax.SAXException - if an error occurs
ConfigurationException - if an error occurs


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.