Top Description Fields Constructors Methods
org.snakeyaml.engine.v2.nodes

public abstract Class Node

extends Object
Class Inheritance
Known Direct Subclasses
org.snakeyaml.engine.v2.nodes.ScalarNode, org.snakeyaml.engine.v2.nodes.AnchorNode, org.snakeyaml.engine.v2.nodes.CollectionNode
Imports
java.util.HashMap, .List, .Map, .Objects, .Optional, org.snakeyaml.engine.v2.comments.CommentLine, org.snakeyaml.engine.v2.common.Anchor, org.snakeyaml.engine.v2.exceptions.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.snakeyaml.engine.v2.composer.Composer.

Field Summary

Modifier and TypeField and Description
private Optional<Anchor>
private List<CommentLine>
private List<CommentLine>
protected Optional<Mark>
private List<CommentLine>
private Map<String, Object>
private boolean
protected boolean
resolved

true when the tag is assigned by the resolver

private final Optional<Mark>
private Tag

Constructor Summary

AccessConstructor and Description
public
Node(Tag
- the tag
tag
,
Optional<Mark>
- start mark when available
startMark
,
Optional<Mark>
- end mark when available
endMark
)

Create Node to be parsed

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Node is only equal to itself

public Optional<Anchor>

Returns:

the Anchor if available
getAnchor
()

Get the anchor if it was defined for this Node

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 Optional<Mark>
public List<CommentLine>

Returns:

the comment line list.
getInLineComments
()

The ordered list of in-line comments.

public abstract NodeType

Returns:

scalar, sequence, mapping
getNodeType
()

public Object

Returns:

the value if it was specified
getProperty
(String
- the key of the runtime property
key
)

Get the custom runtime property.

public Optional<Mark>
public Tag

Returns:

Tag of this node.
getTag
()

Tag of this node.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean

Returns:

true if the node is self referenced.
isRecursive
()

Indicates if this node must be constructed in two steps.

public void
setAnchor(Optional<Anchor>
- the Anchor for this Node
anchor
)

Set the anchor for this Node

public void
public void
public void
public Object

Returns:

the previous value for the provided key if it was defined
setProperty
(String
- the key for the custom property
key
,
Object
- the value for the custom property
value
)

Define a custom runtime property.

public void
setRecursive(boolean recursive)

public void
setTag(Tag tag)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

anchorback to summary
private Optional<Anchor> anchor
blockCommentsback to summary
private List<CommentLine> blockComments
endCommentsback to summary
private List<CommentLine> endComments
endMarkback to summary
protected Optional<Mark> endMark
inLineCommentsback to summary
private List<CommentLine> inLineComments
propertiesback to summary
private Map<String, Object> properties
recursiveback to summary
private boolean recursive
resolvedback to summary
protected boolean resolved

true when the tag is assigned by the resolver

startMarkback to summary
private final Optional<Mark> startMark
tagback to summary
private Tag tag

Constructor Detail

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

Create Node to be parsed

Parameters
tag:Tag

- the tag

startMark:Optional<Mark>

- start mark when available

endMark:Optional<Mark>

- end mark when available

Method Detail

equalsback to summary
public final boolean equals(Object obj)

Overrides java.lang.Object.equals.

Node is only equal to itself

Annotations
@Override
getAnchorback to summary
public Optional<Anchor> getAnchor()

Get the anchor if it was defined for this Node

Returns:Optional<Anchor>

the Anchor if available

See Also
3.2.2.2. Anchors and Aliases
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 Optional<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.

getNodeTypeback to summary
public abstract NodeType getNodeType()
Returns:NodeType

scalar, sequence, mapping

getPropertyback to summary
public Object getProperty(String key)

Get the custom runtime property.

Parameters
key:String

- the key of the runtime property

Returns:Object

the value if it was specified

getStartMarkback to summary
public Optional<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.

hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this 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.
Annotations
@Override
isRecursiveback to summary
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 org.snakeyaml.engine.v2.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(Optional<Anchor> anchor)

Set the anchor for this Node

Parameters
anchor:Optional<Anchor>

- the Anchor for this Node

See Also
3.2.2.2. Anchors and Aliases
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)
setPropertyback to summary
public Object setProperty(String key, Object value)

Define a custom runtime property. It is not used by Engine but may be used by other tools.

Parameters
key:String

- the key for the custom property

value:Object

- the value for the custom property

Returns:Object

the previous value for the provided key if it was defined

setRecursiveback to summary
public void setRecursive(boolean recursive)
setTagback to summary
public void setTag(Tag tag)