Top Description Fields Constructors Methods
groovy.xml.slurpersupport

public Class NodeChild

extends GPathResult
Class Inheritance
Imports
groovy.lang.Closure, .GroovyObject, .GroovyRuntimeException, org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation, java.io.IOException, .Writer, java.util.Iterator, .List, .Map

Lazy evaluated representation of a child node.

Field Summary

Modifier and TypeField and Description
private final Node
Inherited from groovy.xml.slurpersupport.GPathResult:
namenamespaceMapnamespacePrefixnamespaceTagHintsparent

Constructor Summary

AccessConstructor and Description
public
NodeChild(final Node
a node
node
,
final GPathResult
the GPathResult prior to the application of the expression creating this GPathResult
parent
,
final String
the namespace prefix if any
namespacePrefix
,
final Map<String, String>
the known tag to namespace mappings
namespaceTagHints
)

public
NodeChild(final Node
a node
node
,
final GPathResult
the GPathResult prior to the application of the expression creating this GPathResult
parent
,
final Map<String, String>
the known tag to namespace mappings
namespaceTagHints
)

Method Summary

Modifier and TypeMethod and Description
protected void
public Map<K, V>

Returns:

a map containing all attributes
attributes
()

Returns a map containing all attributes of the Node of this NodeChild.

public void
public Iterator<E>
childNodes()

Implements abstract groovy.xml.slurpersupport.GPathResult.childNodes.

Returns an iterator over the child nodes of this GPathResult.
public GPathResult
find(final Closure<V>
a closure to filters the children of this GPathResult
closure
)

Implements abstract groovy.xml.slurpersupport.GPathResult.find.

Returns the first child of this GPathResult matching the condition(s) specified in the passed closure.
public GPathResult
findAll(final Closure<V>
a closure to filters the children of this GPathResult
closure
)

Implements abstract groovy.xml.slurpersupport.GPathResult.findAll.

Returns the children of this GPathResult matching the condition(s) specified in the passed closure.
public Object
getAt(final int
an index
index
)

Overrides groovy.xml.slurpersupport.GPathResult.getAt.

Supports the subscript operator for a GPathResult.
public Iterator<E>
iterator()

Implements abstract groovy.xml.slurpersupport.GPathResult.iterator.

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public List<String>

Returns:

the list of String values from this node
localText
()

Returns the list of any direct String nodes of this NodeChild.

public String

Returns:

the namespace of this NodeChild
namespaceURI
()

Returns the URI of the namespace of this NodeChild.

public Iterator<E>
public GPathResult
parent()

Overrides groovy.xml.slurpersupport.GPathResult.parent.

Returns as GPathResult with the parent nodes of the current GPathResult
public GPathResult
parents()

Implements abstract groovy.xml.slurpersupport.GPathResult.parents.

Throws a GroovyRuntimeException, because this method is not implemented yet.
protected void
protected void
public int
size()

Implements abstract groovy.xml.slurpersupport.GPathResult.size.

Returns the size of this GPathResult.
public String
text()

Implements abstract groovy.xml.slurpersupport.GPathResult.text.

Returns the text of this GPathResult as a String.
public Writer
writeTo(final Writer
the Writer to which this Writable should output its data.
out
)

Implements groovy.lang.Writable.writeTo.

Writes this object to the given writer.
Inherited from groovy.xml.slurpersupport.GPathResult:
breadthFirstchildrencreateIteratordeclareNamespacedepthFirstequalsgetAtgetBodygetPropertyhashCodeisEmptyleftShiftlistlookupNamespacenamepluspopputAtsetMetaClasssetPropertytoBigDecimaltoBigIntegertoBooleantoDoubletoFloattoIntegertoLongtoStringtoURItoURL

Field Detail

nodeback to summary
private final Node node

Constructor Detail

NodeChildback to summary
public NodeChild(final Node node, final GPathResult parent, final String namespacePrefix, final Map<String, String> namespaceTagHints)
Parameters
node:Node

a node

parent:GPathResult

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

namespacePrefix:String

the namespace prefix if any

namespaceTagHints:Map<String, String>

the known tag to namespace mappings

NodeChildback to summary
public NodeChild(final Node node, final GPathResult parent, final Map<String, String> namespaceTagHints)
Parameters
node:Node

a node

parent:GPathResult

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

namespaceTagHints:Map<String, String>

the known tag to namespace mappings

Method Detail

appendNodeback to summary
protected void appendNode(final Object newValue)

Implements abstract groovy.xml.slurpersupport.GPathResult.appendNode.

attributesback to summary
public Map<K, V> attributes()

Returns a map containing all attributes of the Node of this NodeChild.

Returns:Map<K, V>

a map containing all attributes

buildback to summary
public void build(final GroovyObject builder)

Implements groovy.lang.Buildable.build.

childNodesback to summary
public Iterator<E> childNodes()

Implements abstract groovy.xml.slurpersupport.GPathResult.childNodes.

Doc from groovy.xml.slurpersupport.GPathResult.childNodes.

Returns an iterator over the child nodes of this GPathResult.

Returns:Iterator<E>

an iterator over the child nodes of this GPathResult

findback to summary
public GPathResult find(final Closure<V> closure)

Implements abstract groovy.xml.slurpersupport.GPathResult.find.

Doc from groovy.xml.slurpersupport.GPathResult.find.

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 GPathResult findAll(final Closure<V> closure)

Implements abstract groovy.xml.slurpersupport.GPathResult.findAll.

Doc from groovy.xml.slurpersupport.GPathResult.findAll.

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)

Overrides groovy.xml.slurpersupport.GPathResult.getAt.

Doc from groovy.xml.slurpersupport.GPathResult.getAt.

Supports the subscript operator for a GPathResult.

import groovy.xml.slurpersupport.*
import groovy.xml.XmlSlurper
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

iteratorback to summary
public Iterator<E> iterator()

Implements abstract groovy.xml.slurpersupport.GPathResult.iterator.

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<E>

an Iterator.

localTextback to summary
public List<String> localText()

Returns the list of any direct String nodes of this NodeChild.

Returns:List<String>

the list of String values from this node

Since
2.3.0
namespaceURIback to summary
public String namespaceURI()

Returns the URI of the namespace of this NodeChild.

Returns:String

the namespace of this NodeChild

nodeIteratorback to summary
public Iterator<E> nodeIterator()

Implements abstract groovy.xml.slurpersupport.GPathResult.nodeIterator.

parentback to summary
public GPathResult parent()

Overrides groovy.xml.slurpersupport.GPathResult.parent.

Doc from groovy.xml.slurpersupport.GPathResult.parent.

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 GPathResult parents()

Implements abstract groovy.xml.slurpersupport.GPathResult.parents.

Throws a GroovyRuntimeException, because this method is not implemented yet.

Returns:GPathResult

Doc from groovy.xml.slurpersupport.GPathResult.parents.

the parents of this GPathResult

replaceBodyback to summary
protected void replaceBody(final Object newValue)

Implements abstract groovy.xml.slurpersupport.GPathResult.replaceBody.

replaceNodeback to summary
protected void replaceNode(final Closure<V> newValue)

Implements abstract groovy.xml.slurpersupport.GPathResult.replaceNode.

sizeback to summary
public int size()

Implements abstract groovy.xml.slurpersupport.GPathResult.size.

Doc from groovy.xml.slurpersupport.GPathResult.size.

Returns the size of this GPathResult.

Returns:int

the size of this GPathResult

textback to summary
public String text()

Implements abstract groovy.xml.slurpersupport.GPathResult.text.

Doc from groovy.xml.slurpersupport.GPathResult.text.

Returns the text of this GPathResult as a String.

Returns:String

the text of this GPathResult

writeToback to summary
public Writer writeTo(final Writer out) throws IOException

Implements groovy.lang.Writable.writeTo.

Doc from groovy.lang.Writable.writeTo.

Writes this object to the given writer.

This is used to defer content creation until the point when it is streamed to the output destination. Oftentimes, content will be defined but not necessarily created (as is may be the case with a Closure definition.) In that case, the output is then 'deferred' to the point when it is serialized to the writer. This class may be used whenever an object should be responsible for creating its own textual representation, but creating the entire output as a single String would be inefficient (such as outputting a multi-gigabyte XML document.)

Parameters
out:Writer

the Writer to which this Writable should output its data.

Returns:Writer

the Writer that was passed

Exceptions
IOException:
if an error occurred while outputting data to the writer