Class Node
java.lang.Object
de.espirit.firstspirit.client.access.editor.Node
A node has a
name, attributes (getAttribute(String),
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:
- not be empty
- start with an ASCII letter or underscore or colon
- consist only of ASCII letters 'a' to 'z' (lower or upper case), numbers, and the characters '-', '_', ':', '.'
- must not start with the letters 'xml' (either lower or upper case letters)
Use one of these factory methods to create an instance:
- Since:
- 4.2.414
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic NodeCreate a node with the specified name.static NodeCreate a node with the specified name and the one specified child node.static NodeCreate a node with the specified name and the specified child nodes.static NodeCreate a node with the specified name and the specified text content.@Nullable StringgetAttribute(String name) The value of the attribute with the specified name.The list of child nodes.@NotNull StringgetName()The name of the node.@Nullable StringgetText()The text content of this node.setAttribute(@NotNull String name, @Nullable String value) Sets the named attribute to a provided value, which might also benull.
-
Method Details
-
create
Create a node with the specified name. The name must be a valid name according to thespecification.- Parameters:
name- A valid name.- Returns:
- A new empty node.
- Since:
- 4.2.414
-
create
Create a node with the specified name and the specified text content. The name must be a valid name according to thespecification.- 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
Create a node with the specified name and the one specified child node. The name must be a valid tag name according to thespecification.- 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
Create a node with the specified name and the specified child nodes. The name must be a valid tag name according to thespecification.- 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
The name of the node. The name is a valid tag name according to thespecification.- Returns:
- The name of this node.
- Since:
- 4.2.414
-
getText
The text content of this node. A node may either have text content orchildren.- Returns:
- The text content of the node or
nullit the node has no text content. - Since:
- 4.2.414
-
getAttribute
The value of the attribute with the specified name. May returnnull.- 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:
-
setAttribute
Sets the named attribute to a provided value, which might also benull. If the node is immutable this method throws anUnsupportedOperationException. If the node is created with one of the staticcreatemethods the node is mutable.- Parameters:
name- Name of the attribute to set - must be a valid attribute name according to thespecification.value- The value of the attribute ornullto clear the value of the specified attribute.- Returns:
- The node itself.
- Throws:
UnsupportedOperationException- for immutable nodes.- Since:
- 4.2.414
-
getChildren
The list of child nodes. The returned list is unmodifiable. This list is always empty if atext contentis set.- Returns:
- Immutable list of child nodes.
- Since:
- 4.2.414
-