@Override public int compareTo(DataLocation other) { return (int) (_location.getCharOffset() - ((Location) other)._location.getCharOffset()); }
@Override public int getCharacterOffset() { return (int)location.getCharOffset(); }
public String getJson() { return source.substring((int) from.getCharOffset() - 1, (int) to.getCharOffset()); }
public String getJson() { return source.substring((int) from.getCharOffset() - 1, (int) to.getCharOffset()); }
@Override public long getPos() throws IOException { if (parser == null){ return 0; } else { return parser.getCurrentLocation().getCharOffset(); } }
public static BadMessageException newParsingException(JsonParser jsonParser, String info) { return new BadMessageException(String.format("%s. offset: %d", info, jsonParser. getCurrentLocation().getCharOffset())); }
public PositionEndpoint(JsonLocation location) { this(location.getCharOffset(), location.getLineNr(), location.getColumnNr()); }
long charOffsetStart = startLocation.getCharOffset(); long charOffsetEnd = endLocation.getCharOffset(); String jsonSubString = endLocation.getSourceRef().toString().substring((int)charOffsetStart - 1, (int)charOffsetEnd); logger.info(strWalkStep);
StaxLocation(final JsonLocation location) { this((int) location.getCharOffset(), location.getColumnNr(), location.getLineNr()); }
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()); } }
key.set(parser.getCurrentLocation().getCharOffset());
public static ProtocolException newStanzaParsingException(JsonParser jsonParser, String info) { return new ProtocolException(new BadRequest(String.format("%s. offset: %d", info, jsonParser.getCurrentLocation().getCharOffset()))); }
private static int findJsonEndBoundary(String plan, int indexInPlan) throws IOException { // read the json pushdown query with jackson to find it's total length, wasn't sure how to do this with just regex // as it will span across a variable number of lines ObjectMapper map = new ObjectMapper(); //for later inner object data binding JsonParser p = map.getFactory().createParser(plan.substring(indexInPlan)); JsonToken token = p.nextToken(); if (token != JsonToken.START_ARRAY) { throw new RuntimeException("Error finding elastic pushdown query JSON in plan text, " + "did not find start array as expected, instead found " + token); } int startEndCounter = 1; while (startEndCounter != 0) { token = p.nextToken(); if (token == JsonToken.START_ARRAY) { startEndCounter++; } else if (token == JsonToken.END_ARRAY) { startEndCounter--; } } long pushdownEndIndexInPlan = p.getTokenLocation().getCharOffset() + 1; return indexInPlan + (int) pushdownEndIndexInPlan; }
LOG.trace("Read domain {}", domain.getId()); ++count; bytesParsed = parser.getCurrentLocation().getCharOffset() + 1; LOG.trace("Parser now at offset {}", bytesParsed);
int start = (int)parser.getTokenLocation().getCharOffset() + (parser.getCurrentToken() == JsonToken.VALUE_STRING ? 1 : 0); switch (parser.getCurrentToken()) { case VALUE_STRING: // values are one token updatePath(token); if (path.equals(searchedPath)) { int end = (int)parser.getTokenLocation().getCharOffset() + parser.getTextLength(); return new Interval(start, end);
par.getCurrentName(), locLast.getLineNr(), locLast.getCharOffset());
@Override public T fromBytes(final byte[] bytes) { try { try { return mapper.readValue(bytes, clazz); } catch (final JsonParseException ex) { final JsonLocation location = ex.getLocation(); Object src = location.getSourceRef(); if (src instanceof ByteBuffer) { src = ((ByteBuffer) src).asCharBuffer(); } else if (src instanceof byte[]) { src = new String((byte[]) src); } else if (src instanceof char[]) { src = new String((char[]) src); } throw new JsonParseException( ex.getMessage(), new JsonLocation( src, location.getByteOffset(), location.getCharOffset(), location.getLineNr(), location.getColumnNr()), ex.getCause()); } } catch (final IOException ex) { throw new RuntimeException(ex); } } }
JsonToken token; while ((token = parser.nextToken()) != null) { int currentStart = (int)parser.getTokenLocation().getCharOffset(); int currentEnd = currentStart + parser.getTextLength(); if (previousEnd < selectionEnd && selectionEnd < currentStart) {
private void throwParsingError(JsonLocation jsonLocation, String message) { throw SeedException.createNew(DataErrorCode.FAILED_TO_PARSE_DATA_STREAM) .put("parsingError", message) .put("line", jsonLocation.getLineNr()) .put("col", jsonLocation.getColumnNr()) .put("offset", jsonLocation.getCharOffset()); }
private void throwParsingError(JsonLocation jsonLocation, String message) { throw BusinessException.createNew(DataErrorCode.FAILED_TO_PARSE_DATA_STREAM) .put("parsingError", message) .put("line", jsonLocation.getLineNr()) .put("col", jsonLocation.getColumnNr()) .put("offset", jsonLocation.getCharOffset()); }