public final class ElementXPointer extends Object implements SimpleXPointer
ElementScheme
Modifier and Type | Class and Description |
---|---|
static interface |
ElementXPointer.Context
Context object which may be used to accelerate the node search.
|
static class |
ElementXPointer.ContextImpl
An implementation of
ElementXPointer.Context . |
Modifier and Type | Field and Description |
---|---|
int[] |
descendant
Location part of this xpointer if any; an empty array otherwise.
|
String |
id
ID part of this xpointer if any;
null otherwise. |
Constructor and Description |
---|
ElementXPointer(String id)
Constructs an XPointer pointing to element with specified ID.
|
ElementXPointer(String id,
int[] descendant)
Constructs an XPointer pointing to specified descendant of element with
specified ID.
|
Modifier and Type | Method and Description |
---|---|
Element |
findElement(Document doc)
Find in specified document the element selected by this xpointer.
|
Element |
findElement(Document doc,
ElementXPointer.Context context)
Find in specified document the element selected by this xpointer.
|
Node[] |
findNodes(Document doc,
Object context)
Searches specified document and returns the range of nodes selected
by this xpointer.
|
boolean |
isElementID()
Returns
true if this XPointer is
element(ID); returns false otherwise. |
boolean |
isRootElement()
Returns
true if this XPointer is element(/1);
returns false otherwise. |
String |
toString()
Returns the string representation of this XPointer.
|
public final String id
null
otherwise.public final int[] descendant
public ElementXPointer(String id)
null
.public ElementXPointer(String id, int[] descendant)
null
.
Example 1: for "#element(foo/1/2)", pass id=foo and descendant=[1,2].
Example 2: for "#element(/1/2)", pass id=null
and descendant=[1,2].
Example 3: for "#foo", pass id=foo and
descendant=null
.
public boolean isRootElement()
true
if this XPointer is element(/1);
returns false
otherwise.public boolean isElementID()
true
if this XPointer is
element(ID); returns false
otherwise.public String toString()
public Element findElement(Document doc)
doc
- document to be searchednull
public Element findElement(Document doc, ElementXPointer.Context context)
doc
- document to be searchedcontext
- context object used to accelerate the search.
May not be null
.null
public Node[] findNodes(Document doc, Object context)
SimpleXPointer
findNodes
in interface SimpleXPointer
doc
- document to be searchedcontext
- a context object (for example, cached data)
which is specific to the scheme of this xpointer.
May be null
An implementation cannot count on a context to be available.
null