|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gdata.model.Path
public class Path
The Path class represents an immutable path to a model entity in the GData
DOM. A path can be absolute (the root ElementMetadata
for the path is
specified at construction time or relative (the root element type is unknown
at construction time).
The toAbsolute(ElementMetadata)
method can be used to produce an
absolute path from a relative path by interpreting it relative to a root.
New paths can be constructed using the of(MetadataKey...)
or
to(ElementMetadata, MetadataKey...)
methods as well as using the
builder()
method to obtain a new Path.Builder
instance that can
be used for incremental path construction.
Nested Class Summary | |
---|---|
static class |
Path.Builder
The Builder class provides a model for incrementally constructing new Path relative or absolute instances. |
Field Summary | |
---|---|
static Path |
ROOT
A simple relative path that selects the root of the path. |
Method Summary | |
---|---|
static Path.Builder |
builder()
|
boolean |
equals(java.lang.Object o)
The equals method will return true if the target object is also a Path , has the same root or is also relative, and has the same list
of path steps. |
ElementKey<?,?> |
getParentKey()
Returns the element key for the second-to-last key in the path. |
AttributeMetadata<?> |
getSelectedAttribute()
Returns the attribute type currently selected by the path or null
if the path selects an element or is relative. |
AttributeKey<?> |
getSelectedAttributeKey()
Returns the attribute key at the end of the path. |
ElementMetadata<?,?> |
getSelectedElement()
Returns the element type currently selected by the path or null
if the path is relative. |
ElementKey<?,?> |
getSelectedElementKey()
Returns the element key at the end of the path. |
java.util.List<MetadataKey<?>> |
getSteps()
Returns the list of path steps. |
int |
hashCode()
|
boolean |
isRelative()
Returns true if path is relative |
static Path |
of(MetadataKey<?>... steps)
Constructs a new relative Path that selects an element defined by
the set of path steps to the element. |
boolean |
selectsAttribute()
Returns true if the path selects an attribute. |
boolean |
selectsElement()
Returns true if the path selects an element. |
static Path |
to(ElementMetadata<?,?> root,
MetadataKey<?>... keys)
Constructs a new absolute Path to an element type as defined by a
root type and the relative steps from it to the selected type. |
Path |
toAbsolute(ElementMetadata<?,?> root)
Constructs a new Path instance by interpreting the steps in the
current path relative to the provided root ElementMetadata . |
java.lang.String |
toString()
The toString() implementation is overridden to return the XPath
string that represents the path. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Path ROOT
Method Detail |
---|
public static Path.Builder builder()
public static Path of(MetadataKey<?>... steps)
Path
that selects an element defined by
the set of path steps to the element.
steps
- keys defining steps to the selected element
public static Path to(ElementMetadata<?,?> root, MetadataKey<?>... keys)
Path
to an element type as defined by a
root type and the relative steps from it to the selected type.
keys
- keys defining steps to the selected element
PathException
- if this path has been bound to a
metadata instance and no key with the given step can be found, or
if the path is an attribute path. Once a path has an attribute key
no more steps may be added.
java.lang.NullPointerException
- if root is null.public boolean selectsAttribute()
true
if the path selects an attribute.
public boolean selectsElement()
true
if the path selects an element.
public ElementMetadata<?,?> getSelectedElement()
null
if the path is relative.
public AttributeMetadata<?> getSelectedAttribute()
null
if the path selects an element or is relative.
public java.util.List<MetadataKey<?>> getSteps()
public boolean isRelative()
true
if path is relative
public AttributeKey<?> getSelectedAttributeKey()
java.lang.IllegalStateException
- if this path is not to an attribute.public ElementKey<?,?> getSelectedElementKey()
java.lang.IllegalStateException
- if this path is not to an element.public ElementKey<?,?> getParentKey()
null
.
public Path toAbsolute(ElementMetadata<?,?> root)
Path
instance by interpreting the steps in the
current path relative to the provided root ElementMetadata
.
root
- root of returned path
Path
bound to the root element metadata.
PathException
- if the path is not found in the metadata.
java.lang.NullPointerException
- if root is null.public java.lang.String toString()
toString()
implementation is overridden to return the XPath
string that represents the path.
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
Path
, has the same root or is also relative, and has the same list
of path steps.
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |