org.apache.tinkerpop.gremlin.structure.io.graphson

## Class GraphSONReader

- java.lang.Object
- - org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader

- All Implemented Interfaces:
    GraphReader

      public final class GraphSONReader
      extends Object
      implements GraphReader

  A @{link GraphReader} that constructs a graph from a JSON-based representation of a graph and its elements. This implementation only supports JSON data types and is therefore lossy with respect to data types (e.g. a float will become a double, element IDs may not be retrieved in the format they were serialized, etc.). `Edge` and `Vertex` objects are serialized to `Map` instances. If an `Element` is used as a key, it is coerced to its identifier. Other complex objects are converted via `Object.toString()` unless there is a mapper serializer supplied.
  Author:
    Stephen Mallette (http://stephen.genoprime.com)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `GraphSONReader.Builder`

    - ### Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.structure.io.GraphReader

      `GraphReader.ReaderBuilder<T extends GraphReader>`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static GraphSONReader.Builder` | `build()`
    `Edge` | `readEdge(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod)` Read an `Edge` from output generated by `GraphSONWriter.writeEdge(OutputStream, Edge)` or via an `Edge` passed to `GraphSONWriter.writeObject(OutputStream, Object)`.
    `void` | `readGraph(InputStream inputStream, Graph graphToWriteTo)` Read data into a `Graph` from output generated by any of the `GraphSONWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.writeGraph(OutputStream, Graph)`.
    `<C> C` | `readObject(InputStream inputStream, Class<? extends C> clazz)` Reads an arbitrary object using the registered serializers.
    `Property` | `readProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Property>,Property> propertyAttachMethod)` Read a `Property` from output generated by `GraphSONWriter.writeProperty(OutputStream, Property)` or via an `Property` passed to `GraphSONWriter.writeObject(OutputStream, Object)`.
    `Vertex` | `readVertex(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod)` Read a `Vertex` from output generated by any of the `GraphSONWriter` `writeVertex` or `writeVertices` methods or by `GraphSONWriter.writeGraph(OutputStream, Graph)`.
    `Vertex` | `readVertex(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection)` Read a `Vertex` from output generated by any of the `GraphSONWriter` `writeVertex` or `writeVertices` methods or by `GraphSONWriter.writeGraph(OutputStream, Graph)`.
    `VertexProperty` | `readVertexProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<VertexProperty>,VertexProperty> vertexPropertyAttachMethod)` Read a `VertexProperty` from output generated by `GraphSONWriter.writeVertexProperty(OutputStream, VertexProperty)` or via an `VertexProperty` passed to `GraphSONWriter.writeObject(OutputStream, Object)`.
    `Iterator<Vertex>` | `readVertices(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection)` Read `Vertex` objects from output generated by any of the `GraphSONWriter` `writeVertex` or `writeVertices` methods or by `GraphSONWriter.writeGraph(OutputStream, Graph)`.

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

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

    - ### Methods inherited from interface org.apache.tinkerpop.gremlin.structure.io.GraphReader

      `readVertex`

- - ### Method Detail

    - #### readGraph

          public void readGraph(InputStream inputStream,
                                Graph graphToWriteTo)
                         throws IOException

      Read data into a `Graph` from output generated by any of the `GraphSONWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.writeGraph(OutputStream, Graph)`.
      Specified by:
        `readGraph` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing an entire graph of vertices and edges as defined by the accompanying `GraphSONWriter.writeGraph(OutputStream, Graph)`.
        `graphToWriteTo` - the graph to write to when reading from the stream.
      Throws:
        `IOException`

    - #### readVertices

          public Iterator<Vertex> readVertices(InputStream inputStream,
                                               Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod,
                                               Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod,
                                               Direction attachEdgesOfThisDirection)
                                        throws IOException

      Read `Vertex` objects from output generated by any of the `GraphSONWriter` `writeVertex` or `writeVertices` methods or by `GraphSONWriter.writeGraph(OutputStream, Graph)`.
      Specified by:
        `readVertices` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `Vertex` as defined by the accompanying `GraphWriter.writeVertices(OutputStream, Iterator, Direction)` or `GraphWriter.writeVertices(OutputStream, Iterator)` methods.
        `vertexAttachMethod` - a function that creates re-attaches a `Vertex` to a `Host` object.
        `edgeAttachMethod` - a function that creates re-attaches a `Edge` to a `Host` object.
        `attachEdgesOfThisDirection` - only edges of this direction are passed to the `edgeMaker`.
      Throws:
        `IOException`

    - #### readVertex

          public Vertex readVertex(InputStream inputStream,
                                   Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod)
                            throws IOException

      Read a `Vertex` from output generated by any of the `GraphSONWriter` `writeVertex` or `writeVertices` methods or by `GraphSONWriter.writeGraph(OutputStream, Graph)`.
      Specified by:
        `readVertex` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least a single vertex as defined by the accompanying `GraphWriter.writeVertex(OutputStream, Vertex)`.
        `vertexAttachMethod` - a function that creates re-attaches a `Vertex` to a `Host` object.
      Throws:
        `IOException`

    - #### readVertex

          public Vertex readVertex(InputStream inputStream,
                                   Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod,
                                   Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod,
                                   Direction attachEdgesOfThisDirection)
                            throws IOException

      Read a `Vertex` from output generated by any of the `GraphSONWriter` `writeVertex` or `writeVertices` methods or by `GraphSONWriter.writeGraph(OutputStream, Graph)`.
      Specified by:
        `readVertex` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `Vertex` as defined by the accompanying `GraphWriter.writeVertices(OutputStream, Iterator, Direction)` method.
        `vertexAttachMethod` - a function that creates re-attaches a `Vertex` to a `Host` object.
        `edgeAttachMethod` - a function that creates re-attaches a `Edge` to a `Host` object.
        `attachEdgesOfThisDirection` - only edges of this direction are passed to the `edgeMaker`.
      Throws:
        `IOException`

    - #### readEdge

          public Edge readEdge(InputStream inputStream,
                               Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod)
                        throws IOException

      Read an `Edge` from output generated by `GraphSONWriter.writeEdge(OutputStream, Edge)` or via an `Edge` passed to `GraphSONWriter.writeObject(OutputStream, Object)`.
      Specified by:
        `readEdge` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `Edge` as defined by the accompanying `GraphWriter.writeEdge(OutputStream, Edge)` method.
        `edgeAttachMethod` - a function that creates re-attaches a `Edge` to a `Host` object.
      Throws:
        `IOException`

    - #### readVertexProperty

          public VertexProperty readVertexProperty(InputStream inputStream,
                                                   Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<VertexProperty>,VertexProperty> vertexPropertyAttachMethod)
                                            throws IOException

      Read a `VertexProperty` from output generated by `GraphSONWriter.writeVertexProperty(OutputStream, VertexProperty)` or via an `VertexProperty` passed to `GraphSONWriter.writeObject(OutputStream, Object)`.
      Specified by:
        `readVertexProperty` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `VertexProperty` as written by the accompanying `GraphWriter.writeVertexProperty(OutputStream, VertexProperty)` method.
        `vertexPropertyAttachMethod` - a function that creates re-attaches a `VertexProperty` to a `Host` object.
      Returns:
        the value returned by the attach method.
      Throws:
        `IOException`

    - #### readProperty

          public Property readProperty(InputStream inputStream,
                                       Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Property>,Property> propertyAttachMethod)
                                throws IOException

      Read a `Property` from output generated by `GraphSONWriter.writeProperty(OutputStream, Property)` or via an `Property` passed to `GraphSONWriter.writeObject(OutputStream, Object)`.
      Specified by:
        `readProperty` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `Property` as written by the accompanying `GraphWriter.writeProperty(OutputStream, Property)` method.
        `propertyAttachMethod` - a function that creates re-attaches a `Property` to a `Host` object.
      Returns:
        the value returned by the attach method.
      Throws:
        `IOException`

    - #### readObject

          public <C> C readObject(InputStream inputStream,
                                  Class<? extends C> clazz)
                           throws IOException

      Reads an arbitrary object using the registered serializers.
      Specified by:
        `readObject` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing an object.
        `clazz` - the class expected to be in the stream - may or may not be used by the underlying implementation.
      Throws:
        `IOException`

    - #### build

          public static GraphSONReader.Builder build()

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