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.).EdgeandVertexobjects are serialized toMapinstances. If anElementis used as a key, it is coerced to its identifier. Other complex objects are converted viaObject.toString()unless there is a mapper serializer supplied.- Author:
- Stephen Mallette (http://stephen.genoprime.com)
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classGraphSONReader.Builder- 
Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.structure.io.GraphReaderGraphReader.ReaderBuilder<T extends GraphReader>
 
- 
 - 
Method Summary- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.tinkerpop.gremlin.structure.io.GraphReaderreadVertex
 
- 
 
- 
- 
- 
Method Detail- 
readGraphpublic void readGraph(InputStream inputStream, Graph graphToWriteTo) throws IOException Read data into aGraphfrom output generated by any of theGraphSONWriterwriteVertexorwriteVerticesmethods or byGryoWriter.writeGraph(OutputStream, Graph).- Specified by:
- readGraphin 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
 
 - 
readVerticespublic Iterator<Vertex> readVertices(InputStream inputStream, Function<Attachable<Vertex>,Vertex> vertexAttachMethod, Function<Attachable<Edge>,Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection) throws IOException ReadVertexobjects from output generated by any of theGraphSONWriterwriteVertexorwriteVerticesmethods or byGraphSONWriter.writeGraph(OutputStream, Graph).- Specified by:
- readVerticesin interface- GraphReader
- Parameters:
- inputStream- a stream containing at least one- Vertexas defined by the accompanying- GraphWriter.writeVertices(OutputStream, Iterator, Direction)or- GraphWriter.writeVertices(OutputStream, Iterator)methods.
- vertexAttachMethod- a function that creates re-attaches a- Vertexto a- Hostobject.
- edgeAttachMethod- a function that creates re-attaches a- Edgeto a- Hostobject.
- attachEdgesOfThisDirection- only edges of this direction are passed to the- edgeMaker.
- Throws:
- IOException
 
 - 
readVertexpublic Vertex readVertex(InputStream inputStream, Function<Attachable<Vertex>,Vertex> vertexAttachMethod) throws IOException Read aVertexfrom output generated by any of theGraphSONWriterwriteVertexorwriteVerticesmethods or byGraphSONWriter.writeGraph(OutputStream, Graph).- Specified by:
- readVertexin 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- Vertexto a- Hostobject.
- Throws:
- IOException
 
 - 
readVertexpublic Vertex readVertex(InputStream inputStream, Function<Attachable<Vertex>,Vertex> vertexAttachMethod, Function<Attachable<Edge>,Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection) throws IOException Read aVertexfrom output generated by any of theGraphSONWriterwriteVertexorwriteVerticesmethods or byGraphSONWriter.writeGraph(OutputStream, Graph).- Specified by:
- readVertexin interface- GraphReader
- Parameters:
- inputStream- a stream containing at least one- Vertexas defined by the accompanying- GraphWriter.writeVertices(OutputStream, Iterator, Direction)method.
- vertexAttachMethod- a function that creates re-attaches a- Vertexto a- Hostobject.
- edgeAttachMethod- a function that creates re-attaches a- Edgeto a- Hostobject.
- attachEdgesOfThisDirection- only edges of this direction are passed to the- edgeMaker.
- Throws:
- IOException
 
 - 
readEdgepublic Edge readEdge(InputStream inputStream, Function<Attachable<Edge>,Edge> edgeAttachMethod) throws IOException Read anEdgefrom output generated byGraphSONWriter.writeEdge(OutputStream, Edge)or via anEdgepassed toGraphSONWriter.writeObject(OutputStream, Object).- Specified by:
- readEdgein interface- GraphReader
- Parameters:
- inputStream- a stream containing at least one- Edgeas defined by the accompanying- GraphWriter.writeEdge(OutputStream, Edge)method.
- edgeAttachMethod- a function that creates re-attaches a- Edgeto a- Hostobject.
- Throws:
- IOException
 
 - 
readVertexPropertypublic VertexProperty readVertexProperty(InputStream inputStream, Function<Attachable<VertexProperty>,VertexProperty> vertexPropertyAttachMethod) throws IOException Read aVertexPropertyfrom output generated byGraphSONWriter.writeVertexProperty(OutputStream, VertexProperty)or via anVertexPropertypassed toGraphSONWriter.writeObject(OutputStream, Object).- Specified by:
- readVertexPropertyin interface- GraphReader
- Parameters:
- inputStream- a stream containing at least one- VertexPropertyas written by the accompanying- GraphWriter.writeVertexProperty(OutputStream, VertexProperty)method.
- vertexPropertyAttachMethod- a function that creates re-attaches a- VertexPropertyto a- Hostobject.
- Returns:
- the value returned by the attach method.
- Throws:
- IOException
 
 - 
readPropertypublic Property readProperty(InputStream inputStream, Function<Attachable<Property>,Property> propertyAttachMethod) throws IOException Read aPropertyfrom output generated byGraphSONWriter.writeProperty(OutputStream, Property)or via anPropertypassed toGraphSONWriter.writeObject(OutputStream, Object).- Specified by:
- readPropertyin interface- GraphReader
- Parameters:
- inputStream- a stream containing at least one- Propertyas written by the accompanying- GraphWriter.writeProperty(OutputStream, Property)method.
- propertyAttachMethod- a function that creates re-attaches a- Propertyto a- Hostobject.
- Returns:
- the value returned by the attach method.
- Throws:
- IOException
 
 - 
readObjectpublic <C> C readObject(InputStream inputStream, Class<? extends C> clazz) throws IOException Reads an arbitrary object using the registered serializers.- Specified by:
- readObjectin 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
 
 - 
buildpublic static GraphSONReader.Builder build() 
 
- 
 
-