org.exolab.castor.util
Class LocalConfiguration

java.lang.Object
  extended by org.exolab.castor.util.Configuration
      extended by org.exolab.castor.util.LocalConfiguration

public final class LocalConfiguration
extends Configuration

Provides default configuration for Castor components from the castor.properties configuration file. All Castor features rely on the central configuration file.

The configuration file is loaded from the Java lib directory, the classpath and the Castor JAR. Properties set in the classpath file takes precedence over properties set in the Java library configuration file and properties set in the Castor JAR, allowing for each customization. All three files are named castor.properties.

For example, to change the parser in use, specify that all documents should be printed with identantion or turn debugging on, create a new configuration file in the current directory, instead of modifying the global one.

Version:
$Revision: 1.10 $ $Date: 2005/03/24 10:45:01 $
Author:
Keith Visco, Assaf Arkin

Nested Class Summary
 
Nested classes/interfaces inherited from class org.exolab.castor.util.Configuration
Configuration.ConfigValues, Configuration.Features, Configuration.Property
 
Field Summary
 
Fields inherited from class org.exolab.castor.util.Configuration
ON_VALUE, TRUE_VALUE
 
Constructor Summary
LocalConfiguration()
          Creates a new instance of LocalConfiguration
 
Method Summary
 boolean debug()
          Returns true if the current configuration has enabled debugging.
static LocalConfiguration getInstance()
          Returns an instance of the LocalConfiguration, if a previous configuration has already been loaded for local resource, it will be returned.
 org.apache.xml.serialize.OutputFormat getOutputFormat()
          Returns the default OutputFormat for use with a Serializer.
 org.xml.sax.Parser getParser()
          Return an XML document parser implementing the feature list specified in the configuration file.
 org.xml.sax.Parser getParser(java.lang.String features)
          Returns an XML document parser implementing the requested set of features.
 NodeType getPrimitiveNodeType()
          Returns the NodeType to use for Java primitives.
 java.util.Properties getProperties()
          Returns the current properties from the configuration file(s).
 RegExpEvaluator getRegExpEvaluator()
          Returns a new instance of the specified Regular Expression Evaluator, or null if no validator was specified
 org.apache.xml.serialize.Serializer getSerializer()
          Returns a default serializer for producing an XML document.
 org.xml.sax.DocumentHandler getSerializer(java.io.OutputStream output)
          Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.
 org.xml.sax.DocumentHandler getSerializer(java.io.Writer output)
          Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.
 XMLNaming getXMLNaming()
          Returns the naming conventions to use for the XML framework
 org.xml.sax.XMLReader getXMLReader()
          Returns an XML document parser implementing the requested set of features.
 org.xml.sax.XMLReader getXMLReader(java.lang.String features)
          Returns an XML document parser implementing the requested set of features.
protected  void load()
          Calls Configuration.getDefault() to load the configuration the first time and then looks for a local configuration to merge in with the defaults.
 void loadProperties(java.lang.String fileOrResourceName)
          Load the configuration will not complain about inability to load configuration file from one of the default directories, but if it cannot find the JAR's configuration file, will throw a run time exception.
 boolean marshallingValidation()
          Returns true if the default configuration specified validation in the marshalling framework.
 boolean strictElements()
          Access to the property specifying whether to apply strictness to elements when unmarshalling.
 
Methods inherited from class org.exolab.castor.util.Configuration
getDefault, getDefaultDebug, getDefaultMarshallingValidation, getDefaultOutputFormat, getDefaultParser, getDefaultParser, getDefaultPrimitiveNodeType, getDefaultProperty, getDefaultRegExpEvaluator, getDefaultSerializer, getDefaultSerializer, getDefaultSerializer, getDefaultStrictElements, getDefaultXMLNaming, getDefaultXMLReader, getDefaultXMLReader, getProperty, loadDefaults, loadProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalConfiguration

public LocalConfiguration()
Creates a new instance of LocalConfiguration

Method Detail

getInstance

public static LocalConfiguration getInstance()
Returns an instance of the LocalConfiguration, if a previous configuration has already been loaded for local resource, it will be returned.

Returns:
the LocalConfiguration

debug

public boolean debug()
Returns true if the current configuration has enabled debugging.

Overrides:
debug in class Configuration
Returns:
true if the current configuration has enabled debugging, otherwise false.
See Also:
Configuration.getDefaultDebug()

strictElements

public boolean strictElements()
Access to the property specifying whether to apply strictness to elements when unmarshalling. Default is true which means that elements appearing in the XML Documnt which cannot be mapped to a class cause a SAXException to be thrown. If set to false, these 'unknown' elements are ignored

Overrides:
strictElements in class Configuration
Returns:
true if element processing should be "strict".
See Also:
Configuration.getDefaultStrictElements()

marshallingValidation

public boolean marshallingValidation()
Returns true if the default configuration specified validation in the marshalling framework.

Overrides:
marshallingValidation in class Configuration
Returns:
true if by default validation should be performed during the marshalling and unmarshalling process, otherwise false.
See Also:
Configuration.getDefaultMarshallingValidation()

getProperties

public java.util.Properties getProperties()
Returns the current properties from the configuration file(s). The Properties returned may be empty, but never null.

Overrides:
getProperties in class Configuration
Returns:
The current set of configuration properties.
See Also:
Configuration.getDefault()

getXMLNaming

public XMLNaming getXMLNaming()
Returns the naming conventions to use for the XML framework

Overrides:
getXMLNaming in class Configuration
Returns:
the naming conventions to use for the XML framework
See Also:
Configuration.getDefaultXMLNaming()

getParser

public org.xml.sax.Parser getParser()
Return an XML document parser implementing the feature list specified in the configuration file.

Overrides:
getParser in class Configuration
Returns:
A suitable XML parser
See Also:
Configuration.getDefaultParser()

getParser

public org.xml.sax.Parser getParser(java.lang.String features)
Returns an XML document parser implementing the requested set of features. The feature list is a comma separated list of features that parser may or may not support. No errors are generated for unsupported features. If the feature list is not null, it overrides the default feature list specified in the configuration file, including validation and Namespaces.

Parameters:
features - The requested feature list, null for the defaults
Returns:
A suitable XML parser

getXMLReader

public org.xml.sax.XMLReader getXMLReader()
Returns an XML document parser implementing the requested set of features. The feature list is a comma separated list of features that parser may or may not support. No errors are generated for unsupported features. If the feature list is not null, it overrides the default feature list specified in the configuration file, including validation and Namespaces.

Overrides:
getXMLReader in class Configuration
Returns:
A suitable XML parser

getXMLReader

public org.xml.sax.XMLReader getXMLReader(java.lang.String features)
Returns an XML document parser implementing the requested set of features. The feature list is a comma separated list of features that parser may or may not support. No errors are generated for unsupported features. If the feature list is not null, it overrides the default feature list specified in the configuration file, including validation and Namespaces.

Returns:
A suitable XML parser

getPrimitiveNodeType

public NodeType getPrimitiveNodeType()
Returns the NodeType to use for Java primitives. A null value will be returned if no NodeType was specified, indicating the default NodeType should be used.

Overrides:
getPrimitiveNodeType in class Configuration
Returns:
the NodeType assigned to Java primitives, or null if no NodeType was specified.
See Also:
Configuration.getDefaultPrimitiveNodeType()

getRegExpEvaluator

public RegExpEvaluator getRegExpEvaluator()
Returns a new instance of the specified Regular Expression Evaluator, or null if no validator was specified

Overrides:
getRegExpEvaluator in class Configuration
Returns:
the regular expression evaluator,
See Also:
Configuration.getDefaultRegExpEvaluator()

getSerializer

public org.apache.xml.serialize.Serializer getSerializer()
Returns a default serializer for producing an XML document. The caller can specify an alternative output format, may reuse this serializer across several streams, and may serialize both DOM and SAX events. If such control is not required, it is recommended to call one of the other two methods.

Specified by:
getSerializer in class Configuration
Returns:
A suitable serializer
See Also:
Configuration.getDefaultSerializer()

getOutputFormat

public org.apache.xml.serialize.OutputFormat getOutputFormat()
Returns the default OutputFormat for use with a Serializer.

Specified by:
getOutputFormat in class Configuration
Returns:
the default OutputFormat
See Also:
Configuration.getDefaultOutputFormat()

getSerializer

public org.xml.sax.DocumentHandler getSerializer(java.io.OutputStream output)
                                          throws java.io.IOException
Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.

Specified by:
getSerializer in class Configuration
Parameters:
output - The output stream
Returns:
A suitable serializer
Throws:
java.io.IOException

getSerializer

public org.xml.sax.DocumentHandler getSerializer(java.io.Writer output)
                                          throws java.io.IOException
Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.

Specified by:
getSerializer in class Configuration
Parameters:
output - The output stream
Returns:
A suitable serializer
Throws:
java.io.IOException

load

protected void load()
Calls Configuration.getDefault() to load the configuration the first time and then looks for a local configuration to merge in with the defaults. Will not complain about inability to load local configuration file from one of the default directories, but if it cannot find the JAR's configuration file, will throw a run time exception.


loadProperties

public void loadProperties(java.lang.String fileOrResourceName)
                    throws java.io.FileNotFoundException
Load the configuration will not complain about inability to load configuration file from one of the default directories, but if it cannot find the JAR's configuration file, will throw a run time exception.

Throws:
java.io.FileNotFoundException


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com