Class UTF8FaunaGenerator

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public final class UTF8FaunaGenerator
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A generator for encoding JSON with Fauna-specific tagged values and other data types.
    • Constructor Summary

      Constructors 
      Constructor Description
      UTF8FaunaGenerator()
      Initializes a new instance of the UTF8FaunaGenerator class.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the generator and the underlying resources.
      static UTF8FaunaGenerator create()
      Creates a new UTF8FaunaGenerator instance.
      void flush()
      Flushes the written data to the underlying buffer or stream.
      java.lang.String serialize()
      Serializes the current state of the generator's buffer as a UTF-8 encoded string.
      void writeBoolean​(java.lang.String fieldName, boolean value)
      Writes a boolean value with a specific field name.
      void writeBooleanValue​(boolean value)
      Writes a boolean value to the stream.
      void writeBytesValue​(byte[] value)
      Writes a byte array encoded as a base64 string as a tagged element.
      void writeCharValue​(java.lang.Character value)
      Writes a character value as an integer.
      void writeDate​(java.lang.String fieldName, java.time.LocalDate value)
      Writes a date value with a specific field name.
      void writeDateValue​(java.time.LocalDate value)
      Writes a date value as a tagged element.
      void writeDouble​(java.lang.String fieldName, double value)
      Writes a double value with a specific field name.
      void writeDoubleValue​(double value)
      Writes a double value as a tagged element.
      void writeDoubleValue​(float value)
      Writes a float value as a tagged element (@double).
      void writeEndArray()
      Writes the end of an array.
      void writeEndEscapedObject()
      Writes the end of a specially tagged object.
      void writeEndObject()
      Writes the end of an object.
      void writeEndRef()
      Writes the end of a reference object.
      void writeFieldName​(java.lang.String value)
      Writes a field name for the next value.
      void writeInt​(java.lang.String fieldName, int value)
      Writes an integer value with a specific field name.
      void writeIntValue​(int value)
      Writes an integer value as a tagged element.
      void writeLong​(java.lang.String fieldName, long value)
      Writes a long integer value with a specific field name.
      void writeLongValue​(long value)
      Writes a long integer value as a tagged element.
      void writeModule​(java.lang.String fieldName, Module value)
      Writes a module value with a specific field name.
      void writeModuleValue​(Module value)
      Writes a module value as a tagged element.
      void writeNull​(java.lang.String fieldName)
      Writes a null value with a specific field name.
      void writeNullValue()
      Writes a null value to the stream.
      void writeStartArray()
      Writes the beginning of an array.
      void writeStartEscapedObject()
      Writes the beginning of a specially tagged object.
      void writeStartObject()
      Writes the beginning of an object.
      void writeStartRef()
      Writes the beginning of a reference object.
      void writeString​(java.lang.String fieldName, java.lang.String value)
      Writes a string value with a specific field name.
      void writeStringValue​(java.lang.String value)
      Writes a string value as a tagged element.
      void writeTaggedValue​(java.lang.String tag, java.lang.String value)
      Writes a tagged value in an object.
      void writeTime​(java.lang.String fieldName, java.time.Instant value)
      Writes a time value with a specific field name.
      void writeTimeValue​(java.time.Instant value)
      Writes a time value as a tagged element.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UTF8FaunaGenerator

        public UTF8FaunaGenerator()
                           throws java.io.IOException
        Initializes a new instance of the UTF8FaunaGenerator class.
        Throws:
        java.io.IOException - If an error occurs during creation of the JSON generator.
    • Method Detail

      • flush

        public void flush()
                   throws CodecException
        Flushes the written data to the underlying buffer or stream.
        Throws:
        CodecException - If an I/O error occurs.
      • serialize

        public java.lang.String serialize()
                                   throws CodecException
        Serializes 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 CodecException
        Writes the beginning of an object.
        Throws:
        CodecException - If an I/O error occurs.
      • writeEndObject

        public void writeEndObject()
                            throws CodecException
        Writes the end of an object.
        Throws:
        CodecException - If an I/O error occurs.
      • writeStartEscapedObject

        public void writeStartEscapedObject()
                                     throws CodecException
        Writes the beginning of a specially tagged object.
        Throws:
        CodecException - If an I/O error occurs.
      • writeEndEscapedObject

        public void writeEndEscapedObject()
                                   throws CodecException
        Writes the end of a specially tagged object.
        Throws:
        CodecException - If an I/O error occurs.
      • writeStartArray

        public void writeStartArray()
                             throws CodecException
        Writes the beginning of an array.
        Throws:
        CodecException - If an I/O error occurs.
      • writeEndArray

        public void writeEndArray()
                           throws CodecException
        Writes the end of an array.
        Throws:
        CodecException - If an I/O error occurs.
      • writeStartRef

        public void writeStartRef()
                           throws CodecException
        Writes the beginning of a reference object.
        Throws:
        CodecException - If an I/O error occurs.
      • writeEndRef

        public void writeEndRef()
                         throws CodecException
        Writes the end of a reference object.
        Throws:
        CodecException - If an error occurs.
      • writeDouble

        public void writeDouble​(java.lang.String fieldName,
                                double value)
                         throws CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Writes 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 CodecException
        Closes the generator and the underlying resources.
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        CodecException - If an I/O error occurs during closing.