Package org.yaml.snakeyaml.nodes
Class Node
- java.lang.Object
-
- org.yaml.snakeyaml.nodes.Node
-
- Direct Known Subclasses:
AnchorNode,CollectionNode,ScalarNode
public abstract class Node extends java.lang.ObjectBase 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, and later transformed into application specific Java classes by the classes from theorg.yaml.snakeyaml.constructorpackage.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringanchorprivate java.util.List<CommentLine>blockCommentsprivate java.util.List<CommentLine>endCommentsprotected MarkendMarkprivate java.util.List<CommentLine>inLineCommentsprotected booleanresolvedtrue when the tag is assigned by the resolverprivate MarkstartMarkprivate Tagtagprivate booleantwoStepsConstructionprivate java.lang.Class<? extends java.lang.Object>typeprotected java.lang.BooleanuseClassConstructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Node is only equal to itselfjava.lang.StringgetAnchor()java.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.MarkgetEndMark()java.util.List<CommentLine>getInLineComments()The ordered list of in-line comments.abstract NodeIdgetNodeId()For error reporting.MarkgetStartMark()TaggetTag()Tag of this node.java.lang.Class<? extends java.lang.Object>getType()inthashCode()booleanisResolved()Deprecated.Since v1.22.booleanisTwoStepsConstruction()Indicates if this node must be constructed in two steps.voidsetAnchor(java.lang.String anchor)voidsetBlockComments(java.util.List<CommentLine> blockComments)voidsetEndComments(java.util.List<CommentLine> endComments)voidsetInLineComments(java.util.List<CommentLine> inLineComments)voidsetTag(Tag tag)voidsetTwoStepsConstruction(boolean twoStepsConstruction)voidsetType(java.lang.Class<? extends java.lang.Object> type)voidsetUseClassConstructor(java.lang.Boolean useClassConstructor)booleanuseClassConstructor()
-
-
-
Field Detail
-
tag
private Tag tag
-
startMark
private final Mark startMark
-
endMark
protected Mark endMark
-
type
private java.lang.Class<? extends java.lang.Object> type
-
twoStepsConstruction
private boolean twoStepsConstruction
-
anchor
private java.lang.String anchor
-
inLineComments
private java.util.List<CommentLine> inLineComments
-
blockComments
private java.util.List<CommentLine> blockComments
-
endComments
private java.util.List<CommentLine> endComments
-
resolved
protected boolean resolved
true when the tag is assigned by the resolver
-
useClassConstructor
protected java.lang.Boolean useClassConstructor
-
-
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.
-
getEndMark
public Mark getEndMark()
-
getNodeId
public abstract NodeId getNodeId()
For error reporting.- Returns:
- scalar, sequence, mapping
- See Also:
- "class variable 'id' in PyYAML"
-
getStartMark
public Mark getStartMark()
-
setTag
public void setTag(Tag tag)
-
equals
public final boolean equals(java.lang.Object obj)
Node is only equal to itself- Overrides:
equalsin classjava.lang.Object
-
getType
public java.lang.Class<? extends java.lang.Object> getType()
-
setType
public void setType(java.lang.Class<? extends java.lang.Object> type)
-
setTwoStepsConstruction
public void setTwoStepsConstruction(boolean twoStepsConstruction)
-
isTwoStepsConstruction
public boolean isTwoStepsConstruction()
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:
trueif the node is self referenced.
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
useClassConstructor
public boolean useClassConstructor()
-
setUseClassConstructor
public void setUseClassConstructor(java.lang.Boolean useClassConstructor)
-
isResolved
@Deprecated public boolean isResolved()
Deprecated.Since v1.22. Absent in immediately prior versions, but present previously. Restored deprecated for backwards compatibility.Indicates if the tag was added byResolver.- Returns:
- true if the tag of this node was resolved
-
getAnchor
public java.lang.String getAnchor()
-
setAnchor
public void setAnchor(java.lang.String anchor)
-
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)
-
-