APIdia Launch Partner
Top Description Fields Constructors Methods
org.w3c.dom.bootstrap

public final Class DOMImplementationRegistry

extends Object
Class Inheritance
Imports
java.io.BufferedReader, .InputStream, .InputStreamReader, java.lang.reflect.InvocationTargetException, java.util.ArrayList, .List, .StringTokenizer, org.w3c.dom.DOMImplementation, .DOMImplementationList, .DOMImplementationSource

A factory that enables applications to obtain instances of DOMImplementation.

Example:

 // get an instance of the DOMImplementation registry
 DOMImplementationRegistry registry =
      DOMImplementationRegistry.newInstance();
 // get a DOM implementation the Level 3 XML module
 DOMImplementation domImpl =
      registry.getDOMImplementation("XML 3.0");

This provides an application with an implementation-independent starting point. DOM implementations may modify this class to meet new security standards or to provide *additional* fallbacks for the list of DOMImplementationSources.

Since
1.5, DOM Level 3
See Also
DOMImplementation, DOMImplementationSource

Field Summary

Modifier and TypeField and Description
private static final int
DEFAULT_LINE_LENGTH

Default columns per line.

private static final String
private static final String
FALLBACK_CLASS

Default class name.

public static final String
PROPERTY

The system property to specify the DOMImplementationSource class names.

private List<DOMImplementationSource>
sources

The list of DOMImplementationSources.

Constructor Summary

AccessConstructor and Description
private
DOMImplementationRegistry(final List<DOMImplementationSource>
List of DOMImplementationSources
srcs
)

Private constructor.

Method Summary

Modifier and TypeMethod and Description
public void
addSource(final DOMImplementationSource
The source to be registered, may not be null
s
)

Register an implementation.

private static ClassLoader

Returns:

A class loader, possibly null
getClassLoader
()

Gets a class loader.

private static ClassLoader

Returns:

The Context Classloader
getContextClassLoader
()

This method returns the ContextClassLoader.

public DOMImplementation

Returns:

An implementation that has the desired features, or null if none found.
getDOMImplementation
(final String
A string that specifies which features are required. This is a space separated list in which each feature is specified by its name optionally followed by a space and a version number. This is something like: "XML 1.0 Traversal +Events 2.0"
features
)

Return the first implementation that has the desired features, or null if none is found.

public DOMImplementationList

Returns:

A list of DOMImplementations that support the desired features.
getDOMImplementationList
(final String
A string that specifies which features are required. This is a space separated list in which each feature is specified by its name optionally followed by a space and a version number. This is something like: "XML 1.0 Traversal +Events 2.0"
features
)

Return a list of implementations that support the desired features.

private static InputStream

Returns:

an InputStream for the resource specified
getResourceAsStream
(final ClassLoader
classLoader
classLoader
,
final String
the resource
name
)

This method returns an InputStream for the reading resource META_INF/services/org.w3c.dom.DOMImplementationSourceList.

private static String

Returns:

first line of resource, or null
getServiceValue
(final ClassLoader
classLoader, may not be null.
classLoader
)

This method attempts to return the first line of the resource META_INF/services/org.w3c.dom.DOMImplementationSourceList from the provided ClassLoader.

private static String

Returns:

the system property
getSystemProperty
(final String
the name of the system property
name
)

This method returns the system property indicated by the specified name.

public static DOMImplementationRegistry

Returns:

an initialized instance of DOMImplementationRegistry
newInstance
()

Obtain a new instance of a DOMImplementationRegistry.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_LINE_LENGTHback to summary
private static final int DEFAULT_LINE_LENGTH

Default columns per line.

DEFAULT_PACKAGEback to summary
private static final String DEFAULT_PACKAGE
FALLBACK_CLASSback to summary
private static final String FALLBACK_CLASS

Default class name.

PROPERTYback to summary
public static final String PROPERTY

The system property to specify the DOMImplementationSource class names.

sourcesback to summary
private List<DOMImplementationSource> sources

The list of DOMImplementationSources.

Constructor Detail

DOMImplementationRegistryback to summary
private DOMImplementationRegistry(final List<DOMImplementationSource> srcs)

Private constructor.

Parameters
srcs:List<DOMImplementationSource>

List of DOMImplementationSources

Method Detail

addSourceback to summary
public void addSource(final DOMImplementationSource s)

Register an implementation.

Parameters
s:DOMImplementationSource

The source to be registered, may not be null

getClassLoaderback to summary
private static ClassLoader getClassLoader()

Gets a class loader.

Returns:ClassLoader

A class loader, possibly null

getContextClassLoaderback to summary
private static ClassLoader getContextClassLoader()

This method returns the ContextClassLoader.

Returns:ClassLoader

The Context Classloader

getDOMImplementationback to summary
public DOMImplementation getDOMImplementation(final String features)

Return the first implementation that has the desired features, or null if none is found.

Parameters
features:String

A string that specifies which features are required. This is a space separated list in which each feature is specified by its name optionally followed by a space and a version number. This is something like: "XML 1.0 Traversal +Events 2.0"

Returns:DOMImplementation

An implementation that has the desired features, or null if none found.

getDOMImplementationListback to summary
public DOMImplementationList getDOMImplementationList(final String features)

Return a list of implementations that support the desired features.

Parameters
features:String

A string that specifies which features are required. This is a space separated list in which each feature is specified by its name optionally followed by a space and a version number. This is something like: "XML 1.0 Traversal +Events 2.0"

Returns:DOMImplementationList

A list of DOMImplementations that support the desired features.

getResourceAsStreamback to summary
private static InputStream getResourceAsStream(final ClassLoader classLoader, final String name)

This method returns an InputStream for the reading resource META_INF/services/org.w3c.dom.DOMImplementationSourceList.

Parameters
classLoader:ClassLoader

classLoader

name:String

the resource

Returns:InputStream

an InputStream for the resource specified

getServiceValueback to summary
private static String getServiceValue(final ClassLoader classLoader)

This method attempts to return the first line of the resource META_INF/services/org.w3c.dom.DOMImplementationSourceList from the provided ClassLoader.

Parameters
classLoader:ClassLoader

classLoader, may not be null.

Returns:String

first line of resource, or null

getSystemPropertyback to summary
private static String getSystemProperty(final String name)

This method returns the system property indicated by the specified name.

Parameters
name:String

the name of the system property

Returns:String

the system property

newInstanceback to summary
public static DOMImplementationRegistry newInstance() throws ClassNotFoundException, InstantiationException, IllegalAccessException, ClassCastException

Obtain a new instance of a DOMImplementationRegistry. The DOMImplementationRegistry is initialized by the application or the implementation, depending on the context, by first checking the value of the Java system property org.w3c.dom.DOMImplementationSourceList and the service provider whose contents are at "META_INF/services/org.w3c.dom.DOMImplementationSourceList". The value of this property is a white-space separated list of names of availables classes implementing the DOMImplementationSource interface. Each class listed in the class name list is instantiated and any exceptions encountered are thrown to the application.

Returns:DOMImplementationRegistry

an initialized instance of DOMImplementationRegistry

Exceptions
ClassNotFoundException:
If any specified class can not be found
InstantiationException:
If any specified class is an interface or abstract class
IllegalAccessException:
If the default constructor of a specified class is not accessible
ClassCastException:
If any specified class does not implement DOMImplementationSource