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.Stringnameprotected java.util.MapnamespaceMapprotected java.lang.StringnamespacePrefixprotected java.util.Map<java.lang.String,java.lang.String>namespaceTagHintsprotected GPathResultparent
-
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 voidappendNode(java.lang.Object newValue)java.util.IteratorbreadthFirst()An iterator useful for traversing XML documents/fragments in breadth-first order.abstract java.util.IteratorchildNodes()GPathResultchildren()GPathResultdeclareNamespace(java.util.Map newNamespaceMapping)java.util.IteratordepthFirst()booleanequals(java.lang.Object obj)abstract GPathResultfind(Closure closure)abstract GPathResultfindAll(Closure closure)java.lang.ObjectgetAt(int index)java.lang.ObjectgetAt(IntRange range)ClosuregetBody()java.lang.ObjectgetProperty(java.lang.String property)Retrieves a property value.booleanisEmpty()abstract java.util.Iteratoriterator()java.lang.ObjectleftShift(java.lang.Object newValue)java.util.Listlist()java.lang.StringlookupNamespace(java.lang.String prefix)java.lang.Stringname()abstract java.util.IteratornodeIterator()GPathResultparent()abstract GPathResultparents()java.lang.Objectplus(java.lang.Object newValue)voidputAt(int index, java.lang.Object newValue)protected abstract voidreplaceBody(java.lang.Object newValue)protected abstract voidreplaceNode(Closure newValue)voidsetMetaClass(MetaClass metaClass)Allows the MetaClass to be replaced with a derived implementation.voidsetProperty(java.lang.String property, java.lang.Object newValue)Sets the given property to the new value.abstract intsize()abstract java.lang.Stringtext()java.math.BigDecimaltoBigDecimal()java.math.BigIntegertoBigInteger()java.lang.BooleantoBoolean()java.lang.DoubletoDouble()java.lang.FloattoFloat()java.lang.IntegertoInteger()java.lang.LongtoLong()java.lang.StringtoString()java.net.URItoURI()java.net.URLtoURL()-
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:GroovyObjectAllows the MetaClass to be replaced with a derived implementation.- Specified by:
setMetaClassin interfaceGroovyObject- Overrides:
setMetaClassin classGroovyObjectSupport- Parameters:
metaClass- the new metaclass
-
getProperty
public java.lang.Object getProperty(java.lang.String property)
Description copied from interface:GroovyObjectRetrieves a property value.- Specified by:
getPropertyin interfaceGroovyObject- Overrides:
getPropertyin 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:GroovyObjectSets the given property to the new value.- Specified by:
setPropertyin interfaceGroovyObject- Overrides:
setPropertyin 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:
toStringin 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:
equalsin 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()
-
-