org.jbind.xml
Class PrefsConfig

java.lang.Object
  extended byorg.jbind.util.other.Prefs
      extended byorg.jbind.xml.PrefsConfig
All Implemented Interfaces:
IConfig

public class PrefsConfig
extends Prefs
implements IConfig

Configuration of the XML package. Uses Preferences for storing the configuration information. The configuration can be managed using the main method of this class.

The configuration information is divided into several branches:

An example preferences file can be obtained by executing the command:
java org.jbind.xml.Config -reset -export config.xml.


Field Summary
static java.lang.String APPLICATION_XML_CATALOG
          Application XML catalog.
static java.lang.String CARTRIDGES
          Relative node path that is used for storing cartridges ("schemaCompiler/cartridges").
static java.lang.String CHECK_COUNTRY_CODE
          Key for a boolean value in the validation prefences ("checkCountryCode").
static java.lang.String CHECK_LANGUAGE_CODE
          Key for a boolean value in the validation prefences ("checkLanguageCode").
static java.lang.String COUNTRY_CODES
          Relative node path that is used for storing country codes.
static java.lang.String DATA_FACTORY
          Key to configure a class name in the modules prefences ("dataFactory").
static java.lang.String DEFAULT_ENTITY_RESOLVER
           
static java.lang.String ENTITY_RESOLVER
          Key to configure a class name in the modules prefences ("entityResolver").
static PrefsConfig instance
           
static java.lang.String JBIND_CONFIG
          System property to specify a configuration resource ("jBindConfig").
static java.lang.String JBIND_INIT_CONFIG
          System property that determines if the JBind configuration is initialized ("jBindInitConfig").
static java.lang.String JBIND_PREFERENCE_TREE
          System property to control whether the user preference tree or the system preference tree is used ("jBindPreferenceTree").
static java.lang.String JBIND_XML_CATALOG
          JBind XML catalog.
static java.lang.String LANGUAGE_CODES
          Relative node path that is used for storing language codes.
static java.lang.String LOAD_BY_CLASS_LOADER
          Constant that identifies the load method that uses the Config.class.getResource(String aResourceName) to access a resource.
static java.lang.String LOAD_BY_URL
          Constant that identifies a load method that uses a configured URL.
static java.lang.String MODULES
          Relative node path that is used for storing information about the configurable modules ("modules").
static java.lang.String N2P_MAPPING
          Relative node path that is used for storing namespace to package mappings ("schemaCompiler/namespaceToPackageMapping").
static java.lang.String REGEX_FACTORY
          Key to configure a class name in the modules prefences ("regExFactory").
static java.lang.String RUNTIME
          Relative node path that is used for storing validation information ("runtime").
static java.lang.String SCHEMA_COMPILER
          Relative node path that is used for storing information for the schema compiler ("schemaCompiler").
static java.lang.String STRICT_SCHEMA_VALIDATION
          Key for a boolean value in the validation prefences ("strictSchemaValidation").
static java.lang.String USE_CONTEXT_CLASS_LOADER
          Key for a boolean value in the runtime prefences ("useContextClassLoader").
static java.lang.String USER_XML_CATALOG
          User XML catalog.
static java.lang.String VALIDATION
          Relative node path that is used for storing validation information ("validation").
static java.lang.String XML_CATALOGS
          Relative node path ("xmlCatalogs") that is used to configure XML catalogs that are used to resolve publicIds, systemIds, and namespaces.
static java.lang.String XPATH_FACTORY
          Key to configure a class name in the modules prefences ("xPathFactory").
 
Method Summary
 void addCatalog(java.net.URL aUrl)
           
 boolean checkCountryCode()
           
 boolean checkLanguageCode()
           
 IRegEx createRegEx(java.lang.String aString)
           
protected  void doResetPrefs()
          Hook method that is called if the "reset" option is handled.
 java.lang.String[] getCartridgeClasses()
           
 java.lang.String getCountry(java.lang.String aCode)
           
 IDataImplFactory getDataImplFactory()
           
 org.xml.sax.EntityResolver getDefaultEntityResolver()
           
 org.xml.sax.EntityResolver getEntityResolver()
           
 java.lang.String getLanguage(java.lang.String aCode)
           
 java.lang.String getPackageForNamespace(java.lang.String aNamespace)
           
 IRegExFactory getRegExFactory()
           
 javax.xml.transform.URIResolver getUriResolver()
           
 IXPathFactory getXPathFactory()
           
static void main(java.lang.String[] anArgs)
          Manages the configuration.
 java.lang.String resolveUri(java.lang.String aUri)
           
 boolean strictSchemaValidation()
           
 boolean useContextClassLoader()
           
 
Methods inherited from class org.jbind.util.other.Prefs
doAcceptArgument, doMain, getPrefs, getPrefs, resetPrefs, usage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static final PrefsConfig instance

SCHEMA_COMPILER

public static final java.lang.String SCHEMA_COMPILER
Relative node path that is used for storing information for the schema compiler ("schemaCompiler").

See Also:
Constant Field Values

N2P_MAPPING

public static final java.lang.String N2P_MAPPING
Relative node path that is used for storing namespace to package mappings ("schemaCompiler/namespaceToPackageMapping").

See Also:
Constant Field Values

CARTRIDGES

public static final java.lang.String CARTRIDGES
Relative node path that is used for storing cartridges ("schemaCompiler/cartridges").

See Also:
Constant Field Values

VALIDATION

public static final java.lang.String VALIDATION
Relative node path that is used for storing validation information ("validation").

See Also:
Constant Field Values

USE_CONTEXT_CLASS_LOADER

public static final java.lang.String USE_CONTEXT_CLASS_LOADER
Key for a boolean value in the runtime prefences ("useContextClassLoader"). The default is true. Iff this entry is true then user classes are instantiated using the context class loader. Iff this feature is false then user classes are loaded using the class loader that loaded the JBind classes.

See Also:
Constant Field Values

RUNTIME

public static final java.lang.String RUNTIME
Relative node path that is used for storing validation information ("runtime").

See Also:
Constant Field Values

STRICT_SCHEMA_VALIDATION

public static final java.lang.String STRICT_SCHEMA_VALIDATION
Key for a boolean value in the validation prefences ("strictSchemaValidation"). The default is "false". The following features are influenced by this option:

See Also:
Constant Field Values

CHECK_COUNTRY_CODE

public static final java.lang.String CHECK_COUNTRY_CODE
Key for a boolean value in the validation prefences ("checkCountryCode"). The default is "false".

See Also:
Constant Field Values

CHECK_LANGUAGE_CODE

public static final java.lang.String CHECK_LANGUAGE_CODE
Key for a boolean value in the validation prefences ("checkLanguageCode"). The default is "false".

See Also:
Constant Field Values

COUNTRY_CODES

public static final java.lang.String COUNTRY_CODES
Relative node path that is used for storing country codes. The value is: "validation/countryCodes".

See Also:
Constant Field Values

LANGUAGE_CODES

public static final java.lang.String LANGUAGE_CODES
Relative node path that is used for storing language codes. The value is: "validation/languageCodes".

See Also:
Constant Field Values

MODULES

public static final java.lang.String MODULES
Relative node path that is used for storing information about the configurable modules ("modules").

See Also:
Constant Field Values

XPATH_FACTORY

public static final java.lang.String XPATH_FACTORY
Key to configure a class name in the modules prefences ("xPathFactory").

See Also:
Constant Field Values

REGEX_FACTORY

public static final java.lang.String REGEX_FACTORY
Key to configure a class name in the modules prefences ("regExFactory").

See Also:
Constant Field Values

DATA_FACTORY

public static final java.lang.String DATA_FACTORY
Key to configure a class name in the modules prefences ("dataFactory").

See Also:
Constant Field Values

ENTITY_RESOLVER

public static final java.lang.String ENTITY_RESOLVER
Key to configure a class name in the modules prefences ("entityResolver").

See Also:
Constant Field Values

DEFAULT_ENTITY_RESOLVER

public static final java.lang.String DEFAULT_ENTITY_RESOLVER
See Also:
Constant Field Values

XML_CATALOGS

public static final java.lang.String XML_CATALOGS
Relative node path ("xmlCatalogs") that is used to configure XML catalogs that are used to resolve publicIds, systemIds, and namespaces. The preference node contains a map mapping catalog names to their load method (cf. LOAD_BY_CLASS_LOADER, LOAD_BY_URL).

See Also:
Constant Field Values

LOAD_BY_CLASS_LOADER

public static final java.lang.String LOAD_BY_CLASS_LOADER
Constant that identifies the load method that uses the Config.class.getResource(String aResourceName) to access a resource.

See Also:
Constant Field Values

LOAD_BY_URL

public static final java.lang.String LOAD_BY_URL
Constant that identifies a load method that uses a configured URL. Relative URLs are resolved relative to the current user home directory.

See Also:
Constant Field Values

JBIND_XML_CATALOG

public static final java.lang.String JBIND_XML_CATALOG
JBind XML catalog. ("/org/jbind/catalog.xml").

See Also:
Constant Field Values

APPLICATION_XML_CATALOG

public static final java.lang.String APPLICATION_XML_CATALOG
Application XML catalog. ("/catalog.xml").

See Also:
Constant Field Values

USER_XML_CATALOG

public static final java.lang.String USER_XML_CATALOG
User XML catalog. (".catalog.xml").

See Also:
Constant Field Values

JBIND_INIT_CONFIG

public static final java.lang.String JBIND_INIT_CONFIG
System property that determines if the JBind configuration is initialized ("jBindInitConfig"). The default value is "true".

See Also:
Constant Field Values

JBIND_CONFIG

public static final java.lang.String JBIND_CONFIG
System property to specify a configuration resource ("jBindConfig"). If the specified string contains the substring "://" then it is used as the URL of the configuration file. Otherwise the class loader of the Config class is used to access the resource by its getResourceAsStream method.

See Also:
Constant Field Values

JBIND_PREFERENCE_TREE

public static final java.lang.String JBIND_PREFERENCE_TREE
System property to control whether the user preference tree or the system preference tree is used ("jBindPreferenceTree"). The default is "system".

See Also:
Constant Field Values
Method Detail

getDefaultEntityResolver

public org.xml.sax.EntityResolver getDefaultEntityResolver()

getUriResolver

public javax.xml.transform.URIResolver getUriResolver()

checkLanguageCode

public boolean checkLanguageCode()
Specified by:
checkLanguageCode in interface IConfig

checkCountryCode

public boolean checkCountryCode()
Specified by:
checkCountryCode in interface IConfig

strictSchemaValidation

public boolean strictSchemaValidation()
Specified by:
strictSchemaValidation in interface IConfig

getCountry

public java.lang.String getCountry(java.lang.String aCode)
Specified by:
getCountry in interface IConfig

getLanguage

public java.lang.String getLanguage(java.lang.String aCode)
Specified by:
getLanguage in interface IConfig

getPackageForNamespace

public java.lang.String getPackageForNamespace(java.lang.String aNamespace)
Specified by:
getPackageForNamespace in interface IConfig

resolveUri

public java.lang.String resolveUri(java.lang.String aUri)
                            throws XmlException
Specified by:
resolveUri in interface IConfig
Throws:
XmlException

getXPathFactory

public IXPathFactory getXPathFactory()
Specified by:
getXPathFactory in interface IConfig

getDataImplFactory

public IDataImplFactory getDataImplFactory()
Specified by:
getDataImplFactory in interface IConfig

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Specified by:
getEntityResolver in interface IConfig

getRegExFactory

public IRegExFactory getRegExFactory()
Specified by:
getRegExFactory in interface IConfig

createRegEx

public IRegEx createRegEx(java.lang.String aString)
                   throws java.lang.Exception
Specified by:
createRegEx in interface IConfig
Throws:
java.lang.Exception

getCartridgeClasses

public java.lang.String[] getCartridgeClasses()
                                       throws java.lang.Exception
Specified by:
getCartridgeClasses in interface IConfig
Throws:
java.lang.Exception

doResetPrefs

protected void doResetPrefs()
Description copied from class: Prefs
Hook method that is called if the "reset" option is handled. Before the hook method is called the current preferences are removed and new preferences will be created on demand.

Subclasses should implement this method by setting default values for the various preferences. This enables one to first reset the preferences and then to export them. The exported preferences should contain enough structural information to allow manual editing, i.e. ideally all possible preference keys with default values are present.

The default implementation does nothing.

Overrides:
doResetPrefs in class Prefs

main

public static void main(java.lang.String[] anArgs)
Manages the configuration. For a description of the valid arguments see the Prefs.doMain(java.lang.String[]) method.

Parameters:
anArgs - (required).

addCatalog

public void addCatalog(java.net.URL aUrl)
Specified by:
addCatalog in interface IConfig

useContextClassLoader

public boolean useContextClassLoader()
Specified by:
useContextClassLoader in interface IConfig