@Override public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (!(other instanceof JsonLocation)) return false; JsonLocation otherLoc = (JsonLocation) other; if (_sourceRef == null) { if (otherLoc._sourceRef != null) return false; } else if (!_sourceRef.equals(otherLoc._sourceRef)) return false; return (_lineNr == otherLoc._lineNr) && (_columnNr == otherLoc._columnNr) && (_totalChars == otherLoc._totalChars) && (getByteOffset() == otherLoc.getByteOffset()) ; }
@Override public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (!(other instanceof JsonLocation)) return false; JsonLocation otherLoc = (JsonLocation) other; if (_sourceRef == null) { if (otherLoc._sourceRef != null) return false; } else if (!_sourceRef.equals(otherLoc._sourceRef)) return false; return (_lineNr == otherLoc._lineNr) && (_columnNr == otherLoc._columnNr) && (_totalChars == otherLoc._totalChars) && (getByteOffset() == otherLoc.getByteOffset()) ; }
@Override public int getInputPos() { JsonLocation currentLocation = input.getCurrentLocation(); long byteOffset = currentLocation.getByteOffset(); if ( input.getCurrentToken() == JsonToken.FIELD_NAME ) byteOffset-=2; // eager parsing of jackson ':' + '['/'{' return (int) byteOffset; }
@Override public int getInputPos() { JsonLocation currentLocation = input.getCurrentLocation(); long byteOffset = currentLocation.getByteOffset(); if ( input.getCurrentToken() == JsonToken.FIELD_NAME ) byteOffset-=2; // eager parsing of jackson ':' + '['/'{' return (int) byteOffset; }
private String getLocationString() { JsonLocation l = parser.getCurrentLocation(); List<String> parts = new ArrayList<>(4); parts.add("line: " + l.getLineNr()); parts.add("column: " + l.getColumnNr()); if (l.getByteOffset() >= 0) { parts.add("byte offset: " + l.getByteOffset()); } return parts.toString(); }
Object inputSource = jp.getInputSource(); long start = jp.getTokenLocation().getByteOffset(); long end = jp.getTokenLocation().getByteOffset();
@Override public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (!(other instanceof JsonLocation)) return false; JsonLocation otherLoc = (JsonLocation) other; if (_sourceRef == null) { if (otherLoc._sourceRef != null) return false; } else if (!_sourceRef.equals(otherLoc._sourceRef)) return false; return (_lineNr == otherLoc._lineNr) && (_columnNr == otherLoc._columnNr) && (_totalChars == otherLoc._totalChars) && (getByteOffset() == otherLoc.getByteOffset()) ; } }
@Override public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (!(other instanceof JsonLocation)) return false; JsonLocation otherLoc = (JsonLocation) other; if (_sourceRef == null) { if (otherLoc._sourceRef != null) return false; } else if (!_sourceRef.equals(otherLoc._sourceRef)) return false; return (_lineNr == otherLoc._lineNr) && (_columnNr == otherLoc._columnNr) && (_totalChars == otherLoc._totalChars) && (getByteOffset() == otherLoc.getByteOffset()) ; }
@Override public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (!(other instanceof JsonLocation)) return false; JsonLocation otherLoc = (JsonLocation) other; if (_sourceRef == null) { if (otherLoc._sourceRef != null) return false; } else if (!_sourceRef.equals(otherLoc._sourceRef)) return false; return (_lineNr == otherLoc._lineNr) && (_columnNr == otherLoc._columnNr) && (_totalChars == otherLoc._totalChars) && (getByteOffset() == otherLoc.getByteOffset()) ; } }
@Override public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (!(other instanceof JsonLocation)) return false; JsonLocation otherLoc = (JsonLocation) other; if (_sourceRef == null) { if (otherLoc._sourceRef != null) return false; } else if (!_sourceRef.equals(otherLoc._sourceRef)) return false; return (_lineNr == otherLoc._lineNr) && (_columnNr == otherLoc._columnNr) && (_totalChars == otherLoc._totalChars) && (getByteOffset() == otherLoc.getByteOffset()) ; } }
@Override public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (!(other instanceof JsonLocation)) return false; JsonLocation otherLoc = (JsonLocation) other; if (_sourceRef == null) { if (otherLoc._sourceRef != null) return false; } else if (!_sourceRef.equals(otherLoc._sourceRef)) return false; return (_lineNr == otherLoc._lineNr) && (_columnNr == otherLoc._columnNr) && (_totalChars == otherLoc._totalChars) && (getByteOffset() == otherLoc.getByteOffset()) ; } }
@Override public boolean equals(Object other) { if (other == this) return true; if (other == null) return false; if (!(other instanceof JsonLocation)) return false; JsonLocation otherLoc = (JsonLocation) other; if (_sourceRef == null) { if (otherLoc._sourceRef != null) return false; } else if (!_sourceRef.equals(otherLoc._sourceRef)) return false; return (_lineNr == otherLoc._lineNr) && (_columnNr == otherLoc._columnNr) && (_totalChars == otherLoc._totalChars) && (getByteOffset() == otherLoc.getByteOffset()) ; } }
@Override public float getProgress() throws IOException { if (splitLen == 0 || parser == null) return 0; return (float)parser.getCurrentLocation().getByteOffset() / splitLen; }
/** * Returns the current position in the underlying InputStream */ public long getInputStreamPosition() { return jsonParser.getTokenLocation().getByteOffset(); }
private String getLocationString() { JsonLocation l = parser.getCurrentLocation(); List<String> parts = new ArrayList<>(4); parts.add("line: " + l.getLineNr()); parts.add("column: " + l.getColumnNr()); if (l.getByteOffset() >= 0) { parts.add("byte offset: " + l.getByteOffset()); } return parts.toString(); }
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()); } }
protected void printStatus(final JsonParser jp, final long importedVertices, final long importedEdges) { if (output != null && (importedVertices + importedEdges) % 50000 == 0) { final long parsed = jp.getCurrentLocation().getByteOffset(); if (inputSize > 0) output.onMessage(String.format("Imported %d graph elements: %d vertices and %d edges. Parsed %s/%s (uncompressed) (%s%%)", importedVertices + importedEdges, importedVertices, importedEdges, OFileUtils.getSizeAsString(parsed), "" + OFileUtils.getSizeAsString(inputSize), "" + parsed * 100 / inputSize)); else output.onMessage(String.format("Imported %d graph elements: %d vertices and %d edges. Parsed %s (uncompressed)", importedVertices + importedEdges, importedVertices, importedEdges, OFileUtils.getSizeAsString(parsed))); } } }
dataStart = jp.getTokenLocation().getByteOffset(); if (current.isScalarValue()) { if (!current.isNumeric() && !current.isBoolean()) { jp.skipChildren(); dataEnd = jp.getCurrentLocation().getByteOffset(); } else {
dataStart = jp.getTokenLocation().getByteOffset(); if (current.isScalarValue()) { if (!current.isNumeric() && !current.isBoolean()) { jp.skipChildren(); dataEnd = jp.getCurrentLocation().getByteOffset(); } else {
@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); } } }