Java Code Examples for org.apache.tinkerpop.shaded.jackson.core.JsonParser#getText()
The following examples show how to use
org.apache.tinkerpop.shaded.jackson.core.JsonParser#getText() .
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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Bytecode deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Bytecode bytecode = new Bytecode(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { final String current = jsonParser.getCurrentName(); if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // there should be a list now and the first item in the list is always string and is the step name // skip the start array jsonParser.nextToken(); final String stepName = jsonParser.getText(); // iterate through the rest of the list for arguments until it gets to the end final List<Object> arguments = new ArrayList<>(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // we don't know the types here, so let the deserializer figure that business out arguments.add(deserializationContext.readValue(jsonParser, Object.class)); } // if it's not a "source" then it must be a "step" if (current.equals(GraphSONTokens.SOURCE)) bytecode.addSource(stepName, arguments.toArray()); else bytecode.addStep(stepName, arguments.toArray()); } } } return bytecode; }
Example 8
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public A deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Class<A> enumClass = (Class<A>) this._valueClass; final String enumName = jsonParser.getText(); for (final Enum a : enumClass.getEnumConstants()) { if (a.name().equals(enumName)) return (A) a; } throw new IOException("Unknown enum type: " + enumClass); }
Example 9
Source File: TraversalSerializersV2d0.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 10
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Bytecode deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Bytecode bytecode = new Bytecode(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { final String current = jsonParser.getCurrentName(); if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // there should be a list now and the first item in the list is always string and is the step name // skip the start array jsonParser.nextToken(); final String stepName = jsonParser.getText(); // iterate through the rest of the list for arguments until it gets to the end final List<Object> arguments = new ArrayList<>(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // we don't know the types here, so let the deserializer figure that business out arguments.add(deserializationContext.readValue(jsonParser, Object.class)); } // if it's not a "source" then it must be a "step" if (current.equals(GraphSONTokens.SOURCE)) bytecode.addSource(stepName, arguments.toArray()); else bytecode.addStep(stepName, arguments.toArray()); } } } return bytecode; }
Example 11
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public A deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Class<A> enumClass = (Class<A>) this._valueClass; final String enumName = jsonParser.getText(); for (final Enum a : enumClass.getEnumConstants()) { if (a.name().equals(enumName)) return (A) a; } throw new IOException("Unknown enum type: " + enumClass); }
Example 12
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); }