Package io.github.qishr.cascara.lang.yaml.ast
Class YamlScalarNode
java.lang.Object
io.github.qishr.cascara.lang.yaml.ast.YamlNode
io.github.qishr.cascara.lang.yaml.ast.YamlScalarNode
All Implemented Interfaces:
ScalarAstNode<YamlNode>
public class YamlScalarNode
extends YamlNode
Represents a leaf node in the YAML AST containing a single scalar value.
Constructor Summary
| Constructor | Description |
|---|---|
| YamlScalarNode(int line, int column, String raw, String unescapedContent, QuoteStyle quoteStyle) | Constructor for use in parsers. |
| YamlScalarNode(Object primitiveValue, QuoteStyle quoteStyle) | A programmatic and serializer constructor. |
| YamlScalarNode(Object primitiveValue) | A programmatic and serializer constructor. |
| YamlScalarNode() | The default constructor |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public List<YamlNode> | getChildren() | Scalars are leaf nodes and have no children. |
| public QuoteStyle | getQuoteStyle() | Gets the quoting style used for this scalar. |
| public boolean | isQuoted() | |
| public void | setQuoteStyle(QuoteStyle quoteStyle) | Sets the quoting style and clears the raw cache. |
| public String | getRaw() | Returns the original raw (unescaped) string as seen in the source file. |
| public Object | getPrimitive() | Performs basic type inference to return the most appropriate Java object. |
| public void | setPrimitive(Object primitive) | |
| public String | asString() | |
| public int | asInteger() | |
| public int | asInteger(int defaultValue) | |
| public double | asDouble() | |
| public double | asDouble(double defaultValue) | |
| public boolean | asBoolean() | |
| public boolean | asBoolean(boolean defaultValue) | |
| public boolean | equals(Object o) | Compares this scalar with another for equality. |
| public int | hashCode() | |
| public String | toString() |
Methods inherited from YamlNode
getEndColumn, getEndLine, getComments, setAnchor, getStartColumn, getToken, getAnchor, addComment, getStartLine, setToken
Method Details
getChildren
public List<YamlNode> getChildren()
Scalars are leaf nodes and have no children.
getQuoteStyle
public QuoteStyle getQuoteStyle()
Gets the quoting style used for this scalar.
Specified By:
isQuoted
public boolean isQuoted()
setQuoteStyle
public void setQuoteStyle(QuoteStyle quoteStyle)
Sets the quoting style and clears the raw cache.
Specified By:
getRaw
public String getRaw()
Returns the original raw (unescaped) string as seen in the source file.
Specified By:
getPrimitive
public Object getPrimitive()
Performs basic type inference to return the most appropriate Java object.
Specified By:
setPrimitive
public void setPrimitive(Object primitive)
Specified By:
asString
public String asString()
Specified By:
asInteger
public int asInteger()
Specified By:
asInteger
public int asInteger(int defaultValue)
Specified By:
asDouble
public double asDouble()
Specified By:
asDouble
public double asDouble(double defaultValue)
Specified By:
asBoolean
public boolean asBoolean()
Specified By:
asBoolean
public boolean asBoolean(boolean defaultValue)
Specified By:
equals
public boolean equals(Object o)
Compares this scalar with another for equality.Two scalars are considered equal if they share the same anchor and logical string value. Source coordinates and quoting styles are ignored.
hashCode
public int hashCode()
toString
public String toString()