org.apache.tinkerpop.gremlin.driver

## Interface MessageSerializer

- All Known Subinterfaces:
    MessageTextSerializer
  All Known Implementing Classes:
    AbstractGraphSONMessageSerializerV1d0, AbstractGraphSONMessageSerializerV2d0, AbstractGryoMessageSerializerV1d0, AbstractGryoMessageSerializerV3d0, AbstractMessageSerializer, GraphSONMessageSerializerGremlinV1d0, GraphSONMessageSerializerGremlinV2d0, GraphSONMessageSerializerV1d0, GraphSONMessageSerializerV2d0, GraphSONMessageSerializerV3d0, GryoLiteMessageSerializerV1d0, GryoMessageSerializerV1d0, GryoMessageSerializerV3d0

      public interface MessageSerializer

  Serializes data to and from Gremlin Server. Typically the object being serialized or deserialized will be an item from an `Iterator` as returned from the `ScriptEngine` or an incoming `RequestMessage`. `MessageSerializer` instances are instantiated to a cache via `ServiceLoader` and indexed based on the mime types they support. If a mime type is supported more than once, the last `MessageSerializer` instance loaded for that mime type is assigned. If a mime type is not found the default `GraphSONMessageSerializerV1d0` is used to return the results.
  Author:
    Stephen Mallette (http://stephen.genoprime.com)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Logger` | `logger`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default void` | `configure(Map<String,Object> config, Map<String,Graph> graphs)` Configure the serializer with mapper settings as required.
    `RequestMessage` | `deserializeRequest(ByteBuf msg)` Deserialize a Netty `ByteBuf` into a `RequestMessage`.
    `ResponseMessage` | `deserializeResponse(ByteBuf msg)` Deserialize a Netty `ByteBuf` into a `ResponseMessage`.
    `String[]` | `mimeTypesSupported()` The list of mime types that the serializer supports.
    `ByteBuf` | `serializeRequestAsBinary(RequestMessage requestMessage, ByteBufAllocator allocator)` Serialize a `ResponseMessage` to a Netty `ByteBuf`.
    `ByteBuf` | `serializeResponseAsBinary(ResponseMessage responseMessage, ByteBufAllocator allocator)` Serialize a `ResponseMessage` to a Netty `ByteBuf`.

- - ### Field Detail

    - #### logger

          static final Logger logger

  - ### Method Detail

    - #### serializeResponseAsBinary

          ByteBuf serializeResponseAsBinary(ResponseMessage responseMessage,
                                            ByteBufAllocator allocator)
                                     throws SerializationException

      Serialize a `ResponseMessage` to a Netty `ByteBuf`.
      Parameters:
        `responseMessage` - The response message to serialize to bytes.
        `allocator` - The Netty allocator for the `ByteBuf` to return back.
      Throws:
        `SerializationException`

    - #### serializeRequestAsBinary

          ByteBuf serializeRequestAsBinary(RequestMessage requestMessage,
                                           ByteBufAllocator allocator)
                                    throws SerializationException

      Serialize a `ResponseMessage` to a Netty `ByteBuf`.
      Parameters:
        `requestMessage` - The request message to serialize to bytes.
        `allocator` - The Netty allocator for the `ByteBuf` to return back.
      Throws:
        `SerializationException`

    - #### deserializeRequest

          RequestMessage deserializeRequest(ByteBuf msg)
                                     throws SerializationException

      Deserialize a Netty `ByteBuf` into a `RequestMessage`.
      Throws:
        `SerializationException`

    - #### deserializeResponse

          ResponseMessage deserializeResponse(ByteBuf msg)
                                       throws SerializationException

      Deserialize a Netty `ByteBuf` into a `ResponseMessage`.
      Throws:
        `SerializationException`

    - #### mimeTypesSupported

          String[] mimeTypesSupported()

      The list of mime types that the serializer supports.

    - #### configure

          default void configure(Map<String,Object> config,
                                 Map<String,Graph> graphs)

      Configure the serializer with mapper settings as required. The default implementation does not perform any function and it is up to the interface implementation to determine how the configuration will be executed and what its requirements are. An implementation may choose to use the list of available graphs to help initialize a serializer. The implementation should account for the possibility of a null value being provided for that parameter.

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