Top Description Fields Constructors Methods
groovy.xml.slurpersupport

public Class Node

extends Object
implements Writable
Class Inheritance
All Implemented Interfaces
groovy.lang.Writable
Imports
groovy.lang.Buildable, .Closure, .GroovyObject, .Writable, java.io.IOException, .Writer, java.util.ArrayList, .HashMap, .Iterator, .LinkedList, .List, .Map, .Stack

Represents a node.

Field Summary

Modifier and TypeField and Description
private final Map<K, V>
private final Map<K, V>
private final List<E>
private final String
private final String
private final Node
private final Stack<E>

Constructor Summary

AccessConstructor and Description
public
Node(final Node
the parent node
parent
,
final String
the name for the node
name
,
final Map<K, V>
the attributes for the node
attributes
,
final Map<K, V>
the namespace mappings for attributes
attributeNamespaces
,
final String
the namespace URI if any
namespaceURI
)

Method Summary

Modifier and TypeMethod and Description
public void
addChild(final Object
the object to add as a child
child
)

Adds an object as a new child to this Node.

protected void
appendNode(final Object newValue, final GPathResult result)

public Map<K, V>

Returns:

a map of the attributes of this Node
attributes
()

Returns a map of the attributes of this Node.

public void
build(final GroovyObject builder, final Map<K, V> namespaceMap, final Map<String, String> namespaceTagHints)

private void
buildChildren(final GroovyObject builder, final Map<K, V> namespaceMap, final Map<String, String> namespaceTagHints)

public Iterator<E>

Returns:

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

Returns an iterator over the child nodes of this Node.

public List<E>

Returns:

a list of the children of this Node
children
()

Returns a list of the children of this Node.

private static String
findNamespaceTag(final Map<K, V> tagMap, final Object namespaceURI)

private static String
getTagFor(final Object namespaceURI, final Map<K, V> current, final Map<K, V> pending, final Map<K, V> local, final Map<K, V> tagHints, final List<E> newTags, final GroovyObject builder)

public List<String>

Returns:

the list of String values from this node
localText
()

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

public String

Returns:

the name of this Node
name
()

Returns the name of this Node.

public String

Returns:

the namespace of this Node
namespaceURI
()

Returns the URI of the namespace of this Node.

public Node

Returns:

the parent of this Node
parent
()

Returns the parent of this Node.

protected void
replaceBody(final Object
the new body
newValue
)

Replaces the current body of this Node with the passed object.

public void
replaceNode(final Closure<V> replacementClosure, final GPathResult result)

public String

Returns:

a string containing the text of the children of this Node
text
()

Returns a string containing the text of the children of this Node.

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 java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeNamespacesback to summary
private final Map<K, V> attributeNamespaces
attributesback to summary
private final Map<K, V> attributes
childrenback to summary
private final List<E> children
nameback to summary
private final String name
namespaceURIback to summary
private final String namespaceURI
parentback to summary
private final Node parent
replacementNodeStackback to summary
private final Stack<E> replacementNodeStack

Constructor Detail

Nodeback to summary
public Node(final Node parent, final String name, final Map<K, V> attributes, final Map<K, V> attributeNamespaces, final String namespaceURI)
Parameters
parent:Node

the parent node

name:String

the name for the node

attributes:Map<K, V>

the attributes for the node

attributeNamespaces:Map<K, V>

the namespace mappings for attributes

namespaceURI:String

the namespace URI if any

Method Detail

addChildback to summary
public void addChild(final Object child)

Adds an object as a new child to this Node.

Parameters
child:Object

the object to add as a child

appendNodeback to summary
protected void appendNode(final Object newValue, final GPathResult result)
attributesback to summary
public Map<K, V> attributes()

Returns a map of the attributes of this Node.

Returns:Map<K, V>

a map of the attributes of this Node

buildback to summary
public void build(final GroovyObject builder, final Map<K, V> namespaceMap, final Map<String, String> namespaceTagHints)
buildChildrenback to summary
private void buildChildren(final GroovyObject builder, final Map<K, V> namespaceMap, final Map<String, String> namespaceTagHints)
childNodesback to summary
public Iterator<E> childNodes()

Returns an iterator over the child nodes of this Node.

Returns:Iterator<E>

an iterator over the child nodes of this Node

childrenback to summary
public List<E> children()

Returns a list of the children of this Node.

Returns:List<E>

a list of the children of this Node

findNamespaceTagback to summary
private static String findNamespaceTag(final Map<K, V> tagMap, final Object namespaceURI)
getTagForback to summary
private static String getTagFor(final Object namespaceURI, final Map<K, V> current, final Map<K, V> pending, final Map<K, V> local, final Map<K, V> tagHints, final List<E> newTags, final GroovyObject builder)
localTextback to summary
public List<String> localText()

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

Returns:List<String>

the list of String values from this node

Since
2.3.0
nameback to summary
public String name()

Returns the name of this Node.

Returns:String

the name of this Node

namespaceURIback to summary
public String namespaceURI()

Returns the URI of the namespace of this Node.

Returns:String

the namespace of this Node

parentback to summary
public Node parent()

Returns the parent of this Node.

Returns:Node

the parent of this Node

replaceBodyback to summary
protected void replaceBody(final Object newValue)

Replaces the current body of this Node with the passed object.

Parameters
newValue:Object

the new body

replaceNodeback to summary
public void replaceNode(final Closure<V> replacementClosure, final GPathResult result)
textback to summary
public String text()

Returns a string containing the text of the children of this Node.

Returns:String

a string containing the text of the children of this Node

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