Package groovy.util.slurpersupport
Class GPathResult
- java.lang.Object
-
- groovy.lang.GroovyObjectSupport
-
- groovy.util.slurpersupport.GPathResult
-
- All Implemented Interfaces:
Buildable
,GroovyObject
,Writable
- Direct Known Subclasses:
Attribute
,FilteredAttributes
,FilteredNodeChildren
,NoChildren
,NodeChild
public abstract class GPathResult extends GroovyObjectSupport implements Writable, Buildable
Base class for representing lazy evaluated GPath expressions.- Author:
- John Wilson
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
name
protected java.util.Map
namespaceMap
protected java.lang.String
namespacePrefix
protected java.util.Map<java.lang.String,java.lang.String>
namespaceTagHints
protected GPathResult
parent
-
Constructor Summary
Constructors Constructor Description GPathResult(GPathResult parent, java.lang.String name, java.lang.String namespacePrefix, java.util.Map<java.lang.String,java.lang.String> namespaceTagHints)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
appendNode(java.lang.Object newValue)
java.util.Iterator
breadthFirst()
An iterator useful for traversing XML documents/fragments in breadth-first order.abstract java.util.Iterator
childNodes()
GPathResult
children()
GPathResult
declareNamespace(java.util.Map newNamespaceMapping)
java.util.Iterator
depthFirst()
boolean
equals(java.lang.Object obj)
abstract GPathResult
find(Closure closure)
abstract GPathResult
findAll(Closure closure)
java.lang.Object
getAt(int index)
java.lang.Object
getAt(IntRange range)
Closure
getBody()
java.lang.Object
getProperty(java.lang.String property)
Retrieves a property value.boolean
isEmpty()
abstract java.util.Iterator
iterator()
java.lang.Object
leftShift(java.lang.Object newValue)
java.util.List
list()
java.lang.String
lookupNamespace(java.lang.String prefix)
java.lang.String
name()
abstract java.util.Iterator
nodeIterator()
GPathResult
parent()
abstract GPathResult
parents()
java.lang.Object
plus(java.lang.Object newValue)
void
putAt(int index, java.lang.Object newValue)
protected abstract void
replaceBody(java.lang.Object newValue)
protected abstract void
replaceNode(Closure newValue)
void
setMetaClass(MetaClass metaClass)
Allows the MetaClass to be replaced with a derived implementation.void
setProperty(java.lang.String property, java.lang.Object newValue)
Sets the given property to the new value.abstract int
size()
abstract java.lang.String
text()
java.math.BigDecimal
toBigDecimal()
java.math.BigInteger
toBigInteger()
java.lang.Boolean
toBoolean()
java.lang.Double
toDouble()
java.lang.Float
toFloat()
java.lang.Integer
toInteger()
java.lang.Long
toLong()
java.lang.String
toString()
java.net.URI
toURI()
java.net.URL
toURL()
-
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, invokeMethod
-
-
-
-
Field Detail
-
parent
protected final GPathResult parent
-
name
protected final java.lang.String name
-
namespacePrefix
protected final java.lang.String namespacePrefix
-
namespaceMap
protected final java.util.Map namespaceMap
-
namespaceTagHints
protected final java.util.Map<java.lang.String,java.lang.String> namespaceTagHints
-
-
Constructor Detail
-
GPathResult
public GPathResult(GPathResult parent, java.lang.String name, java.lang.String namespacePrefix, java.util.Map<java.lang.String,java.lang.String> namespaceTagHints)
- Parameters:
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
-
setMetaClass
public void setMetaClass(MetaClass metaClass)
Description copied from interface:GroovyObject
Allows the MetaClass to be replaced with a derived implementation.- Specified by:
setMetaClass
in interfaceGroovyObject
- Overrides:
setMetaClass
in classGroovyObjectSupport
- Parameters:
metaClass
- the new metaclass
-
getProperty
public java.lang.Object getProperty(java.lang.String property)
Description copied from interface:GroovyObject
Retrieves a property value.- Specified by:
getProperty
in interfaceGroovyObject
- Overrides:
getProperty
in classGroovyObjectSupport
- Parameters:
property
- the name of the property of interest- Returns:
- the given property
-
setProperty
public void setProperty(java.lang.String property, java.lang.Object newValue)
Description copied from interface:GroovyObject
Sets the given property to the new value.- Specified by:
setProperty
in interfaceGroovyObject
- Overrides:
setProperty
in classGroovyObjectSupport
- Parameters:
property
- the name of the property of interestnewValue
- the new value for the property
-
leftShift
public java.lang.Object leftShift(java.lang.Object newValue)
-
plus
public java.lang.Object plus(java.lang.Object newValue)
-
replaceNode
protected abstract void replaceNode(Closure newValue)
-
replaceBody
protected abstract void replaceBody(java.lang.Object newValue)
-
appendNode
protected abstract void appendNode(java.lang.Object newValue)
-
name
public java.lang.String name()
-
parent
public GPathResult parent()
-
children
public GPathResult children()
-
lookupNamespace
public java.lang.String lookupNamespace(java.lang.String prefix)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toInteger
public java.lang.Integer toInteger()
-
toLong
public java.lang.Long toLong()
-
toFloat
public java.lang.Float toFloat()
-
toDouble
public java.lang.Double toDouble()
-
toBigDecimal
public java.math.BigDecimal toBigDecimal()
-
toBigInteger
public java.math.BigInteger toBigInteger()
-
toURL
public java.net.URL toURL() throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
toURI
public java.net.URI toURI() throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
-
toBoolean
public java.lang.Boolean toBoolean()
-
declareNamespace
public GPathResult declareNamespace(java.util.Map newNamespaceMapping)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getAt
public java.lang.Object getAt(int index)
-
getAt
public java.lang.Object getAt(IntRange range)
-
putAt
public void putAt(int index, java.lang.Object newValue)
-
depthFirst
public java.util.Iterator depthFirst()
-
breadthFirst
public java.util.Iterator breadthFirst()
An iterator useful for traversing XML documents/fragments in breadth-first order.- Returns:
- Iterator the iterator of GPathResult objects
-
list
public java.util.List list()
-
isEmpty
public boolean isEmpty()
-
getBody
public Closure getBody()
-
size
public abstract int size()
-
text
public abstract java.lang.String text()
-
parents
public abstract GPathResult parents()
-
childNodes
public abstract java.util.Iterator childNodes()
-
iterator
public abstract java.util.Iterator iterator()
-
find
public abstract GPathResult find(Closure closure)
-
findAll
public abstract GPathResult findAll(Closure closure)
-
nodeIterator
public abstract java.util.Iterator nodeIterator()
-
-