# XPathFactory

public abstract class **XPathFactory** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
<br />

An `XPathFactory` instance can be used to create
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPath.html` objects.

See `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance(java.lang.String)` for lookup mechanism.

<br />

### Constant Summary

|---|---|---|
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [DEFAULT_OBJECT_MODEL_URI](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#DEFAULT_OBJECT_MODEL_URI) | Default Object Model URI. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [DEFAULT_PROPERTY_NAME](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#DEFAULT_PROPERTY_NAME) | The default property name according to the JAXP spec. |

### Protected Constructor Summary

|---|---|
|   | [XPathFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#XPathFactory())() Protected constructor as `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance()`, `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance(java.lang.String)` or `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance(java.lang.String,%20java.lang.String,%20java.lang.ClassLoader)` should be used to create a new instance of an `XPathFactory`. |

### Public Method Summary

|---|---|
| abstract boolean | [getFeature](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#getFeature(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Get the state of the named feature. |
| abstract boolean | [isObjectModelSupported](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#isObjectModelSupported(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) objectModel) Is specified object model supported by this `XPathFactory`? |
| final static [XPathFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html) | [newInstance](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance())() Get a new `XPathFactory` instance using the default object model, `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#DEFAULT_OBJECT_MODEL_URI`, the W3C DOM. |
| static [XPathFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html) | [newInstance](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance(java.lang.String,%20java.lang.String,%20java.lang.ClassLoader))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) uri, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) factoryClassName, [ClassLoader](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ClassLoader.html) classLoader) |
| final static [XPathFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html) | [newInstance](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) uri) Get a new `XPathFactory` instance using the specified object model. |
| abstract [XPath](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPath.html) | [newXPath](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newXPath())() Return a new `XPath` using the underlying object model determined when the `XPathFactory` was instantiated. |
| abstract void | [setFeature](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#setFeature(java.lang.String,%20boolean))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, boolean value) Set a feature for this `XPathFactory` and `XPath`s created by this factory. |
| abstract void | [setXPathFunctionResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#setXPathFunctionResolver(javax.xml.xpath.XPathFunctionResolver))([XPathFunctionResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFunctionResolver.html) resolver) Establish a default function resolver. |
| abstract void | [setXPathVariableResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#setXPathVariableResolver(javax.xml.xpath.XPathVariableResolver))([XPathVariableResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathVariableResolver.html) resolver) Establish a default variable resolver. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Constants

#### public static final [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**DEFAULT_OBJECT_MODEL_URI**

<br />

Default Object Model URI.

<br />

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

#### public static final [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**DEFAULT_PROPERTY_NAME**

<br />

The default property name according to the JAXP spec.

<br />

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

## Protected Constructors

#### protected
**XPathFactory**
()

<br />

Protected constructor as `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance()`, `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance(java.lang.String)`
or `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#newInstance(java.lang.String,%20java.lang.String,%20java.lang.ClassLoader)`
should be used to create a new instance of an `XPathFactory`.

<br />

## Public Methods

#### public abstract boolean
**getFeature**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name)

<br />

Get the state of the named feature.


Feature names are fully qualified `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html`s.
Implementations may define their own features.
An `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactoryConfigurationException.html` is thrown if this `XPathFactory` or the `XPath`s
it creates cannot support the feature.
It is possible for an `XPathFactory` to expose a feature value but be unable to change its state.

<br />

##### Parameters

| name | Feature name. |
|---|---|

##### Returns

- State of the named feature.

##### Throws

| [XPathFactoryConfigurationException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactoryConfigurationException.html) | if this `XPathFactory` or the `XPath`s it creates cannot support this feature. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `name` is `null`. |
|---|---|

#### public abstract boolean
**isObjectModelSupported**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) objectModel)

<br />

Is specified object model supported by this `XPathFactory`?

<br />

##### Parameters

| objectModel | Specifies the object model which the returned `XPathFactory` will understand. |
|---|---|

##### Returns

- `true` if `XPathFactory` supports `objectModel`, else `false`.

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If `objectModel` is `null`. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | If `objectModel.length() == 0`. |
|---|---|

#### public static final [XPathFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html)
**newInstance**
()

<br />

Get a new `XPathFactory` instance using the default object model,
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#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.

<br />

##### Returns

- Instance of an `XPathFactory`.

#### public static [XPathFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html)
**newInstance**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) uri, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) factoryClassName, [ClassLoader](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ClassLoader.html) classLoader)

<br />

##### Parameters

| uri |   |
| factoryClassName |   |
| classLoader |   |
|---|---|

##### Returns

- Instance of an `XPathFactory`.

##### Throws

| [XPathFactoryConfigurationException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactoryConfigurationException.html) | If the specified object model is unavailable. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If `uri` is `null`. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | If `uri.length() == 0`. |
|---|---|

#### public static final [XPathFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html)
**newInstance**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) uri)

<br />

Get a new `XPathFactory` instance using the specified object model.

To find a `XPathFactory` object,
this method looks the following places in the following order where "the class loader" refers to the context class loader:

1. If the system property `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#DEFAULT_PROPERTY_NAME` + ":uri" is present, where uri is the parameter to this method, then its value is read as a class name. The method will try to create a new instance of this class by using the class loader, and returns it if it is successfully created.
2. ${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for. If present, the value is processed just like above.
3. The class loader is asked for service provider provider-configuration files matching `javax.xml.xpath.XPathFactory` in the resource directory META-INF/services. See the JAR File Specification for file format and parsing rules. Each potential service provider is required to implement the method:

              https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#isObjectModelSupported(java.lang.String)
            
   The first service provider found in class loader order that supports the specified object model is returned.
4. Platform default `XPathFactory` is located in a platform specific way. There must be a platform default XPathFactory for the W3C DOM, i.e. `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#DEFAULT_OBJECT_MODEL_URI`.

If everything fails, an `XPathFactoryConfigurationException` will be thrown.

Tip for Trouble-shooting:

See `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Properties.html#load(java.io.InputStream)` for exactly how a property file is parsed.
In particular, colons ':' need to be escaped in a property file, so make sure the URIs are properly escaped in it.
For example:

```
   http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory
 
```

<br />

##### Parameters

| uri | Identifies the underlying object model. The specification only defines the URI `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactory.html#DEFAULT_OBJECT_MODEL_URI`, `http://java.sun.com/jaxp/xpath/dom` for the W3C DOM, the org.w3c.dom package, and implementations are free to introduce other URIs for other object models. |
|---|---|

##### Returns

- Instance of an `XPathFactory`.

##### Throws

| [XPathFactoryConfigurationException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactoryConfigurationException.html) | If the specified object model is unavailable. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If `uri` is `null`. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | If `uri.length() == 0`. |
|---|---|

#### public abstract [XPath](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPath.html)
**newXPath**
()

<br />

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

<br />

##### Returns

- New instance of an `XPath`.

#### public abstract void
**setFeature**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, boolean value)

<br />

Set a feature for this `XPathFactory` and `XPath`s created by this factory.


Feature names are fully qualified `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html`s.
Implementations may define their own features.
An `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactoryConfigurationException.html` is thrown if this `XPathFactory` or the `XPath`s
it creates cannot support the feature.
It is possible for an `XPathFactory` to expose a feature value but be unable to change its state.


All implementations are required to support the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/XMLConstants.html#FEATURE_SECURE_PROCESSING` feature.
When the feature is `true`, any reference to an external function is an error.
Under these conditions, the implementation must not call the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFunctionResolver.html`
and must throw an `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFunctionException.html`.

<br />

##### Parameters

| name | Feature name. |
| value | Is feature state `true` or `false`. |
|---|---|

##### Throws

| [XPathFactoryConfigurationException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFactoryConfigurationException.html) | if this `XPathFactory` or the `XPath`s it creates cannot support this feature. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `name` is `null`. |
|---|---|

#### public abstract void
**setXPathFunctionResolver**
([XPathFunctionResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathFunctionResolver.html) resolver)

<br />

Establish a default function resolver.

Any `XPath` objects constructed from this factory will use
the specified resolver by default.

A `NullPointerException` is thrown if `resolver` is `null`.

<br />

##### Parameters

| resolver | XPath function resolver. |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If `resolver` is `null`. |
|---|---|

#### public abstract void
**setXPathVariableResolver**
([XPathVariableResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/xpath/XPathVariableResolver.html) resolver)

<br />

Establish a default variable resolver.

Any `XPath` objects constructed from this factory will use
the specified resolver by default.

A `NullPointerException` is thrown if `resolver` is `null`.

<br />

##### Parameters

| resolver | Variable resolver. |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If `resolver` is `null`. |
|---|---|