org.sape.carbon.core.config.format.jdom
Class JDOMConfigurationFactory

java.lang.Object
  |
  +--org.sape.carbon.core.config.format.jdom.JDOMConfigurationFactory
All Implemented Interfaces:
ConfigurationDataFormatService

public class JDOMConfigurationFactory
extends Object
implements ConfigurationDataFormatService

This factory implementation constructs the appropriate Configuration implementation, through the Dynamic Proxy facility of the JDK, for the particular Configuration interface requested.

Copyright 2002 Sapient

Since:
carbon 1.0
Version:
$Revision: 1.21 $($Author: dvoet $ / $Date: 2003/05/05 21:21:17 $)
Author:
Greg Hinkle, January 2002

Field Summary
private  org.apache.commons.logging.Log log
          Provides a handle to Apache-commons logger
private static String SCHEMA_URI
          Name of the feature URI to turn on schema validation in xerces.
private static String XERCES_SAX_PARSER
          Name of the xerces sax parser used to do schema validation.
 
Constructor Summary
JDOMConfigurationFactory()
           
 
Method Summary
protected  boolean containsDtd(org.jdom.Document document)
          Checks if the given JDOM Document contains a DTD for validation against.
protected  boolean containsSchema(org.jdom.Document document)
          Checks if the given JDOM Document contains a Schema for validation against.
protected  boolean containsValidatingDocument(org.jdom.Document document)
          Checks if the given JDOM Document contains a document for validation against.
protected  String convertStreamToString(String name, InputStream in)
          Converts a given input stream into a String.
protected static String getSaxParserClassName()
          Returns a string representation of the parser in the system or null if an error occurs.
 org.jdom.Document readConfigurationStreamToData(String name, InputStream in)
          Loads a org.jdom.Document object from the given InputStream.
 void writeConfigurationStreamToData(org.jdom.Document document, OutputStream out)
          Stores the raw version of the provided org.jdom.Document object in the format that this format service implementation understands.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.apache.commons.logging.Log log
Provides a handle to Apache-commons logger


SCHEMA_URI

private static final String SCHEMA_URI
Name of the feature URI to turn on schema validation in xerces.

See Also:
Constant Field Values

XERCES_SAX_PARSER

private static final String XERCES_SAX_PARSER
Name of the xerces sax parser used to do schema validation.

See Also:
Constant Field Values
Constructor Detail

JDOMConfigurationFactory

public JDOMConfigurationFactory()
Method Detail

readConfigurationStreamToData

public org.jdom.Document readConfigurationStreamToData(String name,
                                                       InputStream in)
                                                throws ConfigurationFormatException

Loads a org.jdom.Document object from the given InputStream. This node object will represent the full object-graph depiction of a live configuration.

Specified by:
readConfigurationStreamToData in interface ConfigurationDataFormatService
Parameters:
name - The name of the configuration node
in - the InputStream from which the configuration will be read
Returns:
The Document object representing a live object graph of the data from the input stream
Throws:
ConfigurationFormatException - when there is a formatting error with the input stream

containsValidatingDocument

protected boolean containsValidatingDocument(org.jdom.Document document)
Checks if the given JDOM Document contains a document for validation against. This can be a inline/external DTD or a Schema.

Parameters:
document - the document to check against
Returns:
if the document has a validation document associated

containsDtd

protected boolean containsDtd(org.jdom.Document document)
Checks if the given JDOM Document contains a DTD for validation against.

Parameters:
document - the document to check against
Returns:
if the document has a DTD associated

containsSchema

protected boolean containsSchema(org.jdom.Document document)
Checks if the given JDOM Document contains a Schema for validation against.

Parameters:
document - the document to check against
Returns:
if the document has a Schema associated

convertStreamToString

protected String convertStreamToString(String name,
                                       InputStream in)
                                throws ConfigurationFormatException
Converts a given input stream into a String.

Parameters:
name - the name of the input string to convert. Used for logging.
in - the input stream to convert
Returns:
a string representation of the InputStream
Throws:
ConfigurationFormatException - indicates an error converting the input stream into a string. Generally used to wrap an IOException

getSaxParserClassName

protected static String getSaxParserClassName()
Returns a string representation of the parser in the system or null if an error occurs.

Returns:
name of the system sax parser or null for an error

writeConfigurationStreamToData

public void writeConfigurationStreamToData(org.jdom.Document document,
                                           OutputStream out)
                                    throws ConfigurationFormatException

Stores the raw version of the provided org.jdom.Document object in the format that this format service implementation understands. The format of this implementation is strict XML.

Specified by:
writeConfigurationStreamToData in interface ConfigurationDataFormatService
Parameters:
out - The output stream to which the raw configuration data should be written
document - the document to output
Throws:
ConfigurationFormatException - When unable to write a node's raw format to the output stream


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.