org.apache.tinkerpop.shaded.jackson.databind.SerializerProvider Java Examples
The following examples show how to use
org.apache.tinkerpop.shaded.jackson.databind.SerializerProvider.
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: 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 #2
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 6 votes |
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer, final boolean normalize) throws IOException { // when "detached" you can't check features of the graph it detached from so it has to be // treated differently from a regular VertexProperty implementation. if (property instanceof DetachedVertexProperty) { // only write meta properties key if they exist if (property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, serializerProvider, typeSerializer, normalize); } } else { // still attached - so we can check the features to see if it's worth even trying to write the // meta properties key if (property.graph().features().vertex().supportsMetaProperties() && property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, serializerProvider, typeSerializer, normalize); } } }
Example #3
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 #4
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public void serialize(final Metrics metrics, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { final Map<String, Object> m = new HashMap<>(); m.put(GraphSONTokens.ID, metrics.getId()); m.put(GraphSONTokens.NAME, metrics.getName()); m.put(GraphSONTokens.COUNTS, metrics.getCounts()); m.put(GraphSONTokens.DURATION, metrics.getDuration(TimeUnit.NANOSECONDS) / 1000000d); if (!metrics.getAnnotations().isEmpty()) { m.put(GraphSONTokens.ANNOTATIONS, metrics.getAnnotations()); } if (!metrics.getNested().isEmpty()) { final List<Metrics> nested = new ArrayList<>(); metrics.getNested().forEach(it -> nested.add(it)); m.put(GraphSONTokens.METRICS, nested); } jsonGenerator.writeObject(m); }
Example #5
Source File: JavaUtilSerializersV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
private static void ser(final Map.Entry entry, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { // this treatment of keys is consistent with the current GraphSONKeySerializer which extends the // StdKeySerializer final Object key = entry.getKey(); final Class cls = key.getClass(); String k; if (cls == String.class) k = (String) key; else if (Element.class.isAssignableFrom(cls)) k = ((Element) key).id().toString(); else if(Date.class.isAssignableFrom(cls)) { if (serializerProvider.isEnabled(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS)) k = String.valueOf(((Date) key).getTime()); else k = serializerProvider.getConfig().getDateFormat().format((Date) key); } else if(cls == Class.class) k = ((Class) key).getName(); else k = key.toString(); serializerProvider.defaultSerializeField(k, entry.getValue(), jsonGenerator); }
Example #6
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public void serialize(final TraversalExplanation traversalExplanation, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { final Map<String, Object> m = new HashMap<>(); m.put(GraphSONTokens.ORIGINAL, getStepsAsList(traversalExplanation.getOriginalTraversal())); final List<Pair<TraversalStrategy, Traversal.Admin<?, ?>>> strategyTraversals = traversalExplanation.getStrategyTraversals(); final List<Map<String, Object>> intermediates = new ArrayList<>(); for (final Pair<TraversalStrategy, Traversal.Admin<?, ?>> pair : strategyTraversals) { final Map<String, Object> intermediate = new HashMap<>(); intermediate.put(GraphSONTokens.STRATEGY, pair.getValue0().toString()); intermediate.put(GraphSONTokens.CATEGORY, pair.getValue0().getTraversalCategory().getSimpleName()); intermediate.put(GraphSONTokens.TRAVERSAL, getStepsAsList(pair.getValue1())); intermediates.add(intermediate); } m.put(GraphSONTokens.INTERMEDIATE, intermediates); if (strategyTraversals.isEmpty()) m.put(GraphSONTokens.FINAL, getStepsAsList(traversalExplanation.getOriginalTraversal())); else m.put(GraphSONTokens.FINAL, getStepsAsList(strategyTraversals.get(strategyTraversals.size() - 1).getValue1())); jsonGenerator.writeObject(m); }
Example #7
Source File: TinkerIoRegistryV2d0.java From tinkergraph-gremlin with Apache License 2.0 | 6 votes |
@Override public void serialize(final TinkerGraph graph, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeFieldName(GraphSONTokens.VERTICES); jsonGenerator.writeStartArray(); final Iterator<Vertex> vertices = graph.vertices(); while (vertices.hasNext()) { serializerProvider.defaultSerializeValue(vertices.next(), jsonGenerator); } jsonGenerator.writeEndArray(); jsonGenerator.writeFieldName(GraphSONTokens.EDGES); jsonGenerator.writeStartArray(); final Iterator<Edge> edges = graph.edges(); while (edges.hasNext()) { serializerProvider.defaultSerializeValue(edges.next(), jsonGenerator); } jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); }
Example #8
Source File: RecordId.java From sqlg with MIT License | 6 votes |
@SuppressWarnings("deprecation") @Override public void serializeWithType(final RecordId recordId, 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(recordId, jsonGenerator); final Map<String, Object> m = new LinkedHashMap<>(); m.put("schemaTable", recordId.getSchemaTable()); if (recordId.hasSequenceId()) { m.put("id", recordId.sequenceId()); } else { m.put("id", recordId.getIdentifiers()); } jsonGenerator.writeObject(m); typeSerializer.writeTypeSuffixForScalar(recordId, jsonGenerator); }
Example #9
Source File: MetricsModule.java From hugegraph with Apache License 2.0 | 6 votes |
@Override public void serialize(Histogram histogram, JsonGenerator json, SerializerProvider provider) throws IOException { json.writeStartObject(); final Snapshot snapshot = histogram.getSnapshot(); json.writeNumberField("count", histogram.getCount()); json.writeNumberField("max", snapshot.getMax()); json.writeNumberField("mean", snapshot.getMean()); json.writeNumberField("min", snapshot.getMin()); json.writeNumberField("p50", snapshot.getMedian()); json.writeNumberField("p75", snapshot.get75thPercentile()); json.writeNumberField("p95", snapshot.get95thPercentile()); json.writeNumberField("p98", snapshot.get98thPercentile()); json.writeNumberField("p99", snapshot.get99thPercentile()); json.writeNumberField("p999", snapshot.get999thPercentile()); if (this.showSamples) { json.writeObjectField("values", snapshot.getValues()); } json.writeNumberField("stddev", snapshot.getStdDev()); json.writeEndObject(); }
Example #10
Source File: MetricsModule.java From hugegraph with Apache License 2.0 | 6 votes |
@Override public void serialize(Meter meter, JsonGenerator json, SerializerProvider provider) throws IOException { json.writeStartObject(); json.writeNumberField("count", meter.getCount()); json.writeNumberField("m15_rate", meter.getFifteenMinuteRate() * this.rateFactor); json.writeNumberField("m1_rate", meter.getOneMinuteRate() * this.rateFactor); json.writeNumberField("m5_rate", meter.getFiveMinuteRate() * this.rateFactor); json.writeNumberField("mean_rate", meter.getMeanRate() * this.rateFactor); json.writeStringField("units", this.rateUnit); json.writeEndObject(); }
Example #11
Source File: SchemaTable.java From sqlg with MIT License | 5 votes |
@Override public void serialize(final SchemaTable schemaTable, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { // when types are not embedded, stringify or resort to JSON primitive representations of the // type so that non-jvm languages can better interoperate with the TinkerPop stack. jsonGenerator.writeString(schemaTable.toString()); }
Example #12
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final TraversalStrategy traversalStrategy, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); for (final Map.Entry<Object, Object> entry : ConfigurationConverter.getMap(traversalStrategy.getConfiguration()).entrySet()) { jsonGenerator.writeObjectField((String) entry.getKey(), entry.getValue()); } jsonGenerator.writeEndObject(); }
Example #13
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private void ser(final Object o, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { if (Element.class.isAssignableFrom(o.getClass())) jsonGenerator.writeFieldName((((Element) o).id()).toString()); else super.serialize(o, jsonGenerator, serializerProvider); }
Example #14
Source File: JavaUtilSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Map.Entry entry, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); ser(entry, jsonGenerator, serializerProvider); jsonGenerator.writeEndObject(); }
Example #15
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Tree tree, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { jsonGenerator.writeStartArray(); final Set<Map.Entry<Element, Tree>> set = tree.entrySet(); for (Map.Entry<Element, Tree> entry : set) { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.KEY, entry.getKey()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, entry.getValue()); jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); }
Example #16
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Path path, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { jsonGenerator.writeStartObject(); // paths shouldn't serialize with properties if the path contains graph elements final Path p = DetachedFactory.detach(path, false); jsonGenerator.writeObjectField(GraphSONTokens.LABELS, p.labels()); jsonGenerator.writeObjectField(GraphSONTokens.OBJECTS, p.objects()); jsonGenerator.writeEndObject(); }
Example #17
Source File: JavaUtilSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final Map.Entry entry, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { typeSerializer.writeTypePrefixForObject(entry, jsonGenerator); ser(entry, jsonGenerator, serializerProvider); typeSerializer.writeTypeSuffixForObject(entry, jsonGenerator); }
Example #18
Source File: AbstractGraphSONMessageSerializerV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
public void ser(final RequestMessage requestMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { GraphSONUtil.writeStartObject(requestMessage, jsonGenerator, typeSerializer); jsonGenerator.writeStringField(SerTokens.TOKEN_REQUEST, requestMessage.getRequestId().toString()); jsonGenerator.writeStringField(SerTokens.TOKEN_OP, requestMessage.getOp()); jsonGenerator.writeStringField(SerTokens.TOKEN_PROCESSOR, requestMessage.getProcessor()); jsonGenerator.writeObjectField(SerTokens.TOKEN_ARGS, requestMessage.getArgs()); GraphSONUtil.writeEndObject(requestMessage, jsonGenerator, typeSerializer); }
Example #19
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Path path, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { jsonGenerator.writeStartObject(); // paths shouldn't serialize with properties if the path contains graph elements final Path p = DetachedFactory.detach(path, false); jsonGenerator.writeObjectField(GraphSONTokens.LABELS, p.labels()); jsonGenerator.writeObjectField(GraphSONTokens.OBJECTS, p.objects()); jsonGenerator.writeEndObject(); }
Example #20
Source File: JavaUtilSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final List list, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { for(Object o : list) { jsonGenerator.writeObject(o); } }
Example #21
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Traverser traverserInstance, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.BULK, traverserInstance.bulk()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, traverserInstance.get()); jsonGenerator.writeEndObject(); }
Example #22
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.ID, property.id()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, property.value()); if (includeLabel) jsonGenerator.writeStringField(GraphSONTokens.LABEL, property.label()); tryWriteMetaProperties(property, jsonGenerator, normalize); jsonGenerator.writeEndObject(); }
Example #23
Source File: JavaUtilSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Map.Entry entry, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { final Map<Object,Object> m = new HashMap<>(); if (entry != null) m.put(entry.getKey(), entry.getValue()); jsonGenerator.writeObject(m); }
Example #24
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Tree tree, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { jsonGenerator.writeStartArray(); final Set<Map.Entry<Element, Tree>> set = tree.entrySet(); for (Map.Entry<Element, Tree> entry : set) { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.KEY, entry.getKey()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, entry.getValue()); jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); }
Example #25
Source File: JavaUtilSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Map map, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { for(Map.Entry entry : (Set<Map.Entry>) map.entrySet()) { jsonGenerator.writeObject(entry.getKey()); jsonGenerator.writeObject(entry.getValue()); } }
Example #26
Source File: SchemaTable.java From sqlg with MIT License | 5 votes |
@Override public void serialize(final SchemaTable schemaTable, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { // when types are not embedded, stringify or resort to JSON primitive representations of the // type so that non-jvm languages can better interoperate with the TinkerPop stack. final Map<String, Object> m = new LinkedHashMap<>(); m.put("schema", schemaTable.getSchema()); m.put("table", schemaTable.getTable()); jsonGenerator.writeObject(m); }
Example #27
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private static void writeMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer, final boolean normalize) throws IOException { jsonGenerator.writeObjectFieldStart(GraphSONTokens.PROPERTIES); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); final Iterator<Property<Object>> metaProperties = normalize ? IteratorUtils.list(( Iterator<Property<Object>>) property.properties(), Comparators.PROPERTY_COMPARATOR).iterator() : property.properties(); while (metaProperties.hasNext()) { final Property<Object> metaProperty = metaProperties.next(); GraphSONUtil.writeWithType(metaProperty.key(), metaProperty.value(), jsonGenerator, serializerProvider, typeSerializer); } jsonGenerator.writeEndObject(); }
Example #28
Source File: AbstractGraphSONMessageSerializerV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
public void ser(final ResponseMessage responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); jsonGenerator.writeStringField(SerTokens.TOKEN_REQUEST, responseMessage.getRequestId() != null ? responseMessage.getRequestId().toString() : null); jsonGenerator.writeFieldName(SerTokens.TOKEN_STATUS); GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); 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()); GraphSONUtil.writeEndObject(responseMessage, jsonGenerator, typeSerializer); jsonGenerator.writeFieldName(SerTokens.TOKEN_RESULT); GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); if (null == responseMessage.getResult().getData()){ jsonGenerator.writeNullField(SerTokens.TOKEN_DATA); } else { jsonGenerator.writeFieldName(SerTokens.TOKEN_DATA); final Object result = responseMessage.getResult().getData(); serializerProvider.findTypedValueSerializer(result.getClass(), true, null).serialize(result, jsonGenerator, serializerProvider); } jsonGenerator.writeObjectField(SerTokens.TOKEN_META, responseMessage.getResult().getMeta()); GraphSONUtil.writeEndObject(responseMessage, jsonGenerator, typeSerializer); GraphSONUtil.writeEndObject(responseMessage, jsonGenerator, typeSerializer); }
Example #29
Source File: AbstractGraphSONMessageSerializerV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final JsonBuilder json, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { // the JSON from the builder will already be started/ended as array or object...just need to surround it // with appropriate chars to fit into the serialization pattern. jsonGenerator.writeRaw(":"); jsonGenerator.writeRaw(json.toString()); jsonGenerator.writeRaw(","); }
Example #30
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final TraversalStrategy traversalStrategy, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); for (final Map.Entry<Object, Object> entry : ConfigurationConverter.getMap(traversalStrategy.getConfiguration()).entrySet()) { jsonGenerator.writeObjectField((String) entry.getKey(), entry.getValue()); } jsonGenerator.writeEndObject(); }