org.apache.tinkerpop.gremlin.structure.io.binary

## Class GraphBinaryReader

- java.lang.Object
- - org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader

-     public class GraphBinaryReader
      extends Object

  Reads a value from a buffer using the `TypeSerializer` instances configured in the `TypeSerializerRegistry`.

  This class exposes two different methods to read a value from a buffer: `read(Buffer)` and `readValue(Buffer, Class, boolean)`:

  - `read()` method expects a value in fully-qualified format, composed of `{type_code}{type_info}{value_flag}{value}`.
  - `readValue()` method expects a `{value_flag}{value}` when a value is nullable and only `{value}` when a value is not nullable.

  The `GraphBinaryReader` should be used to read a nested known type from a `TypeSerializer`. For example, if a POINT type is composed by two doubles representing the position in the x and y axes, a `TypeSerializer` for POINT type should use the provided `GraphBinaryReader` instance to read those two double values. As x and y values are expected to be provided as non-nullable doubles, the method `readValue()` should be used: `readValue(buffer, Double.class, false)`

- - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> T` | `read(Buffer buffer)` Reads the type code, information and value of a given buffer with fully-qualified format.
    `<T> T` | `readValue(Buffer buffer, Class<T> type, boolean nullable)` Reads a value for an specific type.

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

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

- - ### Constructor Detail

    - #### GraphBinaryReader

          public GraphBinaryReader()

    - #### GraphBinaryReader

          public GraphBinaryReader(TypeSerializerRegistry registry)

  - ### Method Detail

    - #### readValue

          public <T> T readValue(Buffer buffer,
                                 Class<T> type,
                                 boolean nullable)
                          throws IOException

      Reads a value for an specific type.

      When the value is nullable, the reader expects the `{value_flag}{value}` to be contained in the buffer.

      When the value is not nullable, the reader expects only the `{value}` to be contained in the buffer.

      Throws:
        `IOException`

    - #### read

          public <T> T read(Buffer buffer)
                     throws IOException

      Reads the type code, information and value of a given buffer with fully-qualified format.
      Throws:
        `IOException`

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