public abstract class GPathResult extends groovy.lang.GroovyObjectSupport
Base class for representing lazy evaluated GPath expressions.
| Modifiers | Name | Description |
|---|---|---|
protected String |
name |
|
protected Map |
namespaceMap |
|
protected String |
namespacePrefix |
|
protected Map |
namespaceTagHints |
|
protected GPathResult |
parent |
| Constructor and description |
|---|
GPathResult
(GPathResult parent, String name, String namespacePrefix, Map namespaceTagHints)Creates a new GPathResult named name with the parent parent,
the namespacePrefix namespacePrefix and the namespaceTagHints specified in
the namespaceTagHints Map. |
| Type | Name and description |
|---|---|
protected void |
appendNode(Object newValue) |
Iterator |
breadthFirst()Provides an Iterator over all the nodes of this GPathResult using a breadth-first traversal. |
Iterator |
childNodes() |
GPathResult |
children()Returns the children of this GPathResult as a GPathResult object. |
GPathResult |
declareNamespace(Map newNamespaceMapping)Adds the specified map of prefix to namespace mappings to this GPathResult. |
Iterator |
depthFirst()Provides an Iterator over all the nodes of this GPathResult using a depth-first traversal. |
boolean |
equals(Object obj) |
GPathResult |
find(groovy.lang.Closure closure) |
GPathResult |
findAll(groovy.lang.Closure closure) |
Object |
getAt(int index)Supports the subscript operator for a GPathResult. |
Object |
getAt(groovy.lang.IntRange range)Supports the range subscript operator for a GPathResult. |
groovy.lang.Closure |
getBody() |
Object |
getProperty(String property)Returns the specified Property of this GPathResult. |
boolean |
isEmpty()Returns true if the GPathResult is empty, i.e. if, and only if, size() is 0. |
Iterator |
iterator() |
Object |
leftShift(Object newValue)Overloads the left shift operator to provide an easy way to lazily append Objects to this GPathResult. |
List |
list()Creates a list of objects representing this GPathResult. |
String |
lookupNamespace(String prefix)Returns the namespace mapped to the specified prefix. |
String |
name() |
Iterator |
nodeIterator() |
GPathResult |
parent()Returns as GPathResult with the parent nodes of the current GPathResult |
GPathResult |
parents() |
Object |
plus(Object newValue)Lazily adds the specified Object to this GPathResult. |
GPathResult |
pop()Returns the parent of this GPathResult. |
void |
putAt(int index, Object newValue) |
protected void |
replaceBody(Object newValue) |
protected void |
replaceNode(groovy.lang.Closure newValue) |
void |
setMetaClass(groovy.lang.MetaClass metaClass)Replaces the MetaClass of this GPathResult. |
void |
setProperty(String property, Object newValue)Replaces the specified property of this GPathResult with a new value. |
int |
size()Returns the size of this GPathResult. |
String |
text() |
BigDecimal |
toBigDecimal()Converts the text of this GPathResult to a BigDecimal object. |
BigInteger |
toBigInteger()Converts the text of this GPathResult to a BigInteger object. |
Boolean |
toBoolean()Converts the text of this GPathResult to a Boolean object. |
Double |
toDouble()Converts the text of this GPathResult to a Double object. |
Float |
toFloat()Converts the text of this GPathResult to a Float object. |
Integer |
toInteger()Converts the text of this GPathResult to a Integer object. |
Long |
toLong()Converts the text of this GPathResult to a Long object. |
String |
toString()Returns the text of this GPathResult. |
URI |
toURI()Converts the text of this GPathResult to a URI object. |
URL |
toURL()Converts the text of this GPathResult to a URL object. |
| Methods inherited from class | Name |
|---|---|
class groovy.lang.GroovyObjectSupport |
groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() |
class Object |
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Creates a new GPathResult named 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 mappingsProvides an Iterator over all the nodes of this GPathResult using a breadth-first traversal.
Iterator of (breadth-first) ordered GPathResultsReturns the children of this GPathResult as a GPathResult object.
Adds the specified map of prefix to namespace mappings to this GPathResult. Already existing prefixes are overwritten.
newNamespaceMapping - the mappings to addthisProvides an Iterator over all the nodes of this GPathResult using a depth-first traversal.
Iterator of (depth-first) ordered GPathResultsSupports the subscript operator for a GPathResult.
def text = """
<characterList>
<character/>
<character>
<name>Gromit</name>
</character>
</characterList>"""
GPathResult characterList = new XmlSlurper().parseText(text)
assert characterList.character[1].name == 'Gromit'
index - an indexSupports the range subscript operator for a GPathResult.
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 getReturns the specified Property of this GPathResult.
Realizes the follow shortcuts:
'..' for parent()
'*' for children()
'**' for depthFirst()
'@' for attribute access
property - the Property to fetch Returns true if the GPathResult is empty, i.e. if, and only if, size() is 0.
Overloads the left shift operator to provide an easy way to lazily append Objects to this GPathResult.
newValue - the Object to appendthisCreates a list of objects representing this GPathResult.
Returns the namespace mapped to the specified prefix.
prefix - the prefix lookupReturns as GPathResult with the parent nodes of the current GPathResult
this for the rootLazily adds the specified Object to this GPathResult.
newValue - the Object to addthisReturns the parent of this GPathResult. If this GPathResult has no parent the GPathResult itself is returned. This is no navigation in the XML tree. It is backtracking on the GPath expression chain. It is the behavior of parent() prior to 2.2.0. Backtracking on '..' actually goes down one level in the tree again. find() and findAll() are popped along with the level they have been applied to.
thisReplaces the MetaClass of this GPathResult.
metaClass - the new MetaClassReplaces the specified property of this GPathResult with a new value.
property - the property of this GPathResult to replacenewValue - the new value of the propertyReturns the size of this GPathResult.
Converts the text of this GPathResult to a BigDecimal object.
BigDecimalConverts the text of this GPathResult to a BigInteger object.
BigIntegerConverts the text of this GPathResult to a Boolean object.
BooleanConverts the text of this GPathResult to a Double object.
DoubleConverts the text of this GPathResult to a Float object.
FloatConverts the text of this GPathResult to a Integer object.
IntegerConverts the text of this GPathResult to a Long object.
LongReturns the text of this GPathResult.
StringConverts the text of this GPathResult to a URI object.
URIConverts the text of this GPathResult to a URL object.
URLCopyright © 2003-2014 The Codehaus. All rights reserved.