Skip to content

Package io.github.qishr.cascara.lang.json.ast

Class JsonScalar

java.lang.Object
        io.github.qishr.cascara.lang.json.ast.JsonNode
                io.github.qishr.cascara.lang.json.ast.JsonScalar

All Implemented Interfaces:
    ScalarAstNode<JsonNode>


public class JsonScalar
extends JsonNode

Constructor Summary

Constructor Description
JsonScalar(JsonToken token, PrimitiveType primitiveType, boolean isKey, JsonOptions options) Constructor for use in parsers.
JsonScalar(Object jvmValue, QuoteStyle quoteStyle, boolean isKey, JsonOptions options)
JsonScalar(Object content, JsonOptions options)
JsonScalar(Object jvmValue, QuoteStyle quoteStyle) A programmatic and serializer constructor.
JsonScalar(Object jvmValue) A programmatic and serializer constructor.
JsonScalar(JsonToken tok, Object jvmValue)
JsonScalar(Object jvmValue, boolean isKey) A programmatic and serializer constructor.
JsonScalar() The default constructor

Method Summary

Modifier and Type Method Description
public PrimitiveType getPrimitiveType()
public QuoteStyle getQuoteStyle()
public JsonScalar setQuoteStyle(QuoteStyle style)
public String getLexeme()
public String getContent()
public Object getPrimitive() Returns the dialect-aware JVM value (cached).
public String asString() Returns the logical clean text value, stripped of outer formatting and escape markers.
public int asInteger()
public int asInteger(int defaultValue)
public double asDouble()
public double asDouble(double defaultValue)
public boolean asBoolean()
public boolean asBoolean(boolean defaultValue) Returns the boolean value of the scalar, if there is one, otherwise the specified default is returned.
public List<JsonNode> getChildren() Scalars are leaf nodes and have no children.
public boolean equals(Object o)
public int hashCode()
public String toString()
public JsonOptions getOptions()

Methods inherited from JsonNode

getEndColumn, getEndLine, getComments, getStartColumn, getToken, setToken, addComment, getStartLine

Method Details

getPrimitiveType

public PrimitiveType getPrimitiveType()

Specified By:

ScalarAstNode


getQuoteStyle

public QuoteStyle getQuoteStyle()

Specified By:

ScalarAstNode


setQuoteStyle

public JsonScalar setQuoteStyle(QuoteStyle style)

Specified By:

ScalarAstNode


getLexeme

public String getLexeme()

Specified By:

ScalarAstNode


getContent

public String getContent()

Specified By:

ScalarAstNode


getPrimitive

public Object getPrimitive()

Returns the dialect-aware JVM value (cached).

Specified By:

ScalarAstNode


asString

public String asString()

Returns the logical clean text value, stripped of outer formatting and escape markers.

Specified By:

ScalarAstNode


asInteger

public int asInteger()

Specified By:

ScalarAstNode


asInteger

public int asInteger(int defaultValue)

Specified By:

ScalarAstNode


asDouble

public double asDouble()

Specified By:

ScalarAstNode


asDouble

public double asDouble(double defaultValue)

Specified By:

ScalarAstNode


asBoolean

public boolean asBoolean()

Specified By:

ScalarAstNode


asBoolean

public boolean asBoolean(boolean defaultValue)

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

Specified By:

ScalarAstNode


getChildren

public List<JsonNode> getChildren()

Scalars are leaf nodes and have no children.

Overrides:

JsonNode


equals

public boolean equals(Object o)

Overrides:

JsonNode


hashCode

public int hashCode()

Overrides:

JsonNode


toString

public String toString()

Overrides:

Object


getOptions

public JsonOptions getOptions()