Top Description Fields Constructors Methods
groovy.util.slurpersupport

public abstract Class GPathResult

extends GroovyObjectSupport
implements Writable, Buildable, Iterable
Class Inheritance
All Implemented Interfaces
java.lang.Iterable, groovy.lang.Buildable, groovy.lang.Writable
Known Direct Subclasses
groovy.util.slurpersupport.NoChildren, groovy.util.slurpersupport.NodeChild, groovy.util.slurpersupport.NodeChildren, groovy.util.slurpersupport.Attribute
Annotations
@Deprecated
Imports
groovy.lang.Buildable, .Closure, .DelegatingMetaClass, .GString, .GroovyObject, .GroovyObjectSupport, .IntRange, .MetaClass, .Writable, org.codehaus.groovy.runtime.DefaultGroovyMethods, .ResourceGroovyMethods, .StringGroovyMethods, java.math.BigDecimal, .BigInteger, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, java.util.ArrayList, .HashMap, .Iterator, .LinkedList, .List, .Map, .Stack

Deprecated

Base class for representing lazy evaluated GPath expressions.

Field Summary

Modifier and TypeField and Description
protected final String
protected final Map<K, V>
protected final String
protected final Map<String, String>
protected final GPathResult
parent

Deprecated as a consequence of GPathResult being deprecated.

Constructor Summary

AccessConstructor and Description
public
GPathResult(final GPathResult
the GPathResult prior to the application of the expression creating this GPathResult
parent
,
final String
if the GPathResult corresponds to something with a name, e.g. a node
name
,
final String
the namespace prefix if any
namespacePrefix
,
final Map<String, String>
the known tag to namespace mappings
namespaceTagHints
)

Deprecated as a consequence of GPathResult being deprecated.
Creates a new GPathResult named name with the parent parent, the namespacePrefix namespacePrefix and the namespaceTagHints specified in the namespaceTagHints Map.

Method Summary

Modifier and TypeMethod and Description
protected abstract void
appendNode(Object newValue)

public Iterator<E>

Returns:

the Iterator of (breadth-first) ordered GPathResults
breadthFirst
()

Provides an Iterator over all the nodes of this GPathResult using a breadth-first traversal.

public abstract Iterator<E>

Returns:

an iterator over the child nodes of this GPathResult
childNodes
()

Returns an iterator over the child nodes of this GPathResult.

public GPathResult

Returns:

the children of this GPathResult
children
()

Deprecated as a consequence of GPathResult being deprecated.
Returns the children of this GPathResult as a GPathResult object.
protected Iterator<E>
public GPathResult

Returns:

this
declareNamespace
(final Map<K, V>
the mappings to add
newNamespaceMapping
)

Deprecated as a consequence of GPathResult being deprecated.
Adds the specified map of prefix to namespace mappings to this GPathResult.
public Iterator<E>

Returns:

the Iterator of (depth-first) ordered GPathResults
depthFirst
()

Provides an Iterator over all the nodes of this GPathResult using a depth-first traversal.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public abstract GPathResult

Returns:

the first child matching the closure
find
(Closure<V>
a closure to filters the children of this GPathResult
closure
)

Deprecated as a consequence of GPathResult being deprecated.
Returns the first child of this GPathResult matching the condition(s) specified in the passed closure.
public abstract GPathResult

Returns:

the children matching the closure
findAll
(Closure<V>
a closure to filters the children of this GPathResult
closure
)

Deprecated as a consequence of GPathResult being deprecated.
Returns the children of this GPathResult matching the condition(s) specified in the passed closure.
public Object

Returns:

the value at the given index
getAt
(final int
an index
index
)

Supports the subscript operator for a GPathResult.

public Object

Returns:

a new list based on range borders
getAt
(final IntRange
a Range indicating the items to get
range
)

Supports the range subscript operator for a GPathResult.

public Closure<V>

Returns:

the body of this GPathResult, converted to a Closure
getBody
()

Creates a Closure representing the body of this GPathResult.

public Object
getProperty(final String
the Property to fetch
property
)

Overrides default groovy.lang.GroovyObject.getProperty.

Returns the specified Property of this GPathResult.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean

Returns:

true if the GPathResult is empty
isEmpty
()

Returns true if the GPathResult is empty, i.e. if, and only if, size() is 0.

public abstract Iterator<E>
iterator()

Redeclares java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public Object

Returns:

this
leftShift
(final Object
the Object to append
newValue
)

Overloads the left shift operator to provide an easy way to lazily append Objects to this GPathResult.

public List<E>

Returns:

a list representing of this GPathResult
list
()

Creates a list of objects representing this GPathResult.

public String

Returns:

the namespace of the prefix
lookupNamespace
(final String
the prefix lookup
prefix
)

Returns the namespace mapped to the specified prefix.

public String

Returns:

the name of this GPathResult
name
()

Returns the name of this GPathResult.

public abstract Iterator<E>
public GPathResult

Returns:

the parents GPathResult or this for the root
parent
()

Deprecated as a consequence of GPathResult being deprecated.
Returns as GPathResult with the parent nodes of the current GPathResult
public abstract GPathResult

Returns:

the parents of this GPathResult
parents
()

Deprecated as a consequence of GPathResult being deprecated.
Returns the parents of this GPathResult as a GPathResult.
public Object

Returns:

this
plus
(final Object
the Object to add
newValue
)

Lazily adds the specified Object to this GPathResult.

public GPathResult

Returns:

the parent or this
pop
()

Deprecated as a consequence of GPathResult being deprecated.
Returns the parent of this GPathResult.
public void
putAt(final int
an index
index
,
final Object
the value to put at the given index
newValue
)

A helper method to allow GPathResults to work with subscript operators

protected abstract void
replaceBody(Object newValue)

protected abstract void
replaceNode(Closure<V> newValue)

public void
setMetaClass(final MetaClass
the new MetaClass
metaClass
)

Overrides groovy.lang.GroovyObjectSupport.setMetaClass.

Implements groovy.lang.GroovyObject.setMetaClass.

Replaces the MetaClass of this GPathResult.
public void
setProperty(final String
the property of this GPathResult to replace
property
,
final Object
the new value of the property
newValue
)

Overrides default groovy.lang.GroovyObject.setProperty.

Replaces the specified property of this GPathResult with a new value.
public abstract int

Returns:

the size of this GPathResult
size
()

Returns the size of this GPathResult.

public abstract String

Returns:

the text of this GPathResult
text
()

Returns the text of this GPathResult as a String.

private boolean
public BigDecimal

Returns:

the GPathResult, converted to a BigDecimal
toBigDecimal
()

Converts the text of this GPathResult to a BigDecimal object.

public BigInteger

Returns:

the GPathResult, converted to a BigInteger
toBigInteger
()

Converts the text of this GPathResult to a BigInteger object.

public Boolean

Returns:

the GPathResult, converted to a Boolean
toBoolean
()

Converts the text of this GPathResult to a Boolean object.

public Double

Returns:

the GPathResult, converted to a Double
toDouble
()

Converts the text of this GPathResult to a Double object.

public Float

Returns:

the GPathResult, converted to a Float
toFloat
()

Converts the text of this GPathResult to a Float object.

public Integer

Returns:

the GPathResult, converted to a Integer
toInteger
()

Converts the text of this GPathResult to a Integer object.

public Long

Returns:

the GPathResult, converted to a Long
toLong
()

Converts the text of this GPathResult to a Long object.

public String

Returns:

the GPathResult, converted to a String
toString
()

Overrides java.lang.Object.toString.

Returns the text of this GPathResult.
public URI

Returns:

the GPathResult, converted to a URI
toURI
()

Converts the text of this GPathResult to a URI object.

public URL

Returns:

the GPathResult, converted to a URL
toURL
()

Converts the text of this GPathResult to a URL object.

Inherited from groovy.lang.GroovyObjectSupport:
getMetaClass

Field Detail

nameback to summary
protected final String name
namespaceMapback to summary
protected final Map<K, V> namespaceMap
namespacePrefixback to summary
protected final String namespacePrefix
namespaceTagHintsback to summary
protected final Map<String, String> namespaceTagHints
parentback to summary
protected final GPathResult parent

Deprecated

as a consequence of GPathResult being deprecated. See corresponding docs for further information.

Constructor Detail

GPathResultback to summary
public GPathResult(final GPathResult parent, final String name, final String namespacePrefix, final Map<String, String> namespaceTagHints)

Deprecated

as a consequence of GPathResult being deprecated. See corresponding docs for further information.

Creates a new GPathResult named name with the parent parent, the namespacePrefix namespacePrefix and the namespaceTagHints specified in the namespaceTagHints Map.

Parameters
parent:GPathResult

the GPathResult prior to the application of the expression creating this GPathResult

name:String

if the GPathResult corresponds to something with a name, e.g. a node

namespacePrefix:String

the namespace prefix if any

namespaceTagHints:Map<String, String>

the known tag to namespace mappings

Method Detail

appendNodeback to summary
protected abstract void appendNode(Object newValue)
breadthFirstback to summary
public Iterator<E> breadthFirst()

Provides an Iterator over all the nodes of this GPathResult using a breadth-first traversal.

Returns:Iterator<E>

the Iterator of (breadth-first) ordered GPathResults

childNodesback to summary
public abstract Iterator<E> childNodes()

Returns an iterator over the child nodes of this GPathResult.

Returns:Iterator<E>

an iterator over the child nodes of this GPathResult

childrenback to summary
public GPathResult children()

Deprecated

as a consequence of GPathResult being deprecated. See corresponding docs for further information.

Returns the children of this GPathResult as a GPathResult object.

Returns:GPathResult

the children of this GPathResult

createIteratorback to summary
protected Iterator<E> createIterator(final Object obj)
declareNamespaceback to summary
public GPathResult declareNamespace(final Map<K, V> newNamespaceMapping)

Deprecated

as a consequence of GPathResult being deprecated. See corresponding docs for further information.

Adds the specified map of prefix to namespace mappings to this GPathResult. Already existing prefixes are overwritten.

Parameters
newNamespaceMapping:Map<K, V>

the mappings to add

Returns:GPathResult

this

depthFirstback to summary
public Iterator<E> depthFirst()

Provides an Iterator over all the nodes of this GPathResult using a depth-first traversal.

Returns:Iterator<E>

the Iterator of (depth-first) ordered GPathResults

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
findback to summary
public abstract GPathResult find(Closure<V> closure)

Deprecated

as a consequence of GPathResult being deprecated. See corresponding docs for further information.

Returns the first child of this GPathResult matching the condition(s) specified in the passed closure.

Parameters
closure:Closure<V>

a closure to filters the children of this GPathResult

Returns:GPathResult

the first child matching the closure

findAllback to summary
public abstract GPathResult findAll(Closure<V> closure)

Deprecated

as a consequence of GPathResult being deprecated. See corresponding docs for further information.

Returns the children of this GPathResult matching the condition(s) specified in the passed closure.

Parameters
closure:Closure<V>

a closure to filters the children of this GPathResult

Returns:GPathResult

the children matching the closure

getAtback to summary
public Object getAt(final int index)

Supports 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'
Parameters
index:int

an index

Returns:Object

the value at the given index

getAtback to summary
public Object getAt(final IntRange range)

Supports 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'
Parameters
range:IntRange

a Range indicating the items to get

Returns:Object

a new list based on range borders

getBodyback to summary
public Closure<V> getBody()

Creates a Closure representing the body of this GPathResult.

Returns:Closure<V>

the body of this GPathResult, converted to a Closure

getPropertyback to summary
public Object getProperty(final String property)

Overrides default groovy.lang.GroovyObject.getProperty.

Returns the specified Property of this GPathResult.

Realizes the follow shortcuts:

  • '..' for parent()
  • '*' for children()
  • '**' for depthFirst()
  • '@' for attribute access
Parameters
property:String

the Property to fetch

Returns:Object

Doc from groovy.lang.GroovyObject.getProperty.

the given property

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Returns true if the GPathResult is empty, i.e. if, and only if, size() is 0.

Returns:boolean

true if the GPathResult is empty

iteratorback to summary
public abstract Iterator<E> iterator()

Redeclares java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<E>

an Iterator.

leftShiftback to summary
public Object leftShift(final Object newValue)

Overloads the left shift operator to provide an easy way to lazily append Objects to this GPathResult.

Parameters
newValue:Object

the Object to append

Returns:Object

this

listback to summary
public List<E> list()

Creates a list of objects representing this GPathResult.

Returns:List<E>

a list representing of this GPathResult

lookupNamespaceback to summary
public String lookupNamespace(final String prefix)

Returns the namespace mapped to the specified prefix.

Parameters
prefix:String

the prefix lookup

Returns:String

the namespace of the prefix

nameback to summary
public String name()

Returns the name of this GPathResult.

Returns:String

the name of this GPathResult

nodeIteratorback to summary
public abstract Iterator<E> nodeIterator()
parentback to summary
public GPathResult parent()

Deprecated

as a consequence of GPathResult being deprecated. See corresponding docs for further information.

Returns as GPathResult with the parent nodes of the current GPathResult

Returns:GPathResult

the parents GPathResult or this for the root

parentsback to summary
public abstract GPathResult parents()

Deprecated

as a consequence of GPathResult being deprecated. See corresponding docs for further information.

Returns the parents of this GPathResult as a GPathResult.

Warning

The subclasses of this package do not implement this method yet.

Returns:GPathResult

the parents of this GPathResult

plusback to summary
public Object plus(final Object newValue)

Lazily adds the specified Object to this GPathResult.

Parameters
newValue:Object

the Object to add

Returns:Object

this

popback to summary
public GPathResult pop()

Deprecated

as a consequence of GPathResult being deprecated. See corresponding docs for further information.

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.

Returns:GPathResult

the parent or this

putAtback to summary
public void putAt(final int index, final Object newValue)

A helper method to allow GPathResults to work with subscript operators

Parameters
index:int

an index

newValue:Object

the value to put at the given index

replaceBodyback to summary
protected abstract void replaceBody(Object newValue)
replaceNodeback to summary
protected abstract void replaceNode(Closure<V> newValue)
setMetaClassback to summary
public void setMetaClass(final MetaClass metaClass)

Overrides groovy.lang.GroovyObjectSupport.setMetaClass.

Implements groovy.lang.GroovyObject.setMetaClass.

Replaces the MetaClass of this GPathResult.

Parameters
metaClass:MetaClass

the new MetaClass

Annotations
@Override
setPropertyback to summary
public void setProperty(final String property, final Object newValue)

Overrides default groovy.lang.GroovyObject.setProperty.

Replaces the specified property of this GPathResult with a new value.

Parameters
property:String

the property of this GPathResult to replace

newValue:Object

the new value of the property

sizeback to summary
public abstract int size()

Returns the size of this GPathResult.

Returns:int

the size of this GPathResult

textback to summary
public abstract String text()

Returns the text of this GPathResult as a String.

Returns:String

the text of this GPathResult

textIsEmptyOrNullback to summary
private boolean textIsEmptyOrNull()
toBigDecimalback to summary
public BigDecimal toBigDecimal()

Converts the text of this GPathResult to a BigDecimal object.

Returns:BigDecimal

the GPathResult, converted to a BigDecimal

toBigIntegerback to summary
public BigInteger toBigInteger()

Converts the text of this GPathResult to a BigInteger object.

Returns:BigInteger

the GPathResult, converted to a BigInteger

toBooleanback to summary
public Boolean toBoolean()

Converts the text of this GPathResult to a Boolean object.

Returns:Boolean

the GPathResult, converted to a Boolean

toDoubleback to summary
public Double toDouble()

Converts the text of this GPathResult to a Double object.

Returns:Double

the GPathResult, converted to a Double

toFloatback to summary
public Float toFloat()

Converts the text of this GPathResult to a Float object.

Returns:Float

the GPathResult, converted to a Float

toIntegerback to summary
public Integer toInteger()

Converts the text of this GPathResult to a Integer object.

Returns:Integer

the GPathResult, converted to a Integer

toLongback to summary
public Long toLong()

Converts the text of this GPathResult to a Long object.

Returns:Long

the GPathResult, converted to a Long

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the text of this GPathResult.

Returns:String

the GPathResult, converted to a String

toURIback to summary
public URI toURI() throws URISyntaxException

Converts the text of this GPathResult to a URI object.

Returns:URI

the GPathResult, converted to a URI

toURLback to summary
public URL toURL() throws MalformedURLException

Converts the text of this GPathResult to a URL object.

Returns:URL

the GPathResult, converted to a URL