Package uk.blankaspect.common.basictree
Class NodeMessage
java.lang.Object
uk.blankaspect.common.basictree.NodeMessage
This class encapsulates a message that relates to a node. A nested class,
NodeMessage.List,
implements a list of such messages.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThis is an enumeration of the components of a node-related message.static enumThis is an enumeration of the kinds of a node-related message.static classThis class implements a list of node-related messages. -
Constructor Summary
ConstructorsConstructorDescriptionNodeMessage(AbstractNode node, NodeMessage.Kind kind, String text) Creates a new instance of a message of the specified kind that relates to the specified node.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.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. -
Method Summary
Modifier and TypeMethodDescriptionReturns the exception that is associated with this message.getKind()Returns the kind of this message.getNode()Returns the node that is associated with this message.getText()Returns the text of this message.booleanisError()Returnstrueif the kind of this message is an error or a fatal error.static StringnodeToPathString(AbstractNode node) Returns a string representation of the path from the specified node from the root of the tree to which it belongs.toString()toString(String separator, Iterable<NodeMessage.Component> components) Returns a string representation of the specified components of this message.toString(String separator, NodeMessage.Component... components) Returns a string representation of the specified components of this message.
-
Constructor Details
-
NodeMessage
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 benull.- Throws:
IllegalArgumentException- ifnodeisnullorkindisnull.
-
NodeMessage
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 benull.- Throws:
IllegalArgumentException- ifnodeisnullorkindisnull.
-
NodeMessage
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 benull.exception- the exception that will be associated with the message, which may benull.- Throws:
IllegalArgumentException- ifnodeisnullorkindisnull.
-
-
Method Details
-
nodeToPathString
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
nodeto the root of the tree to which it belongs.
-
toString
-
getNode
Returns the node that is associated with this message.- Returns:
- the node that is associated with this message.
-
getKind
Returns the kind of this message.- Returns:
- the kind of this message.
-
getText
Returns the text of this message.- Returns:
- the text of this message.
-
getException
Returns the exception that is associated with this message.- Returns:
- the exception that is associated with this message.
-
isError
public boolean isError()Returnstrueif the kind of this message is an error or a fatal error.- Returns:
trueif the kind of this message is an error or a fatal error;falseotherwise.
-
toString
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
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.
-