Package com.fauna.codec
Class UTF8FaunaParser
- java.lang.Object
-
- com.fauna.codec.UTF8FaunaParser
-
public final class UTF8FaunaParser extends java.lang.Object
Represents a reader that provides fast, non-cached, forward-only access to serialized data.
-
-
Constructor Summary
Constructors Constructor Description UTF8FaunaParser(com.fasterxml.jackson.core.JsonParser jsonParser)
Constructs aUTF8FaunaParser
instance with the given JSON parser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static UTF8FaunaParser
fromInputStream(java.io.InputStream body)
Creates aUTF8FaunaParser
from anInputStream
.static UTF8FaunaParser
fromString(java.lang.String str)
Creates aUTF8FaunaParser
from a JSON stringFaunaTokenType
getCurrentTokenType()
Retrieves the current Fauna token type.java.lang.String
getTaggedValueAsString()
Retrieves the tagged value as aString
.java.lang.Boolean
getValueAsBoolean()
Retrieves the current value as aBoolean
.java.lang.Byte
getValueAsByte()
Retrieves the value as aByte
if the current token type isFaunaTokenType.INT
.byte[]
getValueAsByteArray()
Retrieves the value as a byte array if the current token type isFaunaTokenType.BYTES
.java.lang.Character
getValueAsCharacter()
Retrieves the value as aCharacter
if the current token type isFaunaTokenType.INT
.java.lang.Double
getValueAsDouble()
Retrieves the value as aDouble
if the current token type isFaunaTokenType.INT
,FaunaTokenType.LONG
, orFaunaTokenType.DOUBLE
.java.lang.Float
getValueAsFloat()
Retrieves the value as aFloat
if the current token type isFaunaTokenType.INT
,FaunaTokenType.LONG
, orFaunaTokenType.DOUBLE
.java.lang.Integer
getValueAsInt()
Retrieves the value as anInteger
if the current token type isFaunaTokenType.INT
orFaunaTokenType.LONG
.java.time.LocalDate
getValueAsLocalDate()
Retrieves the current value as aLocalDate
if the current token type isFaunaTokenType.DATE
.java.lang.Long
getValueAsLong()
Retrieves the value as aLong
if the current token type isFaunaTokenType.INT
orFaunaTokenType.LONG
.Module
getValueAsModule()
Retrieves the value as aModule
if the current token type isFaunaTokenType.MODULE
.java.lang.Short
getValueAsShort()
Retrieves the value as aShort
if the current token type isFaunaTokenType.INT
.java.lang.String
getValueAsString()
Retrieves the current value as aString
.java.time.Instant
getValueAsTime()
Retrieves the current value as anInstant
if the current token type isFaunaTokenType.TIME
.boolean
read()
Reads the next token from the JSON parser.void
skip()
Skips the current object or array in the JSON data.
-
-
-
Method Detail
-
fromInputStream
public static UTF8FaunaParser fromInputStream(java.io.InputStream body) throws CodecException
Creates aUTF8FaunaParser
from anInputStream
.- Parameters:
body
- The input stream of JSON data.- Returns:
- A
UTF8FaunaParser
instance. - Throws:
CodecException
- if anIOException
occurs while creating the parser.
-
fromString
public static UTF8FaunaParser fromString(java.lang.String str)
Creates aUTF8FaunaParser
from a JSON string- Parameters:
str
- The JSON string.- Returns:
- A
UTF8FaunaParser
instance.
-
getCurrentTokenType
public FaunaTokenType getCurrentTokenType()
Retrieves the current Fauna token type.- Returns:
- The
FaunaTokenType
currently being processed.
-
skip
public void skip()
Skips the current object or array in the JSON data.
-
read
public boolean read() throws CodecException
Reads the next token from the JSON parser.- Returns:
true
if there is another token to read,false
if there are no more tokens.- Throws:
CodecException
- if there is an error reading the token.
-
getValueAsCharacter
public java.lang.Character getValueAsCharacter()
Retrieves the value as aCharacter
if the current token type isFaunaTokenType.INT
.- Returns:
- The current value as a
Character
.
-
getValueAsString
public java.lang.String getValueAsString()
Retrieves the current value as aString
.- Returns:
- The current value as a
String
.
-
getTaggedValueAsString
public java.lang.String getTaggedValueAsString()
Retrieves the tagged value as aString
.- Returns:
- The tagged value as a
String
.
-
getValueAsByteArray
public byte[] getValueAsByteArray()
Retrieves the value as a byte array if the current token type isFaunaTokenType.BYTES
.- Returns:
- The current value as a byte array.
-
getValueAsByte
public java.lang.Byte getValueAsByte()
Retrieves the value as aByte
if the current token type isFaunaTokenType.INT
.- Returns:
- The current value as a
Byte
.
-
getValueAsShort
public java.lang.Short getValueAsShort()
Retrieves the value as aShort
if the current token type isFaunaTokenType.INT
.- Returns:
- The current value as a
Short
.
-
getValueAsInt
public java.lang.Integer getValueAsInt()
Retrieves the value as anInteger
if the current token type isFaunaTokenType.INT
orFaunaTokenType.LONG
.- Returns:
- The current value as an
Integer
.
-
getValueAsBoolean
public java.lang.Boolean getValueAsBoolean()
Retrieves the current value as aBoolean
.- Returns:
- The current value as a
Boolean
.
-
getValueAsLocalDate
public java.time.LocalDate getValueAsLocalDate()
Retrieves the current value as aLocalDate
if the current token type isFaunaTokenType.DATE
.- Returns:
- The current value as a
LocalDate
.
-
getValueAsTime
public java.time.Instant getValueAsTime()
Retrieves the current value as anInstant
if the current token type isFaunaTokenType.TIME
.- Returns:
- The current value as an
Instant
.
-
getValueAsFloat
public java.lang.Float getValueAsFloat()
Retrieves the value as aFloat
if the current token type isFaunaTokenType.INT
,FaunaTokenType.LONG
, orFaunaTokenType.DOUBLE
.- Returns:
- The current value as a
Float
.
-
getValueAsDouble
public java.lang.Double getValueAsDouble()
Retrieves the value as aDouble
if the current token type isFaunaTokenType.INT
,FaunaTokenType.LONG
, orFaunaTokenType.DOUBLE
.- Returns:
- The current value as a
Double
.
-
getValueAsLong
public java.lang.Long getValueAsLong()
Retrieves the value as aLong
if the current token type isFaunaTokenType.INT
orFaunaTokenType.LONG
.- Returns:
- The current value as a
Long
.
-
getValueAsModule
public Module getValueAsModule()
Retrieves the value as aModule
if the current token type isFaunaTokenType.MODULE
.- Returns:
- The current value as a
Module
.
-
-