Top Description Inners Fields Constructors Methods
org.apache.html.dom

pack-priv final Class ObjectFactory

extends Object
Class Inheritance
Imports
java.io.BufferedReader, .File, .FileInputStream, .IOException, .InputStream, .InputStreamReader, java.util.Properties

This class is duplicated for each JAXP subpackage so keep it in sync. It is package private and therefore is not exposed as part of the JAXP API.

This code is designed to implement the JAXP 1.1 spec pluggability feature and is designed to run on JDK version 1.1 and later, and to compile on JDK 1.2 and onward. The code also runs both as part of an unbundled jar file and when bundled as part of the JDK.

Version
$Id: ObjectFactory.java 1391587 2012-09-28 18:40:04Z mrglavas $

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ObjectFactory.ConfigurationError

A configuration error.

Field Summary

Modifier and TypeField and Description
private static final boolean
DEBUG

Set to true for debugging

private static final int
DEFAULT_LINE_LENGTH

Default columns per line.

private static final String
private static long
fLastModified

Cache the time stamp of the xerces.properties file so that we know if it's been modified and can invalidate the cache when necessary.

private static Properties
fXercesProperties

cache the contents of the xerces.properties file.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static Object

Returns:

Class object of factory, never null
createObject
(String
Name of the factory to find, same as a property name
factoryId
,
String
Implementation class name, if nothing else is found. Use null to mean no fallback.
fallbackClassName
)

Finds the implementation Class object in the specified order.

pack-priv static Object

Returns:

Class object of factory, never null
createObject
(String
Name of the factory to find, same as a property name
factoryId
,
String
The filename in the $java.home/lib directory of the properties file. If none specified, ${java.home}/lib/xerces.properties will be used.
propertiesFilename
,
String
Implementation class name, if nothing else is found. Use null to mean no fallback.
fallbackClassName
)

Finds the implementation Class object in the specified order.

private static void
debugPrintln(String msg)

Prints a message to standard error if debugging is enabled.

pack-priv static ClassLoader
findClassLoader()

Figure out which ClassLoader to use.

private static Object
pack-priv static Class<T>
findProviderClass(String className, ClassLoader cl, boolean doFallback)

Find a Class using the specified ClassLoader

private static boolean
isDebugEnabled()

Returns true if debug has been enabled.

pack-priv static Object
newInstance(String className, ClassLoader cl, boolean doFallback)

Create an instance of a class using the specified ClassLoader

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
private static final boolean DEBUG

Set to true for debugging

DEFAULT_LINE_LENGTHback to summary
private static final int DEFAULT_LINE_LENGTH

Default columns per line.

DEFAULT_PROPERTIES_FILENAMEback to summary
private static final String DEFAULT_PROPERTIES_FILENAME
fLastModifiedback to summary
private static long fLastModified

Cache the time stamp of the xerces.properties file so that we know if it's been modified and can invalidate the cache when necessary.

fXercesPropertiesback to summary
private static Properties fXercesProperties

cache the contents of the xerces.properties file. Until an attempt has been made to read this file, this will be null; if the file does not exist or we encounter some other error during the read, this will be empty.

Constructor Detail

ObjectFactoryback to summary
pack-priv ObjectFactory()

Method Detail

createObjectback to summary
pack-priv static Object createObject(String factoryId, String fallbackClassName) throws ConfigurationError

Finds the implementation Class object in the specified order. The specified order is the following:

  1. query the system property using System.getProperty
  2. read META-INF/services/factoryId file
  3. use fallback classname
Parameters
factoryId:String

Name of the factory to find, same as a property name

fallbackClassName:String

Implementation class name, if nothing else is found. Use null to mean no fallback.

Returns:Object

Class object of factory, never null

createObjectback to summary
pack-priv static Object createObject(String factoryId, String propertiesFilename, String fallbackClassName) throws ConfigurationError

Finds the implementation Class object in the specified order. The specified order is the following:

  1. query the system property using System.getProperty
  2. read $java.home/lib/propertiesFilename file
  3. read META-INF/services/factoryId file
  4. use fallback classname
Parameters
factoryId:String

Name of the factory to find, same as a property name

propertiesFilename:String

The filename in the $java.home/lib directory of the properties file. If none specified, ${java.home}/lib/xerces.properties will be used.

fallbackClassName:String

Implementation class name, if nothing else is found. Use null to mean no fallback.

Returns:Object

Class object of factory, never null

debugPrintlnback to summary
private static void debugPrintln(String msg)

Prints a message to standard error if debugging is enabled.

findClassLoaderback to summary
pack-priv static ClassLoader findClassLoader() throws ConfigurationError

Figure out which ClassLoader to use. For JDK 1.2 and later use the context ClassLoader.

findJarServiceProviderback to summary
private static Object findJarServiceProvider(String factoryId) throws ConfigurationError
findProviderClassback to summary
pack-priv static Class<T> findProviderClass(String className, ClassLoader cl, boolean doFallback) throws ClassNotFoundException, ConfigurationError

Find a Class using the specified ClassLoader

isDebugEnabledback to summary
private static boolean isDebugEnabled()

Returns true if debug has been enabled.

newInstanceback to summary
pack-priv static Object newInstance(String className, ClassLoader cl, boolean doFallback) throws ConfigurationError

Create an instance of a class using the specified ClassLoader

org.apache.html.dom back to summary

pack-priv final Class ObjectFactory.ConfigurationError

extends Error
Class Inheritance

A configuration error.

Field Summary

Modifier and TypeField and Description
private Exception
exception

Exception.

pack-priv static final long

Constructor Summary

AccessConstructor and Description
pack-priv
ConfigurationError(String msg, Exception x)

Construct a new instance with the specified detail string and exception.

Method Summary

Modifier and TypeMethod and Description
pack-priv Exception
getException()

Returns the exception associated to this error.

Field Detail

exceptionback to summary
private Exception exception

Exception.

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.lang.Error.serialVersionUID.

Serialization version.

Constructor Detail

ConfigurationErrorback to summary
pack-priv ConfigurationError(String msg, Exception x)

Construct a new instance with the specified detail string and exception.

Method Detail

getExceptionback to summary
pack-priv Exception getException()

Returns the exception associated to this error.