Top Description Fields Constructors Methods
org.yaml.snakeyaml.nodes

public abstract Class Node

extends Object
Class Inheritance
Known Direct Subclasses
org.yaml.snakeyaml.nodes.ScalarNode, org.yaml.snakeyaml.nodes.AnchorNode, org.yaml.snakeyaml.nodes.CollectionNode
Imports
java.util.List, org.yaml.snakeyaml.comments.CommentLine, org.yaml.snakeyaml.error.Mark

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 org.yaml.snakeyaml.composer.Composer, and later transformed into application specific Java classes by the classes from the org.yaml.snakeyaml.constructor package.

Field Summary

Modifier and TypeField and Description
private String
private List<CommentLine>
private List<CommentLine>
protected Mark
private List<CommentLine>
protected boolean
resolved

true when the tag is assigned by the resolver

private final Mark
private Tag
private boolean
private Class<? extends Object>
protected Boolean

Constructor Summary

AccessConstructor and Description
public
Node(Tag tag, Mark startMark, Mark endMark)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Node is only equal to itself
public String
public List<CommentLine>

Returns:

the comment line list.
getBlockComments
()

The ordered list of blank lines and block comments (full line) that appear before this node.

public List<CommentLine>

Returns:

the comment line list.
getEndComments
()

The ordered list of blank lines and block comments (full line) that appear AFTER this node.

public Mark
public List<CommentLine>

Returns:

the comment line list.
getInLineComments
()

The ordered list of in-line comments.

public abstract NodeId

Returns:

scalar, sequence, mapping
getNodeId
()

For error reporting.

public Mark
public Tag

Returns:

Tag of this node.
getTag
()

Tag of this node.

public Class<? extends Object>
public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean

Returns:

true if the node is self referenced.
isTwoStepsConstruction
()

Indicates if this node must be constructed in two steps.

public void
setAnchor(String anchor)

public void
public void
public void
public void
setTag(Tag tag)

public void
setTwoStepsConstruction(boolean twoStepsConstruction)

public void
setType(Class<? extends Object> type)

public void
setUseClassConstructor(Boolean useClassConstructor)

public boolean
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

anchorback to summary
private String anchor
blockCommentsback to summary
private List<CommentLine> blockComments
endCommentsback to summary
private List<CommentLine> endComments
endMarkback to summary
protected Mark endMark
inLineCommentsback to summary
private List<CommentLine> inLineComments
resolvedback to summary
protected boolean resolved

true when the tag is assigned by the resolver

startMarkback to summary
private final Mark startMark
tagback to summary
private Tag tag
twoStepsConstructionback to summary
private boolean twoStepsConstruction
typeback to summary
private Class<? extends Object> type
useClassConstructorback to summary
protected Boolean useClassConstructor

Constructor Detail

Nodeback to summary
public Node(Tag tag, Mark startMark, Mark endMark)

Method Detail

equalsback to summary
public final boolean equals(Object obj)

Overrides java.lang.Object.equals.

Node is only equal to itself

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getAnchorback to summary
public String getAnchor()
getBlockCommentsback to summary
public List<CommentLine> getBlockComments()

The ordered list of blank lines and block comments (full line) that appear before this node.

Returns:List<CommentLine>

the comment line list.

getEndCommentsback to summary
public 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:List<CommentLine>

the comment line list.

getEndMarkback to summary
public Mark getEndMark()
getInLineCommentsback to summary
public 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:List<CommentLine>

the comment line list.

getNodeIdback to summary
public abstract NodeId getNodeId()

For error reporting.

Returns:NodeId

scalar, sequence, mapping

See Also
variable 'id' in PyYAML"
getStartMarkback to summary
public Mark getStartMark()
getTagback to summary
public Tag getTag()

Tag of this node.

Every node has a tag assigned. The tag is either local or global.

Returns:Tag

Tag of this node.

getTypeback to summary
public Class<? extends Object> getType()
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isTwoStepsConstructionback to summary
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 org.yaml.snakeyaml.composer.Composer, used during the construction process.

Only relevant during loading.

Returns:boolean

true if the node is self referenced.

setAnchorback to summary
public void setAnchor(String anchor)
setBlockCommentsback to summary
public void setBlockComments(List<CommentLine> blockComments)
setEndCommentsback to summary
public void setEndComments(List<CommentLine> endComments)
setInLineCommentsback to summary
public void setInLineComments(List<CommentLine> inLineComments)
setTagback to summary
public void setTag(Tag tag)
setTwoStepsConstructionback to summary
public void setTwoStepsConstruction(boolean twoStepsConstruction)
setTypeback to summary
public void setType(Class<? extends Object> type)
setUseClassConstructorback to summary
public void setUseClassConstructor(Boolean useClassConstructor)
useClassConstructorback to summary
public boolean useClassConstructor()