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

public final class Node extends Object
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 nameaccording 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 Details

    • create

      public static Node create(@NotNull @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 @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 @NotNull String name, @NotNull @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 @NotNull String name, @NotNull @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 @NotNull 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 @Nullable 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 @Nullable 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:
    • setAttribute

      public Node setAttribute(@NotNull @NotNull String name, @Nullable @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 @NotNull 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