org.apache.tinkerpop.gremlin.driver.ser.binary

## Class GraphBinaryWriter

- java.lang.Object
- - org.apache.tinkerpop.gremlin.driver.ser.binary.GraphBinaryWriter

-     public class GraphBinaryWriter
      extends Object

  Writes a value to a buffer using the `TypeSerializer` instances configured in the `TypeSerializerRegistry`.

  This class exposes two different methods to write a value to a buffer: `write(Object, ByteBuf)` and `writeValue(Object, ByteBuf, boolean)`:

  - `write()` method writes the binary representation of the `{type_code}{type_info}{value_flag}{value}` components.
  - `writeValue()` method writes the `{value_flag}{value}` when a value is nullable and only `{value}` when a value is not nullable.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static byte` | `VERSION_BYTE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GraphBinaryWriter()`
    `GraphBinaryWriter(TypeSerializerRegistry registry)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> void` | `write(T value, ByteBuf buffer)` Writes an object in fully-qualified format, containing {type_code}{type_info}{value_flag}{value}.
    `<T> void` | `writeFullyQualifiedNull(Class<T> objectClass, ByteBuf buffer, Object information)` Represents a null value of a specific type, useful when the parent type contains a type parameter that must be specified.
    `<T> void` | `writeValue(T value, ByteBuf buffer, boolean nullable)` Writes a value without including type information.
    `void` | `writeValueFlagNone(ByteBuf buffer)` Writes a single byte with value 0, representing an unset value_flag.
    `void` | `writeValueFlagNull(ByteBuf buffer)` Writes a single byte representing the null value_flag.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### VERSION_BYTE

          public static final byte VERSION_BYTE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### GraphBinaryWriter

          public GraphBinaryWriter()

    - #### GraphBinaryWriter

          public GraphBinaryWriter(TypeSerializerRegistry registry)

  - ### Method Detail

    - #### writeValue

          public <T> void writeValue(T value,
                                     ByteBuf buffer,
                                     boolean nullable)
                              throws SerializationException

      Writes a value without including type information.
      Throws:
        `SerializationException`

    - #### write

          public <T> void write(T value,
                                ByteBuf buffer)
                         throws SerializationException

      Writes an object in fully-qualified format, containing {type_code}{type_info}{value_flag}{value}.
      Throws:
        `SerializationException`

    - #### writeFullyQualifiedNull

          public <T> void writeFullyQualifiedNull(Class<T> objectClass,
                                                  ByteBuf buffer,
                                                  Object information)
                                           throws SerializationException

      Represents a null value of a specific type, useful when the parent type contains a type parameter that must be specified.

      Note that for simple types, the provided information will be `null`.

      Throws:
        `SerializationException`

    - #### writeValueFlagNull

          public void writeValueFlagNull(ByteBuf buffer)

      Writes a single byte representing the null value_flag.

    - #### writeValueFlagNone

          public void writeValueFlagNone(ByteBuf buffer)

      Writes a single byte with value 0, representing an unset value_flag.

Copyright © 2013–2019 Apache Software Foundation. All rights reserved.