de.speexx.xml
Class FeatureConfigurator

java.lang.Object
  extended by de.speexx.xml.FeatureConfigurator

public abstract class FeatureConfigurator
extends Object

Should configure a SAXParserFactory, XMLReader or DocumentBuilderFactory with defined, parser dependend features. To get a new instance, call the newInstance() and then call init(InputStream) to set up the configurator.

Note, that DocumentBuilderFactory did not support the setFeature method until JAXP 1.3 (eg. Java 5).

See Xerces J Feature page for more information about features in the most used XML parser in Java.

The default implementation is thread safe.

© Copyright 2006 Sascha Kohlmann under the terms of the GNU LGPL

Since:
2.1
Author:
Sascha Kohlmann

Constructor Summary
FeatureConfigurator()
           
 
Method Summary
abstract  void configure(DocumentBuilderFactory builder)
          Configures the builder factory.
abstract  void configure(Object featurable)
          Configures all objects which has a setFeature(java.lang.String, boolean) method.
abstract  void configure(SAXParserFactory factory)
          Configures the parser factory.
abstract  void configure(XMLReader reader)
          Configures the reader.
abstract  void init(InputStream configuration)
          Sets up the configurator.
static FeatureConfigurator newInstance()
          Returns a new instance of the configurator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FeatureConfigurator

public FeatureConfigurator()
Method Detail

newInstance

public static FeatureConfigurator newInstance()
Returns a new instance of the configurator.

Returns:
a new instance.

init

public abstract void init(InputStream configuration)
                   throws FeatureConfigurationException
Sets up the configurator. The stream points to the configuration data.

The format of the default implemantation is one namespace of the feature, following by a space character (0x20), also fallowing by the literal true or false pair line. The values of the namespace maybe upper- or lower-case or mixed.

Parameters:
configuration - a stream to reach the configuration data.
Throws:
FeatureConfigurationException - if something goes wrong.

configure

public abstract void configure(SAXParserFactory factory)
                        throws ParserConfigurationException,
                               SAXNotRecognizedException,
                               SAXNotSupportedException
Configures the parser factory. Sets the particular feature in the underlying implementation of XMLReader.

Parameters:
factory - the factory to configure.
Throws:
SAXNotRecognizedException - When the underlying XMLReader does not recognize the property name.
SAXNotSupportedException - When the underlying XMLReader recognizes the property name but doesn't support the property.
ParserConfigurationException - if something different happens.
See Also:
SAXParserFactory.setFeature(java.lang.String, boolean)

configure

public abstract void configure(XMLReader reader)
                        throws SAXNotRecognizedException,
                               SAXNotSupportedException
Configures the reader. Sets the particular feature in the XMLReader.

Parameters:
reader - the XMLReader to configure.
Throws:
SAXNotRecognizedException - When the XMLReader does not recognize the feature name.
SAXNotSupportedException - When the XMLReader recognizes the feature name but cannot set the requested value.

configure

public abstract void configure(DocumentBuilderFactory builder)
                        throws ParserConfigurationException
Configures the builder factory. Sets the particular feature in the DocumentBuilderFactory.

Note: DocumentBuilderFactory supports setFeature since JAXP 1.3 coming with Java 5.

Parameters:
builder - the builder to configure.
Throws:
ParserConfigurationException - if something different happens.
UnsupportedOperationException - if DocumentBuilderFactory doesn't support setFeature(String, boolean) cause it is smaller JAXP 1.3.

configure

public abstract void configure(Object featurable)
Configures all objects which has a setFeature(java.lang.String, boolean) method.

Parameters:
featurable - a class which must have at least a setFeature method.
Throws:
FeatureConfigurationException - if featurable supports a setFeature(String, boolean) but the call fails.
UnsupportedOperationException - if featurable doesn't support a setFeature(String, boolean).


Copyright © 2000-2006 SpeexX. All Rights Reserved.