|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovy.lang.GroovyObjectSupport groovy.util.slurpersupport.GPathResult
public abstract class GPathResult extends GroovyObjectSupport
Base class for representing lazy evaluated GPath expressions.
Field Summary | |
---|---|
protected java.lang.String |
name
|
protected java.util.Map |
namespaceMap
|
protected java.lang.String |
namespacePrefix
|
protected java.util.Map |
namespaceTagHints
|
protected GPathResult |
parent
|
Constructor Summary | |
GPathResult(GPathResult parent, java.lang.String name, java.lang.String namespacePrefix, java.util.Map namespaceTagHints)
Creates a new GPathResult named |
Method Summary | |
---|---|
protected void
|
appendNode(java.lang.Object newValue)
|
java.util.Iterator
|
breadthFirst()
Provides an Iterator over all the nodes of this GPathResult using a breadth-first traversal. |
java.util.Iterator
|
childNodes()
|
GPathResult
|
children()
Returns the children of this GPathResult as a GPathResult object. |
GPathResult
|
declareNamespace(java.util.Map newNamespaceMapping)
Adds the specified map of prefix to namespace mappings to this GPathResult. |
java.util.Iterator
|
depthFirst()
Provides an Iterator over all the nodes of this GPathResult using a depth-first traversal. |
boolean
|
equals(java.lang.Object obj)
|
GPathResult
|
find(Closure closure)
|
GPathResult
|
findAll(Closure closure)
|
java.lang.Object
|
getAt(int index)
Supports the subscript operator for a GPathResult. |
java.lang.Object
|
getAt(IntRange range)
Supports the range subscript operator for a GPathResult. |
Closure
|
getBody()
|
java.lang.Object
|
getProperty(java.lang.String property)
Returns the specified Property of this GPathResult. |
boolean
|
isEmpty()
Returns true if the GPathResult is empty, i.e. if, and only if, |
java.util.Iterator
|
iterator()
|
java.lang.Object
|
leftShift(java.lang.Object newValue)
Overloads the left shift operator to provide an easy way to lazily append Objects to this GPathResult. |
java.util.List
|
list()
Creates a list of objects representing this GPathResult. |
java.lang.String
|
lookupNamespace(java.lang.String prefix)
Returns the namespace mapped to the specified prefix. |
java.lang.String
|
name()
|
java.util.Iterator
|
nodeIterator()
|
GPathResult
|
parent()
Returns the parent of this GPathResult. |
GPathResult
|
parents()
|
java.lang.Object
|
plus(java.lang.Object newValue)
Lazily adds the specified Object to this GPathResult. |
void
|
putAt(int index, java.lang.Object newValue)
|
protected void
|
replaceBody(java.lang.Object newValue)
|
protected void
|
replaceNode(Closure newValue)
|
void
|
setMetaClass(MetaClass metaClass)
Replaces the MetaClass of this GPathResult. |
void
|
setProperty(java.lang.String property, java.lang.Object newValue)
Replaces the specified property of this GPathResult with a new value. |
int
|
size()
Returns the size of this GPathResult. |
java.lang.String
|
text()
|
java.math.BigDecimal
|
toBigDecimal()
Converts the text of this GPathResult to a BigDecimal object. |
java.math.BigInteger
|
toBigInteger()
Converts the text of this GPathResult to a BigInteger object. |
java.lang.Boolean
|
toBoolean()
Converts the text of this GPathResult to a Boolean object. |
java.lang.Double
|
toDouble()
Converts the text of this GPathResult to a Double object. |
java.lang.Float
|
toFloat()
Converts the text of this GPathResult to a Float object. |
java.lang.Integer
|
toInteger()
Converts the text of this GPathResult to a Integer object. |
java.lang.Long
|
toLong()
Converts the text of this GPathResult to a Long object. |
java.lang.String
|
toString()
Returns the text of this GPathResult. |
java.net.URI
|
toURI()
Converts the text of this GPathResult to a URI object. |
java.net.URL
|
toURL()
Converts the text of this GPathResult to a URL object. |
Methods inherited from class GroovyObjectSupport | |
---|---|
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
protected final java.lang.String name
protected final java.util.Map namespaceMap
protected final java.lang.String namespacePrefix
protected final java.util.Map namespaceTagHints
protected final GPathResult parent
Constructor Detail |
---|
public GPathResult(GPathResult parent, java.lang.String name, java.lang.String namespacePrefix, java.util.Map namespaceTagHints)
name
with the parent parent
,
the namespacePrefix namespacePrefix
and the namespaceTagHints specified in
the namespaceTagHints
Map.
parent
- the GPathResult prior to the application of the expression creating this GPathResultname
- if the GPathResult corresponds to something with a name, e.g. a nodenamespacePrefix
- the namespace prefix if anynamespaceTagHints
- the known tag to namespace mappings
Method Detail |
---|
protected void appendNode(java.lang.Object newValue)
public java.util.Iterator breadthFirst()
Iterator
of (breadth-first) ordered GPathResults
public java.util.Iterator childNodes()
public GPathResult children()
public GPathResult declareNamespace(java.util.Map newNamespaceMapping)
newNamespaceMapping
- the mappings to addthis
public java.util.Iterator depthFirst()
Iterator
of (depth-first) ordered GPathResults
public boolean equals(java.lang.Object obj)
public GPathResult find(Closure closure)
public GPathResult findAll(Closure closure)
public java.lang.Object getAt(int index)
def text = """ <characterList> <character/> <character> <name>Gromit</name> </character> </characterList>""" GPathResult characterList = new XmlSlurper().parseText(text) assert characterList.character[1].name == 'Gromit'
index
- an index
public java.lang.Object getAt(IntRange range)
def text = """ <characterList> <character>Wallace</character> <character>Gromit</character> <character>Shaun</character> </characterList>""" GPathResult characterList = new XmlSlurper().parseText(text) assert characterList.character[1..2].join(',') == 'Gromit,Shaun'
range
- a Range indicating the items to get
public Closure getBody()
public java.lang.Object getProperty(java.lang.String property)
Realizes the follow shortcuts:
'..'
for parent()
'*'
for children()
'**'
for depthFirst()
'@'
for attribute access
property
- the Property to fetch
public boolean isEmpty()
size()
is 0.
public java.util.Iterator iterator()
public java.lang.Object leftShift(java.lang.Object newValue)
newValue
- the Object to appendthis
public java.util.List list()
public java.lang.String lookupNamespace(java.lang.String prefix)
prefix
- the prefix lookup
public java.lang.String name()
public java.util.Iterator nodeIterator()
public GPathResult parent()
this
public GPathResult parents()
public java.lang.Object plus(java.lang.Object newValue)
newValue
- the Object to addthis
public void putAt(int index, java.lang.Object newValue)
protected void replaceBody(java.lang.Object newValue)
protected void replaceNode(Closure newValue)
@Override public void setMetaClass(MetaClass metaClass)
metaClass
- the new MetaClass
public void setProperty(java.lang.String property, java.lang.Object newValue)
property
- the property of this GPathResult to replacenewValue
- the new value of the property
public int size()
public java.lang.String text()
public java.math.BigDecimal toBigDecimal()
BigDecimal
public java.math.BigInteger toBigInteger()
BigInteger
public java.lang.Boolean toBoolean()
Boolean
public java.lang.Double toDouble()
Double
public java.lang.Float toFloat()
Float
public java.lang.Integer toInteger()
Integer
public java.lang.Long toLong()
Long
public java.lang.String toString()
String
public java.net.URI toURI()
URI
public java.net.URL toURL()
URL
Groovy Documentation