Package org.snakeyaml.engine.v2.nodes
Class Node
- java.lang.Object
-
- org.snakeyaml.engine.v2.nodes.Node
-
- Direct Known Subclasses:
AnchorNode
,CollectionNode
,ScalarNode
public abstract class Node extends java.lang.Object
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
Fields Modifier and Type Field Description private java.util.Optional<Anchor>
anchor
private java.util.List<CommentLine>
blockComments
private java.util.List<CommentLine>
endComments
protected java.util.Optional<Mark>
endMark
private java.util.List<CommentLine>
inLineComments
private java.util.Map<java.lang.String,java.lang.Object>
properties
private boolean
recursive
protected boolean
resolved
true when the tag is assigned by the resolverprivate java.util.Optional<Mark>
startMark
private Tag
tag
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Node is only equal to itselfjava.util.Optional<Anchor>
getAnchor()
Get the anchor if it was defined for this Nodejava.util.List<CommentLine>
getBlockComments()
The ordered list of blank lines and block comments (full line) that appear before this node.java.util.List<CommentLine>
getEndComments()
The ordered list of blank lines and block comments (full line) that appear AFTER this node.java.util.Optional<Mark>
getEndMark()
java.util.List<CommentLine>
getInLineComments()
The ordered list of in-line comments.abstract NodeType
getNodeType()
java.lang.Object
getProperty(java.lang.String key)
Get the custom runtime property.java.util.Optional<Mark>
getStartMark()
Tag
getTag()
Tag of this node.int
hashCode()
boolean
isRecursive()
Indicates if this node must be constructed in two steps.void
setAnchor(java.util.Optional<Anchor> anchor)
Set the anchor for this Nodevoid
setBlockComments(java.util.List<CommentLine> blockComments)
void
setEndComments(java.util.List<CommentLine> endComments)
void
setInLineComments(java.util.List<CommentLine> inLineComments)
java.lang.Object
setProperty(java.lang.String key, java.lang.Object value)
Define a custom runtime property.void
setRecursive(boolean recursive)
void
setTag(Tag tag)
-
-
-
Field Detail
-
startMark
private final java.util.Optional<Mark> startMark
-
endMark
protected java.util.Optional<Mark> endMark
-
resolved
protected boolean resolved
true when the tag is assigned by the resolver
-
tag
private Tag tag
-
recursive
private boolean recursive
-
anchor
private java.util.Optional<Anchor> anchor
-
inLineComments
private java.util.List<CommentLine> inLineComments
-
blockComments
private java.util.List<CommentLine> blockComments
-
endComments
private java.util.List<CommentLine> endComments
-
properties
private java.util.Map<java.lang.String,java.lang.Object> properties
-
-
Method Detail
-
getTag
public Tag getTag()
Tag of this node.Every node has a tag assigned. The tag is either local or global.
- Returns:
- Tag of this node.
-
setTag
public void setTag(Tag tag)
-
getEndMark
public java.util.Optional<Mark> getEndMark()
-
getNodeType
public abstract NodeType getNodeType()
- Returns:
- scalar, sequence, mapping
-
getStartMark
public java.util.Optional<Mark> getStartMark()
-
equals
public final boolean equals(java.lang.Object obj)
Node is only equal to itself- Overrides:
equals
in classjava.lang.Object
-
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()
- Overrides:
hashCode
in classjava.lang.Object
-
getAnchor
public java.util.Optional<Anchor> getAnchor()
Get the anchor if it was defined for this Node- Returns:
- the Anchor if available
- See Also:
- 3.2.2.2. Anchors and Aliases
-
setAnchor
public void setAnchor(java.util.Optional<Anchor> anchor)
Set the anchor for this Node- Parameters:
anchor
- - the Anchor for this Node- See Also:
- 3.2.2.2. Anchors and Aliases
-
setProperty
public java.lang.Object setProperty(java.lang.String key, java.lang.Object value)
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
public java.lang.Object getProperty(java.lang.String key)
Get the custom runtime property.- Parameters:
key
- - the key of the runtime property- Returns:
- the value if it was specified
-
getInLineComments
public java.util.List<CommentLine> 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
public void setInLineComments(java.util.List<CommentLine> inLineComments)
-
getBlockComments
public java.util.List<CommentLine> getBlockComments()
The ordered list of blank lines and block comments (full line) that appear before this node.- Returns:
- the comment line list.
-
setBlockComments
public void setBlockComments(java.util.List<CommentLine> blockComments)
-
getEndComments
public java.util.List<CommentLine> 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
public void setEndComments(java.util.List<CommentLine> endComments)
-
-