org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException Java Examples
The following examples show how to use
org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TinkerIoRegistryV3d0.java From tinkergraph-gremlin with Apache License 2.0 | 6 votes |
@Override public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Configuration conf = new BaseConfiguration(); conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list"); final TinkerGraph graph = TinkerGraph.open(conf); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals("vertices")) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { if (jsonParser.currentToken() == JsonToken.START_OBJECT) { final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class); v.attach(Attachable.Method.getOrCreate(graph)); } } } else if (jsonParser.getCurrentName().equals("edges")) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { if (jsonParser.currentToken() == JsonToken.START_OBJECT) { final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class); e.attach(Attachable.Method.getOrCreate(graph)); } } } } return graph; }
Example #2
Source File: SchemaTable.java From sqlg with MIT License | 6 votes |
@SuppressWarnings("deprecation") @Override public void serializeWithType(final SchemaTable schemaTable, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException, JsonProcessingException { // when the type is included add "class" as a key and then try to utilize as much of the // default serialization provided by jackson data-bind as possible. for example, write // the uuid as an object so that when jackson serializes it, it uses the uuid serializer // to write it out with the type. in this way, data-bind should be able to deserialize // it back when types are embedded. typeSerializer.writeTypePrefixForScalar(schemaTable, jsonGenerator); final Map<String, Object> m = new LinkedHashMap<>(); m.put("schema", schemaTable.getSchema()); m.put("table", schemaTable.getTable()); jsonGenerator.writeObject(m); typeSerializer.writeTypeSuffixForScalar(schemaTable, jsonGenerator); }
Example #3
Source File: TinkerIoRegistryV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Configuration conf = new BaseConfiguration(); conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list"); final TinkerGraph graph = TinkerGraph.open(conf); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals("vertices")) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { if (jsonParser.currentToken() == JsonToken.START_OBJECT) { final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class); v.attach(Attachable.Method.getOrCreate(graph)); } } } else if (jsonParser.getCurrentName().equals("edges")) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { if (jsonParser.currentToken() == JsonToken.START_OBJECT) { final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class); e.attach(Attachable.Method.getOrCreate(graph)); } } } } return graph; }
Example #4
Source File: TinkerIoRegistryV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Configuration conf = new BaseConfiguration(); conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list"); final TinkerGraph graph = TinkerGraph.open(conf); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals("vertices")) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { if (jsonParser.currentToken() == JsonToken.START_OBJECT) { final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class); v.attach(Attachable.Method.getOrCreate(graph)); } } } else if (jsonParser.getCurrentName().equals("edges")) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { if (jsonParser.currentToken() == JsonToken.START_OBJECT) { final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class); e.attach(Attachable.Method.getOrCreate(graph)); } } } } return graph; }
Example #5
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Double deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { if (jsonParser.getCurrentToken().isNumeric()) return jsonParser.getDoubleValue(); else { final String numberText = jsonParser.getValueAsString(); if ("NaN".equalsIgnoreCase(numberText)) return Double.NaN; else if ("-Infinity".equals(numberText) || "-INF".equalsIgnoreCase(numberText)) return Double.NEGATIVE_INFINITY; else if ("Infinity".equals(numberText) || "INF".equals(numberText)) return Double.POSITIVE_INFINITY; else throw new IllegalStateException("Double value unexpected: " + numberText); } }
Example #6
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Path deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final JsonNode n = jsonParser.readValueAsTree(); final Path p = MutablePath.make(); final ArrayNode labels = (ArrayNode) n.get(GraphSONTokens.LABELS); final ArrayNode objects = (ArrayNode) n.get(GraphSONTokens.OBJECTS); for (int i = 0; i < objects.size(); i++) { final JsonParser po = objects.get(i).traverse(); po.nextToken(); final JsonParser pl = labels.get(i).traverse(); pl.nextToken(); p.extend(deserializationContext.readValue(po, Object.class), deserializationContext.readValue(pl, setType)); } return p; }
Example #7
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Property deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String key = null; Object value = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.KEY)) { jsonParser.nextToken(); key = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); value = deserializationContext.readValue(jsonParser, Object.class); } } return new DetachedProperty<>(key, value); }
Example #8
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
public Vertex deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final DetachedVertex.Builder v = DetachedVertex.build(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) { jsonParser.nextToken(); v.setId(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) { jsonParser.nextToken(); v.setLabel(jsonParser.getText()); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { v.addProperty((DetachedVertexProperty) deserializationContext.readValue(jsonParser, VertexProperty.class)); } } } } return v.create(); }
Example #9
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Traverser deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { long bulk = 1; Object v = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.BULK)) { jsonParser.nextToken(); bulk = deserializationContext.readValue(jsonParser, Long.class); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); v = deserializationContext.readValue(jsonParser, Object.class); } } return new DefaultRemoteTraverser<>(v, bulk); }
Example #10
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Bytecode.Binding deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String k = null; Object v = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.KEY)) { jsonParser.nextToken(); k = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); v = deserializationContext.readValue(jsonParser, Object.class); } } return new Bytecode.Binding<>(k, v); }
Example #11
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public TextP deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String predicate = null; String value = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.PREDICATE)) { jsonParser.nextToken(); predicate = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); value = deserializationContext.readValue(jsonParser, String.class); } } try { return (TextP) TextP.class.getMethod(predicate, String.class).invoke(null, value); } catch (final Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
Example #12
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Traverser deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { long bulk = 1; Object v = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.BULK)) { jsonParser.nextToken(); bulk = deserializationContext.readValue(jsonParser, Long.class); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); v = deserializationContext.readValue(jsonParser, Object.class); } } return new DefaultRemoteTraverser<>(v, bulk); }
Example #13
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Bytecode.Binding deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String k = null; Object v = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.KEY)) { jsonParser.nextToken(); k = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); v = deserializationContext.readValue(jsonParser, Object.class); } } return new Bytecode.Binding<>(k, v); }
Example #14
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public TextP deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String predicate = null; String value = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.PREDICATE)) { jsonParser.nextToken(); predicate = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); value = deserializationContext.readValue(jsonParser, String.class); } } try { return (TextP) TextP.class.getMethod(predicate, String.class).invoke(null, value); } catch (final Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
Example #15
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Double deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { if (jsonParser.getCurrentToken().isNumeric()) return jsonParser.getDoubleValue(); else { final String numberText = jsonParser.getValueAsString(); if ("NaN".equalsIgnoreCase(numberText)) return Double.NaN; else if ("-Infinity".equals(numberText) || "-INF".equalsIgnoreCase(numberText)) return Double.NEGATIVE_INFINITY; else if ("Infinity".equals(numberText) || "INF".equals(numberText)) return Double.POSITIVE_INFINITY; else throw new IllegalStateException("Double value unexpected: " + numberText); } }
Example #16
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Path deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Path p = MutablePath.make(); List<Object> labels = new ArrayList<>(); List<Object> objects = new ArrayList<>(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.LABELS)) { jsonParser.nextToken(); labels = deserializationContext.readValue(jsonParser, List.class); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OBJECTS)) { jsonParser.nextToken(); objects = deserializationContext.readValue(jsonParser, List.class); } } for (int i = 0; i < objects.size(); i++) { p.extend(objects.get(i), (Set<String>) labels.get(i)); } return p; }
Example #17
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Property deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String key = null; Object value = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.KEY)) { jsonParser.nextToken(); key = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); value = deserializationContext.readValue(jsonParser, Object.class); } } return new DetachedProperty<>(key, value); }
Example #18
Source File: AbstractGraphSONMessageSerializerV1d0.java From tinkerpop with Apache License 2.0 | 6 votes |
public void ser(final ResponseMessage responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException, JsonProcessingException { jsonGenerator.writeStartObject(); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); jsonGenerator.writeStringField(SerTokens.TOKEN_REQUEST, responseMessage.getRequestId() != null ? responseMessage.getRequestId().toString() : null); jsonGenerator.writeObjectFieldStart(SerTokens.TOKEN_STATUS); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); jsonGenerator.writeStringField(SerTokens.TOKEN_MESSAGE, responseMessage.getStatus().getMessage()); jsonGenerator.writeNumberField(SerTokens.TOKEN_CODE, responseMessage.getStatus().getCode().getValue()); jsonGenerator.writeObjectField(SerTokens.TOKEN_ATTRIBUTES, responseMessage.getStatus().getAttributes()); jsonGenerator.writeEndObject(); jsonGenerator.writeObjectFieldStart(SerTokens.TOKEN_RESULT); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); if (null == responseMessage.getResult().getData()) jsonGenerator.writeNullField(SerTokens.TOKEN_DATA); else GraphSONUtil.writeWithType(SerTokens.TOKEN_DATA, responseMessage.getResult().getData(), jsonGenerator, serializerProvider, typeSerializer); jsonGenerator.writeObjectField(SerTokens.TOKEN_META, responseMessage.getResult().getMeta()); jsonGenerator.writeEndObject(); jsonGenerator.writeEndObject(); }
Example #19
Source File: TinkerIoRegistryV2d0.java From tinkergraph-gremlin with Apache License 2.0 | 6 votes |
@Override public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Configuration conf = new BaseConfiguration(); conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list"); final TinkerGraph graph = TinkerGraph.open(conf); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals("vertices")) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { if (jsonParser.currentToken() == JsonToken.START_OBJECT) { final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class); v.attach(Attachable.Method.getOrCreate(graph)); } } } else if (jsonParser.getCurrentName().equals("edges")) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { if (jsonParser.currentToken() == JsonToken.START_OBJECT) { final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class); e.attach(Attachable.Method.getOrCreate(graph)); } } } } return graph; }
Example #20
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
public Vertex deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final DetachedVertex.Builder v = DetachedVertex.build(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) { jsonParser.nextToken(); v.setId(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) { jsonParser.nextToken(); v.setLabel(jsonParser.getText()); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { v.addProperty((DetachedVertexProperty) deserializationContext.readValue(jsonParser, VertexProperty.class)); } } } } return v.create(); }
Example #21
Source File: CustomId.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final CustomId customId, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException, JsonProcessingException { // when the type is included add "class" as a key and then try to utilize as much of the // default serialization provided by jackson data-bind as possible. for example, write // the uuid as an object so that when jackson serializes it, it uses the uuid serializer // to write it out with the type. in this way, data-bind should be able to deserialize // it back when types are embedded. jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.CLASS, CustomId.class.getName()); jsonGenerator.writeStringField("cluster", customId.getCluster()); jsonGenerator.writeObjectField("elementId", customId.getElementId()); jsonGenerator.writeEndObject(); }
Example #22
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Lambda deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String script = null; String language = null; int arguments = -1; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.SCRIPT)) { jsonParser.nextToken(); script = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LANGUAGE)) { jsonParser.nextToken(); language = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.ARGUMENTS)) { jsonParser.nextToken(); arguments = jsonParser.getIntValue(); } } if (-1 == arguments || arguments > 2) return new Lambda.UnknownArgLambda(script, language, arguments); else if (0 == arguments) return new Lambda.ZeroArgLambda<>(script, language); else if (1 == arguments) return new Lambda.OneArgLambda<>(script, language); else return new Lambda.TwoArgLambda<>(script, language); }
Example #23
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Edge deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final DetachedEdge.Builder e = DetachedEdge.build(); final DetachedVertex.Builder inV = DetachedVertex.build(); final DetachedVertex.Builder outV = DetachedVertex.build(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) { jsonParser.nextToken(); e.setId(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) { jsonParser.nextToken(); e.setLabel(jsonParser.getText()); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OUT)) { jsonParser.nextToken(); outV.setId(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OUT_LABEL)) { jsonParser.nextToken(); outV.setLabel(jsonParser.getText()); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.IN)) { jsonParser.nextToken(); inV.setId(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.IN_LABEL)) { jsonParser.nextToken(); inV.setLabel(jsonParser.getText()); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { jsonParser.nextToken(); e.addProperty(deserializationContext.readValue(jsonParser, Property.class)); } } } e.setInV(inV.create()); e.setOutV(outV.create()); return e.create(); }
Example #24
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public VertexProperty deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final DetachedVertexProperty.Builder vp = DetachedVertexProperty.build(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) { jsonParser.nextToken(); vp.setId(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) { jsonParser.nextToken(); vp.setLabel(jsonParser.getText()); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); vp.setValue(deserializationContext.readValue(jsonParser, Object.class)); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { final String key = jsonParser.getCurrentName(); jsonParser.nextToken(); final Object val = deserializationContext.readValue(jsonParser, Object.class); vp.addProperty(new DetachedProperty(key, val)); } } } return vp.create(); }
Example #25
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public TraversalExplanation deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Map<String, Object> explainData = deserializationContext.readValue(jsonParser, Map.class); final String originalTraversal = explainData.get(GraphSONTokens.ORIGINAL).toString(); final List<Triplet<String, String, String>> intermediates = new ArrayList<>(); final List<Map<String,Object>> listMap = (List<Map<String,Object>>) explainData.get(GraphSONTokens.INTERMEDIATE); for (Map<String,Object> m : listMap) { intermediates.add(Triplet.with(m.get(GraphSONTokens.STRATEGY).toString(), m.get(GraphSONTokens.CATEGORY).toString(), m.get(GraphSONTokens.TRAVERSAL).toString())); } return new ImmutableExplanation(originalTraversal, intermediates); }
Example #26
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Tree deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final List<Map> data = deserializationContext.readValue(jsonParser, List.class); final Tree t = new Tree(); for (Map<String, Object> entry : data) { t.put(entry.get(GraphSONTokens.KEY), entry.get(GraphSONTokens.VALUE)); } return t; }
Example #27
Source File: TitanGraphSONModule.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Override public RelationIdentifier deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { if (!jsonParser.getText().equals(FIELD_RELATION_ID)) throw new IOException(String.format("Invalid serialization format for %s", RelationIdentifier.class)); final RelationIdentifier ri = RelationIdentifier.parse(jsonParser.nextTextValue()); jsonParser.nextToken(); return ri; }
Example #28
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public BulkSet deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final BulkSet<Object> bulkSet = new BulkSet<>(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { final Object key = deserializationContext.readValue(jsonParser, Object.class); jsonParser.nextToken(); final Long val = deserializationContext.readValue(jsonParser, Long.class); bulkSet.add(key, val); } return bulkSet; }
Example #29
Source File: CustomId.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final CustomId customId, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException, JsonProcessingException { // when the type is included add "class" as a key and then try to utilize as much of the // default serialization provided by jackson data-bind as possible. for example, write // the uuid as an object so that when jackson serializes it, it uses the uuid serializer // to write it out with the type. in this way, data-bind should be able to deserialize // it back when types are embedded. typeSerializer.writeTypePrefixForScalar(customId, jsonGenerator); final Map<String, Object> m = new HashMap<>(); m.put("cluster", customId.getCluster()); m.put("elementId", customId.getElementId()); jsonGenerator.writeObject(m); typeSerializer.writeTypeSuffixForScalar(customId, jsonGenerator); }
Example #30
Source File: TitanGraphSONModule.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final RelationIdentifier relationIdentifier, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException, JsonProcessingException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.CLASS, RelationIdentifier.class.getName()); jsonGenerator.writeStringField(FIELD_RELATION_ID, relationIdentifier.toString()); jsonGenerator.writeEndObject(); }