Groovy Documentation

groovy.util.slurpersupport
[Java] Class GPathResult

java.lang.Object
  groovy.lang.GroovyObjectSupport
      groovy.util.slurpersupport.GPathResult
All Implemented Interfaces:
Buildable, Writable

public abstract class GPathResult
extends GroovyObjectSupport

Base class for representing lazy evaluated GPath expressions.

Authors:
John Wilson


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 name with the parent parent, the namespacePrefix namespacePrefix and the namespaceTagHints specified in the namespaceTagHints Map.

 
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, size() is 0.

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

name

protected final java.lang.String name


namespaceMap

protected final java.util.Map namespaceMap


namespacePrefix

protected final java.lang.String namespacePrefix


namespaceTagHints

protected final java.util.Map namespaceTagHints


parent

protected final GPathResult parent


 
Constructor Detail

GPathResult

public GPathResult(GPathResult parent, java.lang.String name, java.lang.String namespacePrefix, java.util.Map namespaceTagHints)
Creates a new GPathResult named name with the parent parent, the namespacePrefix namespacePrefix and the namespaceTagHints specified in the namespaceTagHints Map.
Parameters:
parent - the GPathResult prior to the application of the expression creating this GPathResult
name - if the GPathResult corresponds to something with a name, e.g. a node
namespacePrefix - the namespace prefix if any
namespaceTagHints - the known tag to namespace mappings


 
Method Detail

appendNode

protected void appendNode(java.lang.Object newValue)


breadthFirst

public java.util.Iterator breadthFirst()
Provides an Iterator over all the nodes of this GPathResult using a breadth-first traversal.
Returns:
the Iterator of (breadth-first) ordered GPathResults


childNodes

public java.util.Iterator childNodes()


children

public GPathResult children()
Returns the children of this GPathResult as a GPathResult object.
Returns:
the children of this GPathResult


declareNamespace

public GPathResult declareNamespace(java.util.Map newNamespaceMapping)
Adds the specified map of prefix to namespace mappings to this GPathResult. Already existing prefixes are overwritten.
Parameters:
newNamespaceMapping - the mappings to add
Returns:
this


depthFirst

public java.util.Iterator depthFirst()
Provides an Iterator over all the nodes of this GPathResult using a depth-first traversal.
Returns:
the Iterator of (depth-first) ordered GPathResults


equals

public boolean equals(java.lang.Object obj)


find

public GPathResult find(Closure closure)


findAll

public GPathResult findAll(Closure closure)


getAt

public java.lang.Object getAt(int index)
Supports 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'
 
Parameters:
index - an index
Returns:
the value at the given index


getAt

public java.lang.Object getAt(IntRange range)
Supports 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'
 
Parameters:
range - a Range indicating the items to get
Returns:
a new list based on range borders


getBody

public Closure getBody()


getProperty

public java.lang.Object getProperty(java.lang.String property)
Returns the specified Property of this GPathResult.

Realizes the follow shortcuts:

Parameters:
property - the Property to fetch


isEmpty

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


iterator

public java.util.Iterator iterator()


leftShift

public 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.
Parameters:
newValue - the Object to append
Returns:
this


list

public java.util.List list()
Creates a list of objects representing this GPathResult.
Returns:
a list representing of this GPathResult


lookupNamespace

public java.lang.String lookupNamespace(java.lang.String prefix)
Returns the namespace mapped to the specified prefix.
Parameters:
prefix - the prefix lookup
Returns:
the namespace of the prefix


name

public java.lang.String name()


nodeIterator

public java.util.Iterator nodeIterator()


parent

public GPathResult parent()
Returns the parent of this GPathResult. If this GPathResult has no parent the GPathResult itself is returned.
Returns:
the parent or this


parents

public GPathResult parents()


plus

public java.lang.Object plus(java.lang.Object newValue)
Lazily adds the specified Object to this GPathResult.
Parameters:
newValue - the Object to add
Returns:
this


putAt

public void putAt(int index, java.lang.Object newValue)


replaceBody

protected void replaceBody(java.lang.Object newValue)


replaceNode

protected void replaceNode(Closure newValue)


setMetaClass

@Override
public void setMetaClass(MetaClass metaClass)
Replaces the MetaClass of this GPathResult.
Parameters:
metaClass - the new MetaClass


setProperty

public void setProperty(java.lang.String property, java.lang.Object newValue)
Replaces the specified property of this GPathResult with a new value.
Parameters:
property - the property of this GPathResult to replace
newValue - the new value of the property


size

public int size()
Returns the size of this GPathResult.
Returns:
the size of this GPathResult


text

public java.lang.String text()


toBigDecimal

public java.math.BigDecimal toBigDecimal()
Converts the text of this GPathResult to a BigDecimal object.
Returns:
the GPathResult, converted to a BigDecimal


toBigInteger

public java.math.BigInteger toBigInteger()
Converts the text of this GPathResult to a BigInteger object.
Returns:
the GPathResult, converted to a BigInteger


toBoolean

public java.lang.Boolean toBoolean()
Converts the text of this GPathResult to a Boolean object.
Returns:
the GPathResult, converted to a Boolean


toDouble

public java.lang.Double toDouble()
Converts the text of this GPathResult to a Double object.
Returns:
the GPathResult, converted to a Double


toFloat

public java.lang.Float toFloat()
Converts the text of this GPathResult to a Float object.
Returns:
the GPathResult, converted to a Float


toInteger

public java.lang.Integer toInteger()
Converts the text of this GPathResult to a Integer object.
Returns:
the GPathResult, converted to a Integer


toLong

public java.lang.Long toLong()
Converts the text of this GPathResult to a Long object.
Returns:
the GPathResult, converted to a Long


toString

public java.lang.String toString()
Returns the text of this GPathResult.
Returns:
the GPathResult, converted to a String


toURI

public java.net.URI toURI()
Converts the text of this GPathResult to a URI object.
Returns:
the GPathResult, converted to a URI


toURL

public java.net.URL toURL()
Converts the text of this GPathResult to a URL object.
Returns:
the GPathResult, converted to a URL


 

Groovy Documentation