Class NodeMessage

java.lang.Object
uk.blankaspect.common.basictree.NodeMessage

public class NodeMessage extends Object
This class encapsulates a message that relates to a node. A nested class, NodeMessage.List, implements a list of such messages.
  • Constructor Details

    • NodeMessage

      public NodeMessage(AbstractNode node, NodeMessage.Kind kind, String text)
      Creates a new instance of a message of the specified kind that relates to the specified node.
      Parameters:
      node - the node that will be associated with the message.
      kind - the kind of the message.
      text - the text of the message, which may be null.
      Throws:
      IllegalArgumentException - if node is null or kind is null.
    • NodeMessage

      public NodeMessage(AbstractNode node, NodeMessage.Kind kind, Throwable exception)
      Creates a new instance of a message of the specified kind that relates to the specified node.
      Parameters:
      node - the node that will be associated with the message.
      kind - the kind of the message.
      exception - the exception that will be associated with the message, which may be null.
      Throws:
      IllegalArgumentException - if node is null or kind is null.
    • NodeMessage

      public NodeMessage(AbstractNode node, NodeMessage.Kind kind, String text, Throwable exception)
      Creates a new instance of a message of the specified kind that relates to the specified node.
      Parameters:
      node - the node that will be associated with the message.
      kind - the kind of the message.
      text - the text of the message, which may be null.
      exception - the exception that will be associated with the message, which may be null.
      Throws:
      IllegalArgumentException - if node is null or kind is null.
  • Method Details

    • nodeToPathString

      public static String nodeToPathString(AbstractNode node)
      Returns a string representation of the path from the specified node from the root of the tree to which it belongs. The elements of the path are:
      • an element of a list node, which is represented by its index enclosed in square brackets (eg, '[2]'), or
      • a key–value pair of a map node, which is represented by its key, with a '/' prefixed to it if the map node is not the root.

      If the specified node is the root of its tree, an empty string is returned.

      Parameters:
      node - the node for whose path a string representation is required.
      Returns:
      a string representation of the path from node to the root of the tree to which it belongs.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getNode

      public AbstractNode getNode()
      Returns the node that is associated with this message.
      Returns:
      the node that is associated with this message.
    • getKind

      public NodeMessage.Kind getKind()
      Returns the kind of this message.
      Returns:
      the kind of this message.
    • getText

      public String getText()
      Returns the text of this message.
      Returns:
      the text of this message.
    • getException

      public Throwable getException()
      Returns the exception that is associated with this message.
      Returns:
      the exception that is associated with this message.
    • isError

      public boolean isError()
      Returns true if the kind of this message is an error or a fatal error.
      Returns:
      true if the kind of this message is an error or a fatal error; false otherwise.
    • toString

      public String toString(String separator, NodeMessage.Component... components)
      Returns a string representation of the specified components of this message.
      Parameters:
      separator - the separator between components in the string representation the message.
      components - the components of this message for which a string representation is required.
      Returns:
      a string representation of the specified components of this message.
    • toString

      public String toString(String separator, Iterable<NodeMessage.Component> components)
      Returns a string representation of the specified components of this message.
      Parameters:
      separator - the separator between components in the string representation the message.
      components - the components of this message for which a string representation is required.
      Returns:
      a string representation of the specified components of this message.