/** * @since 2.7 */ public JsonMappingException(Closeable processor, String msg, Throwable problem) { super(msg, problem); _processor = processor; if (processor instanceof JsonParser) { _location = ((JsonParser) processor).getTokenLocation(); } }
/** * @since 2.7 */ public JsonMappingException(Closeable processor, String msg) { super(msg); _processor = processor; if (processor instanceof JsonParser) { // 17-Aug-2015, tatu: Use of token location makes some sense from databinding, // since actual parsing (current) location is typically only needed for low-level // parsing exceptions. _location = ((JsonParser) processor).getTokenLocation(); } }
@Override public JsonLocation getTokenLocation() { return delegate.getTokenLocation(); }
@Override public JsonLocation getTokenLocation() { return delegate.getTokenLocation(); }
@Override public JsonLocation getTokenLocation() { return delegate.getTokenLocation(); }
private void validate( JsonParser jsonParser, String input, String expected ) throws JsonProcessingException { if ( ! input.equals( expected ) ) { throw new JsonParseException( "Unexpected token: " + input, jsonParser.getTokenLocation() ); } } }
/** * @param src Parser to use for accessing source information * like location, configured codec */ public JsonParser asParser(JsonParser src) { Parser p = new Parser(_first, src.getCodec(), _hasNativeTypeIds, _hasNativeObjectIds, _parentContext); p.setLocation(src.getTokenLocation()); return p; }
private void validate( JsonParser jsonParser, String input, String expected ) throws JsonProcessingException { if ( ! input.equals( expected ) ) { throw new JsonParseException( "Unexpected token: " + input, jsonParser.getTokenLocation() ); } } }
private void validate( JsonParser jsonParser, String input, String expected ) throws JsonProcessingException { if ( ! input.equals( expected ) ) { throw new JsonParseException( "Unexpected token: " + input, jsonParser.getTokenLocation() ); } } }
@Override public JSONOptions deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonLocation l = jp.getTokenLocation(); // logger.debug("Reading tree."); TreeNode n = jp.readValueAsTree(); // logger.debug("Tree {}", n); if (n instanceof JsonNode) { return new JSONOptions( (JsonNode) n, l); } else { throw new IllegalArgumentException(String.format("Received something other than a JsonNode %s", n)); } }
throw new JsonParseException( "Unexpected end of JSON at " + parser.getTokenLocation() + " while expecting an element of an array: " + sampleJsonString()); throw new JsonParseException( "Unexpected end of JSON at " + parser.getTokenLocation() + " while expecting a key of object: " + sampleJsonString()); + token + " at " + parser.getTokenLocation() + ": " + sampleJsonString()); throw new JsonParseException( "Unexpected end of JSON at " + parser.getTokenLocation() + " while expecting a value of object: " + sampleJsonString()); case NOT_AVAILABLE: default: throw new JsonParseException("Unexpected token " + token + " at " + parser.getTokenLocation() + ": " + sampleJsonString());
Object inputSource = jp.getInputSource(); long start = jp.getTokenLocation().getByteOffset(); long end = jp.getTokenLocation().getByteOffset(); Object sourceRef = jp.getTokenLocation().getSourceRef(); if (sourceRef instanceof byte[]) { validateChecksum((byte[]) sourceRef, start, end, context);
/** * @since 2.7 */ public JsonMappingException(Closeable processor, String msg, Throwable problem) { super(msg, problem); _processor = processor; if (processor instanceof JsonParser) { _location = ((JsonParser) processor).getTokenLocation(); } }
@Override public JsonLocation getTokenLocation() { return delegate.getTokenLocation(); }
public static InvalidFormatException from(JsonParser jp, String msg, Object value, Class<?> targetType) { return new InvalidFormatException(msg, jp.getTokenLocation(), value, targetType); }
public static JsonMappingException from(JsonParser jp, String msg) { return new JsonMappingException(msg, jp.getTokenLocation()); }
public static JsonLocation expectObjectStart(JsonParser parser) throws IOException, JsonReadException { if (parser.getCurrentToken() != JsonToken.START_OBJECT) { throw new JsonReadException("expecting the start of an object (\"{\")", parser.getTokenLocation()); } JsonLocation loc = parser.getTokenLocation(); nextToken(parser); return loc; }
public static JsonLocation expectArrayStart(JsonParser parser) throws IOException, JsonReadException { if (parser.getCurrentToken() != JsonToken.START_ARRAY) { throw new JsonReadException("expecting the start of an array (\"[\")", parser.getTokenLocation()); } JsonLocation loc = parser.getTokenLocation(); nextToken(parser); return loc; }
private static long getTokenLocation(JsonParser parser) { if (parser instanceof ReaderBasedJsonParser) { return parser.getTokenLocation().getCharOffset(); } else if (parser instanceof UTF8StreamJsonParser) { return parser.getTokenLocation().getByteOffset(); } else { throw new HazelcastException("Provided parser does not support location: " + parser.getClass().getName()); } }
public Long read(JsonParser parser) throws IOException, JsonReadException { long v = readUnsignedLong(parser); if (v >= 4294967296L) { throw new JsonReadException("expecting a 32-bit unsigned integer, got: " + v, parser.getTokenLocation()); } return v; } };