org.exolab.castor.util
Class Configuration

java.lang.Object
  extended byorg.exolab.castor.util.Configuration

public abstract class Configuration
extends java.lang.Object

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.24 $ $Date: 2001/04/05 17:37:55 $
Author:
Keith Visco, Assaf Arkin

Nested Class Summary
static class Configuration.Property
          Names of properties used in the configuration file.
 
Constructor Summary
Configuration()
           
 
Method Summary
static boolean debug()
          Returns true if the default configuration specified debugging.
static java.util.Properties getDefault()
          Returns the default configuration file.
static org.apache.xml.serialize.OutputFormat getOutputFormat()
          Returns the default OutputFormat for use with a Serializer.
static org.xml.sax.Parser getParser()
          Return an XML document parser implementing the feature list specified in the configuration file.
static org.xml.sax.Parser getParser(java.lang.String features)
          Returns an XML document parser implementing the requested set of features.
static NodeType getPrimitiveNodeType()
          Returns the NodeType to use for Java primitives.
static java.lang.String getProperty(java.lang.String name, java.lang.String defValue)
          Returns a property from the default configuration file.
static RegExpEvaluator getRegExpEvaluator()
          Returns a new instance of the specified Regular Expression Evaluator, or null if no validator was specified
static org.apache.xml.serialize.Serializer getSerializer()
          Returns a default serializer for producing an XML document.
static 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.
static 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.
static XMLNaming getXMLNaming()
          Returns the naming conventions to use for the XML framework
protected static void load()
          Called by getDefault() to load the configuration the first time.
static java.util.Properties loadProperties(java.lang.String resourceName, java.lang.String fileName)
          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.
static boolean marshallingValidation()
          Returns true if the default configuration specified validation in the marshalling framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configuration

public Configuration()
Method Detail

debug

public static boolean debug()
Returns true if the default configuration specified debugging.


marshallingValidation

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


getDefault

public static java.util.Properties getDefault()
Returns the default configuration file. Changes to the returned properties set will affect all Castor functions relying on the default configuration.

Returns:
The default configuration

getProperty

public static java.lang.String getProperty(java.lang.String name,
                                           java.lang.String defValue)
Returns a property from the default configuration file. Equivalent to calling getProperty on the result of getDefault().

Parameters:
name - The property name
Returns:
The property's value

getXMLNaming

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

Returns:
the naming conventions to use for the XML framework

getParser

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

Returns:
A suitable XML parser

getParser

public static 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

getPrimitiveNodeType

public static 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.

Returns:
the NodeType assigned to Java primitives, or null if no NodeType was specified.

getRegExpEvaluator

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

Returns:
the regular expression evaluator,

getSerializer

public static 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.

Returns:
A suitable serializer

getOutputFormat

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

Returns:
the default OutputFormat

getSerializer

public static 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.

Parameters:
output - The output stream
Returns:
A suitable serializer
Throws:
java.io.IOException

getSerializer

public static 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.

Parameters:
output - The output stream
Returns:
A suitable serializer
Throws:
java.io.IOException

load

protected static void load()
Called by getDefault() to load the configuration the first time. 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.


loadProperties

public static java.util.Properties loadProperties(java.lang.String resourceName,
                                                  java.lang.String fileName)
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.



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