Package io.github.qishr.cascara.common.lang.ast
Interface ScalarAstNode
java.lang.Object
io.github.qishr.cascara.common.lang.ast.ScalarAstNode
All Implemented Interfaces:
AstNode
All Known Implementing Classes:
GenericAstScalar, JsonComment, JsonScalar, YamlScalar
public interface ScalarAstNode
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public abstract QuoteStyle | getQuoteStyle() | Returns the QuoteStyle used by a node: PLAIN, SINGLE, DOUBLE, LITERAL, or FOLDED. |
| public abstract ScalarAstNode |
setQuoteStyle(QuoteStyle style) | Sets the QuoteStyle used by a node |
| public abstract String | getLexeme() | Returns the exact, unparsed text block directly from the file buffer. |
| public abstract Object | getPrimitive() | Returns the Java-native representation of the scalar (e.g., Integer, Boolean, String). |
| public abstract ScalarAstNode |
setPrimitive(Object jvmValue) | |
| public abstract PrimitiveType | getPrimitiveType() | |
| public abstract String | getContent() | |
| public default String | asString() | Returns the string form or the primitive. |
| public default int | asInteger() | |
| public default int | asInteger(int defaultValue) | |
| public default long | asLong() | |
| public default long | asLong(long defaultValue) | |
| public default double | asDouble() | |
| public default double | asDouble(double defaultValue) | |
| public default boolean | asBoolean() | Returns the boolean value of the scalar, if there is one, otherwise results false. |
| public default boolean | asBoolean(boolean defaultValue) | Returns the boolean value of the scalar, if there is one, otherwise the specified default is returned. |
Method Details
getQuoteStyle
public abstract QuoteStyle getQuoteStyle()
Returns the QuoteStyle used by a node: PLAIN, SINGLE, DOUBLE, LITERAL, or FOLDED.
setQuoteStyle
public abstract ScalarAstNode
Sets the QuoteStyle used by a node
getLexeme
@io.github.qishr.cascara.common.annotation.Nullable
public abstract String getLexeme()
Returns the exact, unparsed text block directly from the file buffer.
getPrimitive
@io.github.qishr.cascara.common.annotation.Nullable
public abstract Object getPrimitive()
Returns the Java-native representation of the scalar (e.g., Integer, Boolean, String).
setPrimitive
public abstract ScalarAstNode
getPrimitiveType
public abstract PrimitiveType getPrimitiveType()
getContent
@io.github.qishr.cascara.common.annotation.Nullable
public abstract String getContent()
asString
public default String asString()
Returns the string form or the primitive.If the primitive is null, an empty string is returned.
Specified By:
asInteger
public default int asInteger()
asInteger
public default int asInteger(int defaultValue)
asLong
public default long asLong()
asLong
public default long asLong(long defaultValue)
asDouble
public default double asDouble()
asDouble
public default double asDouble(double defaultValue)
asBoolean
public default boolean asBoolean()
Returns the boolean value of the scalar, if there is one, otherwise results false.
asBoolean
public default boolean asBoolean(boolean defaultValue)
Returns the boolean value of the scalar, if there is one, otherwise the specified default is returned.