Package com.fauna.codec
Class UTF8FaunaGenerator
- java.lang.Object
-
- com.fauna.codec.UTF8FaunaGenerator
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public final class UTF8FaunaGenerator extends java.lang.Object implements java.lang.AutoCloseableA generator for encoding JSON with Fauna-specific tagged values and other data types.
-
-
Constructor Summary
Constructors Constructor Description UTF8FaunaGenerator()Initializes a new instance of theUTF8FaunaGeneratorclass.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the generator and the underlying resources.static UTF8FaunaGeneratorcreate()Creates a newUTF8FaunaGeneratorinstance.voidflush()Flushes the written data to the underlying buffer or stream.java.lang.Stringserialize()Serializes the current state of the generator's buffer as a UTF-8 encoded string.voidwriteBoolean(java.lang.String fieldName, boolean value)Writes a boolean value with a specific field name.voidwriteBooleanValue(boolean value)Writes a boolean value to the stream.voidwriteBytesValue(byte[] value)Writes a byte array encoded as a base64 string as a tagged element.voidwriteCharValue(java.lang.Character value)Writes a character value as an integer.voidwriteDate(java.lang.String fieldName, java.time.LocalDate value)Writes a date value with a specific field name.voidwriteDateValue(java.time.LocalDate value)Writes a date value as a tagged element.voidwriteDouble(java.lang.String fieldName, double value)Writes a double value with a specific field name.voidwriteDoubleValue(double value)Writes a double value as a tagged element.voidwriteDoubleValue(float value)Writes a float value as a tagged element (@double).voidwriteEndArray()Writes the end of an array.voidwriteEndEscapedObject()Writes the end of a specially tagged object.voidwriteEndObject()Writes the end of an object.voidwriteEndRef()Writes the end of a reference object.voidwriteFieldName(java.lang.String value)Writes a field name for the next value.voidwriteInt(java.lang.String fieldName, int value)Writes an integer value with a specific field name.voidwriteIntValue(int value)Writes an integer value as a tagged element.voidwriteLong(java.lang.String fieldName, long value)Writes a long integer value with a specific field name.voidwriteLongValue(long value)Writes a long integer value as a tagged element.voidwriteModule(java.lang.String fieldName, Module value)Writes a module value with a specific field name.voidwriteModuleValue(Module value)Writes a module value as a tagged element.voidwriteNull(java.lang.String fieldName)Writes a null value with a specific field name.voidwriteNullValue()Writes a null value to the stream.voidwriteStartArray()Writes the beginning of an array.voidwriteStartEscapedObject()Writes the beginning of a specially tagged object.voidwriteStartObject()Writes the beginning of an object.voidwriteStartRef()Writes the beginning of a reference object.voidwriteString(java.lang.String fieldName, java.lang.String value)Writes a string value with a specific field name.voidwriteStringValue(java.lang.String value)Writes a string value as a tagged element.voidwriteTaggedValue(java.lang.String tag, java.lang.String value)Writes a tagged value in an object.voidwriteTime(java.lang.String fieldName, java.time.Instant value)Writes a time value with a specific field name.voidwriteTimeValue(java.time.Instant value)Writes a time value as a tagged element.
-
-
-
Method Detail
-
create
public static UTF8FaunaGenerator create() throws CodecException
Creates a newUTF8FaunaGeneratorinstance.- Returns:
- A new instance of the
UTF8FaunaGenerator. - Throws:
CodecException- If an I/O error occurs.
-
flush
public void flush() throws CodecExceptionFlushes the written data to the underlying buffer or stream.- Throws:
CodecException- If an I/O error occurs.
-
serialize
public java.lang.String serialize() throws CodecExceptionSerializes the current state of the generator's buffer as a UTF-8 encoded string.- Returns:
- A string representation of the serialized output.
- Throws:
CodecException- If an I/O error occurs.
-
writeStartObject
public void writeStartObject() throws CodecExceptionWrites the beginning of an object.- Throws:
CodecException- If an I/O error occurs.
-
writeEndObject
public void writeEndObject() throws CodecExceptionWrites the end of an object.- Throws:
CodecException- If an I/O error occurs.
-
writeStartEscapedObject
public void writeStartEscapedObject() throws CodecExceptionWrites the beginning of a specially tagged object.- Throws:
CodecException- If an I/O error occurs.
-
writeEndEscapedObject
public void writeEndEscapedObject() throws CodecExceptionWrites the end of a specially tagged object.- Throws:
CodecException- If an I/O error occurs.
-
writeStartArray
public void writeStartArray() throws CodecExceptionWrites the beginning of an array.- Throws:
CodecException- If an I/O error occurs.
-
writeEndArray
public void writeEndArray() throws CodecExceptionWrites the end of an array.- Throws:
CodecException- If an I/O error occurs.
-
writeStartRef
public void writeStartRef() throws CodecExceptionWrites the beginning of a reference object.- Throws:
CodecException- If an I/O error occurs.
-
writeEndRef
public void writeEndRef() throws CodecExceptionWrites the end of a reference object.- Throws:
CodecException- If an error occurs.
-
writeDouble
public void writeDouble(java.lang.String fieldName, double value) throws CodecExceptionWrites a double value with a specific field name.- Parameters:
fieldName- The name of the field.value- The double value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeInt
public void writeInt(java.lang.String fieldName, int value) throws CodecExceptionWrites an integer value with a specific field name.- Parameters:
fieldName- The name of the field.value- The integer value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeLong
public void writeLong(java.lang.String fieldName, long value) throws CodecExceptionWrites a long integer value with a specific field name.- Parameters:
fieldName- The name of the field.value- The long integer value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeString
public void writeString(java.lang.String fieldName, java.lang.String value) throws CodecExceptionWrites a string value with a specific field name.- Parameters:
fieldName- The name of the field.value- The string value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeDate
public void writeDate(java.lang.String fieldName, java.time.LocalDate value) throws CodecExceptionWrites a date value with a specific field name.- Parameters:
fieldName- The name of the field.value- The date value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeTime
public void writeTime(java.lang.String fieldName, java.time.Instant value) throws CodecExceptionWrites a time value with a specific field name.- Parameters:
fieldName- The name of the field.value- The time value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeBoolean
public void writeBoolean(java.lang.String fieldName, boolean value) throws CodecExceptionWrites a boolean value with a specific field name.- Parameters:
fieldName- The name of the field.value- The boolean value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeNull
public void writeNull(java.lang.String fieldName) throws CodecExceptionWrites a null value with a specific field name.- Parameters:
fieldName- The name of the field.- Throws:
CodecException- If an I/O error occurs.
-
writeModule
public void writeModule(java.lang.String fieldName, Module value) throws CodecExceptionWrites a module value with a specific field name.- Parameters:
fieldName- The name of the field.value- The Module value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeFieldName
public void writeFieldName(java.lang.String value) throws CodecExceptionWrites a field name for the next value.- Parameters:
value- The name of the field.- Throws:
CodecException- If an I/O error occurs.
-
writeTaggedValue
public void writeTaggedValue(java.lang.String tag, java.lang.String value) throws CodecExceptionWrites a tagged value in an object.- Parameters:
tag- The tag to use for the value.value- The value associated with the tag.- Throws:
CodecException- If an I/O error occurs.
-
writeDoubleValue
public void writeDoubleValue(double value) throws CodecExceptionWrites a double value as a tagged element.- Parameters:
value- The double value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeDoubleValue
public void writeDoubleValue(float value) throws CodecExceptionWrites a float value as a tagged element (@double).- Parameters:
value- The float value to write as a double.- Throws:
CodecException- If an I/O error occurs.
-
writeIntValue
public void writeIntValue(int value) throws CodecExceptionWrites an integer value as a tagged element.- Parameters:
value- The integer value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeLongValue
public void writeLongValue(long value) throws CodecExceptionWrites a long integer value as a tagged element.- Parameters:
value- The long integer value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeStringValue
public void writeStringValue(java.lang.String value) throws CodecExceptionWrites a string value as a tagged element.- Parameters:
value- The string value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeDateValue
public void writeDateValue(java.time.LocalDate value) throws CodecExceptionWrites a date value as a tagged element.- Parameters:
value- The date value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeTimeValue
public void writeTimeValue(java.time.Instant value) throws CodecExceptionWrites a time value as a tagged element.- Parameters:
value- The time value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeBooleanValue
public void writeBooleanValue(boolean value) throws CodecExceptionWrites a boolean value to the stream.- Parameters:
value- The boolean value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeCharValue
public void writeCharValue(java.lang.Character value) throws CodecExceptionWrites a character value as an integer.- Parameters:
value- The character value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeNullValue
public void writeNullValue() throws CodecExceptionWrites a null value to the stream.- Throws:
CodecException- If an I/O error occurs.
-
writeModuleValue
public void writeModuleValue(Module value) throws CodecException
Writes a module value as a tagged element.- Parameters:
value- The module value to write.- Throws:
CodecException- If an I/O error occurs.
-
writeBytesValue
public void writeBytesValue(byte[] value) throws CodecExceptionWrites a byte array encoded as a base64 string as a tagged element.- Parameters:
value- The byte array to write.- Throws:
CodecException- If an I/O error occurs.
-
close
public void close() throws CodecExceptionCloses the generator and the underlying resources.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
CodecException- If an I/O error occurs during closing.
-
-