de.espirit.firstspirit.client.access.editor
Class Node

java.lang.Object
  extended by de.espirit.firstspirit.client.access.editor.Node

public final class Node
extends Object

A node has a name, attributes (Node.getAttribute(String), Node.setAttribute(String, String)), and either a textual value or children.

The name of a node or an attribute must be a valid name according to this specification:

Use one of these factory methods to create an instance:

Since:
4.2.414
See Also:
ValueEngineer.write(Object), ValueEngineer.read(List)

Method Summary
static Node create(String name)
          Create a node with the specified name.
static Node create(String name, Node... children)
          Create a node with the specified name and the specified child nodes.
static Node create(String name, Node child)
          Create a node with the specified name and the one specified child node.
static Node create(String name, String text)
          Create a node with the specified name and the specified text content.
 String getAttribute(String name)
          The value of the attribute with the specified name.
 List<Node> getChildren()
          The list of child nodes.
 String getName()
          The name of the node.
 String getText()
          The text content of this node.
 Node setAttribute(String name, String value)
          Sets the named attribute to a provided value, which might also be null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static Node create(@NotNull
                          String name)
Create a node with the specified name. The name must be a valid name according to the specification.

Parameters:
name - A valid name.
Returns:
A new empty node.
Since:
4.2.414

create

public static Node create(@NotNull
                          String name,
                          String text)
Create a node with the specified name and the specified text content. The name must be a valid name according to the specification.

Parameters:
name - A valid name.
text - A textual value (may be null or empty).
Returns:
A new node with a textual value.
Since:
4.2.414

create

public static Node create(@NotNull
                          String name,
                          @NotNull
                          Node child)
Create a node with the specified name and the one specified child node. The name must be a valid tag name according to the specification.

Parameters:
name - A valid name (see class comment).
child - The child node.
Returns:
A new node with the given child.
Since:
4.2.414

create

public static Node create(@NotNull
                          String name,
                          @NotNull
                          Node... children)
Create a node with the specified name and the specified child nodes. The name must be a valid tag name according to the specification.

Parameters:
name - A valid name (see class comment).
children - The child nodes.
Returns:
A new node with the given childs.
Since:
4.2.414

getName

@NotNull
public String getName()
The name of the node. The name is a valid tag name according to the specification.

Returns:
The name of this node.
Since:
4.2.414

getText

@Nullable
public String getText()
The text content of this node. A node may either have text content or children.

Returns:
The text content of the node or null it the node has no text content.
Since:
4.2.414

getAttribute

@Nullable
public String getAttribute(String name)
The value of the attribute with the specified name. May return null.

Parameters:
name - The name of the attribute.
Returns:
The value stored for the named attribute or null, if no such attribute is set.
Since:
4.2.414
See Also:
Node.setAttribute(String, String)

setAttribute

public Node setAttribute(@NotNull
                         String name,
                         @Nullable
                         String value)
Sets the named attribute to a provided value, which might also be null. If the node is immutable this method throws an UnsupportedOperationException. If the node is created with one of the static create methods the node is mutable.

Parameters:
name - Name of the attribute to set - must be a valid attribute name according to the specification.
value - The value of the attribute or null to clear the value of the specified attribute.
Returns:
The node itself.
Throws:
UnsupportedOperationException - for immutable nodes.
Since:
4.2.414

getChildren

@NotNull
public List<Node> getChildren()
The list of child nodes. The returned list is unmodifiable. This list is always empty if a text content is set.

Returns:
Immutable list of child nodes.
Since:
4.2.414


Copyright © 2012 e-Spirit AG. All Rights Reserved. Build 4.2.480