Skip to content

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:
    ReferenceScalarNode, 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 PrimitiveType getPrimitiveType()
public abstract String getContent()
public abstract String asString() Returns the string form or the primitive.
public abstract int asInteger()
public abstract int asInteger(int defaultValue)
public abstract double asDouble()
public abstract double asDouble(double defaultValue)
public abstract boolean asBoolean() Returns the boolean value of the scalar, if there is one.
public abstract 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 setQuoteStyle(QuoteStyle style)

Sets the QuoteStyle used by a node


getLexeme

@io.github.qishr.cascara.common.lang.annotation.Nullable
public abstract String getLexeme()

Returns the exact, unparsed text block directly from the file buffer.


getPrimitive

@io.github.qishr.cascara.common.lang.annotation.Nullable
public abstract Object getPrimitive()

Returns the Java-native representation of the scalar (e.g., Integer, Boolean, String).


getPrimitiveType

public abstract PrimitiveType getPrimitiveType()


getContent

@io.github.qishr.cascara.common.lang.annotation.Nullable
public abstract String getContent()


asString

public abstract String asString()

Returns the string form or the primitive.If the primitive is null, an empty string is returned.

Specified By:

AstNode


asInteger

public abstract int asInteger()


asInteger

public abstract int asInteger(int defaultValue)


asDouble

public abstract double asDouble()


asDouble

public abstract double asDouble(double defaultValue)


asBoolean

public abstract boolean asBoolean()

Returns the boolean value of the scalar, if there is one.


asBoolean

public abstract boolean asBoolean(boolean defaultValue)

Returns the boolean value of the scalar, if there is one, otherwise the specified default is returned.