Package org.snakeyaml.engine.v2.nodes
Class Node
java.lang.Object
org.snakeyaml.engine.v2.nodes.Node
- Direct Known Subclasses:
AnchorNode
,CollectionNode
,ScalarNode
Base class for all nodes.
The nodes form the node-graph described in the YAML Specification.
While loading, the node graph is usually created by the
Composer
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<CommentLine> private List
<CommentLine> private List
<CommentLine> private boolean
protected boolean
true when the tag is assigned by the resolverprivate Tag
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Node is only equal to itselfGet the anchor if it was defined for this NodeThe ordered list of blank lines and block comments (full line) that appear before this node.The ordered list of blank lines and block comments (full line) that appear AFTER this node.The ordered list of in-line comments.abstract NodeType
getProperty
(String key) Get the custom runtime property.getTag()
Tag of this node.final int
hashCode()
boolean
Indicates if this node must be constructed in two steps.void
Set the anchor for this Nodevoid
setBlockComments
(List<CommentLine> blockComments) void
setEndComments
(List<CommentLine> endComments) void
setInLineComments
(List<CommentLine> inLineComments) setProperty
(String key, Object value) Define a custom runtime property.void
setRecursive
(boolean recursive) void
-
Field Details
-
startMark
-
endMark
-
resolved
protected boolean resolvedtrue when the tag is assigned by the resolver -
tag
-
recursive
private boolean recursive -
anchor
-
inLineComments
-
blockComments
-
endComments
-
properties
-
-
Constructor Details
-
Node
Create Node to be parsed- Parameters:
tag
- - the tagstartMark
- - start mark when availableendMark
- - end mark when available
-
-
Method Details
-
getTag
Tag of this node.Every node has a tag assigned. The tag is either local or global.
- Returns:
- Tag of this node.
-
setTag
-
getEndMark
-
getNodeType
- Returns:
- scalar, sequence, mapping
-
getStartMark
-
equals
Node is only equal to itself -
isRecursive
public boolean isRecursive()Indicates if this node must be constructed in two steps.Two-step construction is required whenever a node is a child (direct or indirect) of it self. That is, if a recursive structure is build using anchors and aliases.
Set by
Composer
, used during the construction process.Only relevant during loading.
- Returns:
true
if the node is self referenced.
-
setRecursive
public void setRecursive(boolean recursive) -
hashCode
public final int hashCode() -
getAnchor
Get the anchor if it was defined for this Node- Returns:
- the Anchor if available
- See Also:
-
setAnchor
Set the anchor for this Node- Parameters:
anchor
- - the Anchor for this Node- See Also:
-
setProperty
Define a custom runtime property. It is not used by Engine but may be used by other tools.- Parameters:
key
- - the key for the custom propertyvalue
- - the value for the custom property- Returns:
- the previous value for the provided key if it was defined
-
getProperty
Get the custom runtime property.- Parameters:
key
- - the key of the runtime property- Returns:
- the value if it was specified
-
getInLineComments
The ordered list of in-line comments. The first of which appears at the end of the line respresent by this node. The rest are in the following lines, indented per the Spec to indicate they are continuation of the inline comment.- Returns:
- the comment line list.
-
setInLineComments
-
getBlockComments
The ordered list of blank lines and block comments (full line) that appear before this node.- Returns:
- the comment line list.
-
setBlockComments
-
getEndComments
The ordered list of blank lines and block comments (full line) that appear AFTER this node.NOTE: these comment should occur only in the last node in a document, when walking the node tree "in order"
- Returns:
- the comment line list.
-
setEndComments
-