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
Modifier and TypeClassDescriptionstatic enum
This is an enumeration of the components of a node-related message.static enum
This is an enumeration of the kinds of a node-related message.static class
This class implements a list of node-related messages. -
Constructor Summary
ConstructorDescriptionNodeMessage
(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.boolean
isError()
Returnstrue
if the kind of this message is an error or a fatal error.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.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
- ifnode
isnull
orkind
isnull
.
-
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
- ifnode
isnull
orkind
isnull
.
-
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
- ifnode
isnull
orkind
isnull
.
-
-
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
node
to 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()Returnstrue
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
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.
-