@Deprecated public abstract class GPathResult extends GroovyObjectSupport implements Buildable, Writable, Iterable
Base class for representing lazy evaluated GPath expressions.
Modifiers | Name | Description |
---|---|---|
protected String |
name |
|
protected Map |
namespaceMap |
|
protected String |
namespacePrefix |
|
protected Map<String, String> |
namespaceTagHints |
|
protected GPathResult |
parent |
Constructor and description |
---|
GPathResult
(GPathResult parent, String name, String namespacePrefix, Map<String, String> namespaceTagHints) Creates a new GPathResult named name with the parent parent ,
the namespacePrefix namespacePrefix and the namespaceTagHints specified in
the namespaceTagHints Map. |
Type Params | Return Type | Name and description |
---|---|---|
|
protected abstract void |
appendNode(Object newValue) |
|
public Iterator |
breadthFirst() Provides an Iterator over all the nodes of this GPathResult using a breadth-first traversal. |
|
public abstract Iterator |
childNodes() Returns an iterator over the child nodes of this GPathResult. |
|
public GPathResult |
children() Returns the children of this GPathResult as a GPathResult object. |
|
protected Iterator |
createIterator(Object obj) |
|
public GPathResult |
declareNamespace(Map newNamespaceMapping) Adds the specified map of prefix to namespace mappings to this GPathResult. |
|
public Iterator |
depthFirst() Provides an Iterator over all the nodes of this GPathResult using a depth-first traversal. |
|
public void |
doCall(Object[] args) |
|
public void |
doCall(Object[] args) |
|
public boolean |
equals(Object obj) |
|
public abstract GPathResult |
find(Closure closure) Returns the first child of this GPathResult matching the condition(s) specified in the passed closure. |
|
public abstract GPathResult |
findAll(Closure closure) Returns the children of this GPathResult matching the condition(s) specified in the passed closure. |
|
public Object |
getAt(int index) Supports the subscript operator for a GPathResult. |
|
public Object |
getAt(IntRange range) Supports the range subscript operator for a GPathResult. |
|
public Object |
getAttribute(Object object, String attribute) |
|
public Closure |
getBody() Creates a Closure representing the body of this GPathResult. |
|
public Object |
getProperty(String property) Returns the specified Property of this GPathResult. |
|
public boolean |
hasNext() |
|
public boolean |
hasNext() |
|
public boolean |
hasNext() |
|
public int |
hashCode() |
|
public boolean |
isEmpty() Returns true if the GPathResult is empty, i.e. if, and only if, size() is 0. |
|
public abstract Iterator |
iterator() |
|
public Object |
leftShift(Object newValue) Overloads the left shift operator to provide an easy way to lazily append Objects to this GPathResult. |
|
public List |
list() Creates a list of objects representing this GPathResult. |
|
public String |
lookupNamespace(String prefix) Returns the namespace mapped to the specified prefix. |
|
public String |
name() Returns the name of this GPathResult. |
|
public Object |
next() |
|
public Object |
next() |
|
public Object |
next() |
|
public abstract Iterator |
nodeIterator() |
|
public GPathResult |
parent() Returns as GPathResult with the parent nodes of the current GPathResult |
|
public abstract GPathResult |
parents() Returns the parents of this GPathResult as a GPathResult .
|
|
public Object |
plus(Object newValue) Lazily adds the specified Object to this GPathResult. |
|
public GPathResult |
pop() Returns the parent of this GPathResult. |
|
public void |
putAt(int index, Object newValue) A helper method to allow GPathResults to work with subscript operators |
|
public void |
remove() |
|
public void |
remove() |
|
public void |
remove() |
|
protected abstract void |
replaceBody(Object newValue) |
|
protected abstract void |
replaceNode(Closure newValue) |
|
public void |
setAttribute(Object object, String attribute, Object newValue) |
|
public void |
setMetaClass(MetaClass metaClass) Replaces the MetaClass of this GPathResult. |
|
public void |
setProperty(String property, Object newValue) Replaces the specified property of this GPathResult with a new value. |
|
public abstract int |
size() Returns the size of this GPathResult. |
|
public abstract String |
text() Returns the text of this GPathResult as a String . |
|
public BigDecimal |
toBigDecimal() Converts the text of this GPathResult to a BigDecimal object. |
|
public BigInteger |
toBigInteger() Converts the text of this GPathResult to a BigInteger object. |
|
public Boolean |
toBoolean() Converts the text of this GPathResult to a Boolean object. |
|
public Double |
toDouble() Converts the text of this GPathResult to a Double object. |
|
public Float |
toFloat() Converts the text of this GPathResult to a Float object. |
|
public Integer |
toInteger() Converts the text of this GPathResult to a Integer object. |
|
public Long |
toLong() Converts the text of this GPathResult to a Long object. |
|
public String |
toString() Returns the text of this GPathResult. |
|
public URI |
toURI() Converts the text of this GPathResult to a URI object. |
|
public URL |
toURL() Converts the text of this GPathResult to a URL object. |
Methods inherited from class | Name |
---|---|
class GroovyObjectSupport |
getMetaClass, setMetaClass |
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 an iterator over the child nodes of this GPathResult.
Returns 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 addthis
Provides an Iterator over all the nodes of this GPathResult using a depth-first traversal.
Iterator
of (depth-first) ordered GPathResultsReturns the first child of this GPathResult matching the condition(s) specified in the passed closure.
closure
- a closure to filters the children of this GPathResultReturns the children of this GPathResult matching the condition(s) specified in the passed closure.
closure
- a closure to filters the children of this GPathResultSupports the subscript operator for a GPathResult.
import groovy.util.slurpersupport.* 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.
import groovy.util.slurpersupport.* 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 getCreates a Closure representing the body of this GPathResult.
Closure
Returns 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 appendthis
Creates a list of objects representing this GPathResult.
Returns the namespace mapped to the specified prefix.
prefix
- the prefix lookupReturns the name of this GPathResult.
Returns as GPathResult with the parent nodes of the current GPathResult
this
for the root Returns the parents of this GPathResult as a GPathResult
.
Warning: The subclasses of this package do not implement this method yet.
Lazily adds the specified Object to this GPathResult.
newValue
- the Object to addthis
Returns 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.
this
A helper method to allow GPathResults to work with subscript operators
index
- an indexnewValue
- the value to put at the given indexReplaces 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.
Returns the text of this GPathResult as a String
.
Converts the text of this GPathResult to a BigDecimal object.
BigDecimal
Converts the text of this GPathResult to a BigInteger object.
BigInteger
Converts the text of this GPathResult to a Boolean object.
Boolean
Converts the text of this GPathResult to a Double object.
Double
Converts the text of this GPathResult to a Float object.
Float
Converts the text of this GPathResult to a Integer object.
Integer
Converts the text of this GPathResult to a Long object.
Long
Returns the text of this GPathResult.
String
Converts the text of this GPathResult to a URI object.
URI
Converts the text of this GPathResult to a URL object.
URL
Copyright © 2003-2024 The Apache Software Foundation. All rights reserved.