Package gov.aps.jca.configuration
Class DefaultConfigurationSerializer
- java.lang.Object
-
- gov.aps.jca.configuration.DefaultConfigurationSerializer
-
public class DefaultConfigurationSerializer extends Object
A ConfigurationSerializer serializes configurations via SAX2 compliant parser.- Version:
- 1.0
- Author:
- Berin Loritsch, Peter Royal
-
-
Constructor Summary
Constructors Constructor Description DefaultConfigurationSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ContentHandlercreateContentHandler(Result result)Create a ContentHandler for an OutputStreamprotected SAXTransformerFactorygetTransformerFactory()Get the SAXTransformerFactory so we can get a serializer without being tied to one vendor.Stringserialize(Configuration source)Serialize the configuration object to a stringvoidserialize(OutputStream outputStream, Configuration source)Serialize the configuration object to an output stream.voidserialize(String uri, Configuration source)Serialize the configuration object to an output stream derived from an URI.voidserialize(ContentHandler handler, Configuration source)Serialize the configuration to a ContentHandlerprotected voidserializeElement(ContentHandler handler, NamespaceSupport namespaceSupport, Configuration element)Serialize each Configuration element.voidserializeToFile(File file, Configuration source)Serialize the configuration object to a file using a File object.voidserializeToFile(String filename, Configuration source)Serialize the configuration object to a file using a filename.voidsetIndent(boolean indent)Sets the Serializer's use of indentation.
-
-
-
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- abooleanvalue
-
createContentHandler
protected ContentHandler createContentHandler(Result result)
Create a ContentHandler for an OutputStream- Parameters:
result- anOutputStreamvalue- Returns:
- contenthandler that goes to specified OutputStream
-
getTransformerFactory
protected SAXTransformerFactory getTransformerFactory()
Get the SAXTransformerFactory so we can get a serializer without being tied to one vendor.- Returns:
- a
SAXTransformerFactoryvalue
-
serialize
public void serialize(ContentHandler handler, Configuration source) throws SAXException, ConfigurationException
Serialize the configuration to a ContentHandler- Parameters:
handler- aContentHandlerto serialize tosource- aConfigurationvalue- 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- aContentHandlerto usenamespaceSupport- aNamespaceSupportto useelement- aConfigurationvalue- 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- aStringvaluesource- aConfigurationvalue- 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- aFilevaluesource- aConfigurationvalue- 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- anOutputStreamvaluesource- aConfigurationvalue- 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.URLobject.- Parameters:
uri- aStringvaluesource- aConfigurationvalue- Throws:
SAXException- if an error occursIOException- if an error occursConfigurationException- if an error occurs
-
serialize
public String serialize(Configuration source) throws SAXException, ConfigurationException
Serialize the configuration object to a string- Parameters:
source- aConfigurationvalue- Returns:
- configuration serialized as a string.
- Throws:
SAXException- if an error occursConfigurationException- if an error occurs
-
-