XPathFactory

public abstract class XPathFactory extends Object

An XPathFactory instance can be used to create XPath objects.

See newInstance(String) for lookup mechanism.

Constant Summary

String DEFAULT_OBJECT_MODEL_URI

Default Object Model URI.

String DEFAULT_PROPERTY_NAME

The default property name according to the JAXP spec.

Protected Constructor Summary

XPathFactory()

Protected constructor as newInstance(), newInstance(String) or newInstance(String, String, ClassLoader) should be used to create a new instance of an XPathFactory.

Public Method Summary

abstract boolean
getFeature(String name)

Get the state of the named feature.

abstract boolean
isObjectModelSupported(String objectModel)

Is specified object model supported by this XPathFactory?

final static XPathFactory
newInstance()

Get a new XPathFactory instance using the default object model, DEFAULT_OBJECT_MODEL_URI, the W3C DOM.

static XPathFactory
newInstance(String uri, String factoryClassName, ClassLoader classLoader)
final static XPathFactory
newInstance(String uri)

Get a new XPathFactory instance using the specified object model.

abstract XPath
newXPath()

Return a new XPath using the underlying object model determined when the XPathFactory was instantiated.

abstract void
setFeature(String name, boolean value)

Set a feature for this XPathFactory and XPaths created by this factory.

abstract void
setXPathFunctionResolver(XPathFunctionResolver resolver)

Establish a default function resolver.

abstract void
setXPathVariableResolver(XPathVariableResolver resolver)

Establish a default variable resolver.

Inherited Method Summary

Constants

public static final String DEFAULT_OBJECT_MODEL_URI

Default Object Model URI.

Constant Value: "http://java.sun.com/jaxp/xpath/dom"

public static final String DEFAULT_PROPERTY_NAME

The default property name according to the JAXP spec.

Constant Value: "javax.xml.xpath.XPathFactory"

Protected Constructors

protected XPathFactory ()

Protected constructor as newInstance(), newInstance(String) or newInstance(String, String, ClassLoader) should be used to create a new instance of an XPathFactory.

Public Methods

public abstract boolean getFeature (String name)

Get the state of the named feature.

Feature names are fully qualified URIs. Implementations may define their own features. An XPathFactoryConfigurationException is thrown if this XPathFactory or the XPaths it creates cannot support the feature. It is possible for an XPathFactory to expose a feature value but be unable to change its state.

Parameters
name Feature name.
Returns
  • State of the named feature.
Throws
XPathFactoryConfigurationException if this XPathFactory or the XPaths it creates cannot support this feature.
NullPointerException if name is null.

public abstract boolean isObjectModelSupported (String objectModel)

Is specified object model supported by this XPathFactory?

Parameters
objectModel Specifies the object model which the returned XPathFactory will understand.
Returns
  • true if XPathFactory supports objectModel, else false.
Throws
NullPointerException If objectModel is null.
IllegalArgumentException If objectModel.length() == 0.

public static final XPathFactory newInstance ()

Get a new XPathFactory instance using the default object model, DEFAULT_OBJECT_MODEL_URI, the W3C DOM.

This method is functionally equivalent to:

   newInstance(DEFAULT_OBJECT_MODEL_URI)
 

Since the implementation for the W3C DOM is always available, this method will never fail.

Returns
  • Instance of an XPathFactory.

public static XPathFactory newInstance (String uri, String factoryClassName, ClassLoader classLoader)

Parameters
uri
factoryClassName