From 44ff4aafea18de48944d0808b42f13bcbf3f42af Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 29 Nov 2024 21:22:19 -0800 Subject: [PATCH] Changes for core/1364, JsonLocation->TokenStreamLocation rename (#530) --- .../java/tools/jackson/dataformat/avro/AvroParser.java | 4 ++-- .../java/tools/jackson/dataformat/cbor/CBORParser.java | 10 +++++----- .../tools/jackson/dataformat/cbor/CBORReadContext.java | 4 ++-- .../jackson/dataformat/cbor/ParserInputStreamTest.java | 4 ++-- .../java/tools/jackson/dataformat/ion/IonParser.java | 8 ++++---- .../jackson/dataformat/protobuf/ProtobufParser.java | 8 ++++---- .../dataformat/protobuf/ProtobufReadContext.java | 4 ++-- .../jackson/dataformat/smile/SmileParserBase.java | 10 +++++----- .../dataformat/smile/parse/ParserLocationTest.java | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/AvroParser.java b/avro/src/main/java/tools/jackson/dataformat/avro/AvroParser.java index 0d9e9e67a..afc32322f 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/AvroParser.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/AvroParser.java @@ -180,13 +180,13 @@ public Object getTypeId() throws JacksonException { */ @Override - public JsonLocation currentTokenLocation() { + public TokenStreamLocation currentTokenLocation() { // !!! TODO return null; } @Override - public JsonLocation currentLocation() { + public TokenStreamLocation currentLocation() { // !!! TODO return null; } diff --git a/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java b/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java index 5d05aabca..1992e3a0d 100644 --- a/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java +++ b/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java @@ -394,10 +394,10 @@ public Object streamReadInputSource() { * but we do have byte offset to specify. */ @Override - public JsonLocation currentTokenLocation() + public TokenStreamLocation currentTokenLocation() { // token location is correctly managed... - return new JsonLocation(_ioContext.contentReference(), + return new TokenStreamLocation(_ioContext.contentReference(), _tokenInputTotal, // bytes -1, -1, (int) _tokenInputTotal); // char offset, line, column } @@ -407,10 +407,10 @@ public JsonLocation currentTokenLocation() * but we do have byte offset to specify. */ @Override - public JsonLocation currentLocation() + public TokenStreamLocation currentLocation() { final long offset = _currInputProcessed + _inputPtr; - return new JsonLocation(_ioContext.contentReference(), + return new TokenStreamLocation(_ioContext.contentReference(), offset, // bytes -1, -1, (int) offset); // char offset, line, column } @@ -3790,7 +3790,7 @@ protected void _handleEOF() throws StreamReadException { return; } // Ok; end-marker or fixed-length Array/Object? - final JsonLocation loc = _streamReadContext.startLocation(_ioContext.contentReference()); + final TokenStreamLocation loc = _streamReadContext.startLocation(_ioContext.contentReference()); final String startLocDesc = (loc == null) ? "[N/A]" : loc.sourceDescription(); if (_streamReadContext.hasExpectedLength()) { // specific length final int expMore = _streamReadContext.getRemainingExpectedLength(); diff --git a/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORReadContext.java b/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORReadContext.java index 3c5608a09..22c45f2bb 100644 --- a/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORReadContext.java +++ b/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORReadContext.java @@ -167,8 +167,8 @@ public boolean expectMoreValues() { * start marker was found */ @Override - public JsonLocation startLocation(ContentReference srcRef) { - return new JsonLocation(srcRef, 1L, -1, -1); + public TokenStreamLocation startLocation(ContentReference srcRef) { + return new TokenStreamLocation(srcRef, 1L, -1, -1); } /* diff --git a/cbor/src/test/java/tools/jackson/dataformat/cbor/ParserInputStreamTest.java b/cbor/src/test/java/tools/jackson/dataformat/cbor/ParserInputStreamTest.java index ca02db0c8..83a79b9c7 100644 --- a/cbor/src/test/java/tools/jackson/dataformat/cbor/ParserInputStreamTest.java +++ b/cbor/src/test/java/tools/jackson/dataformat/cbor/ParserInputStreamTest.java @@ -5,7 +5,7 @@ import java.io.InputStream; import java.io.SequenceInputStream; -import tools.jackson.core.JsonLocation; +import tools.jackson.core.TokenStreamLocation; import tools.jackson.core.JsonParser; import tools.jackson.databind.JsonNode; import tools.jackson.databind.ObjectMapper; @@ -47,7 +47,7 @@ public void testInputStreamWithHugeValueThatOverlaps() throws Exception { parser.nextToken(); parser.finishToken(); - final JsonLocation loc = parser.currentLocation(); + final TokenStreamLocation loc = parser.currentLocation(); final long start = loc.getByteOffset(); assertEquals(7999, start); diff --git a/ion/src/main/java/tools/jackson/dataformat/ion/IonParser.java b/ion/src/main/java/tools/jackson/dataformat/ion/IonParser.java index 8772cf5a1..5a2eb178b 100644 --- a/ion/src/main/java/tools/jackson/dataformat/ion/IonParser.java +++ b/ion/src/main/java/tools/jackson/dataformat/ion/IonParser.java @@ -548,8 +548,8 @@ public Object getTypeId() throws JacksonException { */ @Override - public JsonLocation currentLocation() { - return JsonLocation.NA; + public TokenStreamLocation currentLocation() { + return TokenStreamLocation.NA; } @Override @@ -562,8 +562,8 @@ public String currentName() throws JacksonException { @Override public Object currentValue() { return _streamReadContext.currentValue(); } @Override - public JsonLocation currentTokenLocation() { - return JsonLocation.NA; + public TokenStreamLocation currentTokenLocation() { + return TokenStreamLocation.NA; } @Override diff --git a/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufParser.java b/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufParser.java index ea7e462e8..2a61659e7 100644 --- a/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufParser.java +++ b/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufParser.java @@ -391,10 +391,10 @@ public Object streamReadInputSource() { * but we do have byte offset to specify. */ @Override - public JsonLocation currentTokenLocation() + public TokenStreamLocation currentTokenLocation() { // token location is correctly managed... - return new JsonLocation(_ioContext.contentReference(), + return new TokenStreamLocation(_ioContext.contentReference(), _tokenInputTotal, // bytes -1, -1, (int) _tokenInputTotal); // char offset, line, column } @@ -404,10 +404,10 @@ public JsonLocation currentTokenLocation() * but we do have byte offset to specify. */ @Override - public JsonLocation currentLocation() + public TokenStreamLocation currentLocation() { final long offset = _currInputProcessed + _inputPtr; - return new JsonLocation(_ioContext.contentReference(), + return new TokenStreamLocation(_ioContext.contentReference(), offset, // bytes -1, -1, (int) offset); // char offset, line, column } diff --git a/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufReadContext.java b/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufReadContext.java index 25523510e..a493119a1 100644 --- a/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufReadContext.java +++ b/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufReadContext.java @@ -191,9 +191,9 @@ private void _adjustEnd(int bytesConsumed) { * @return Location pointing to the point where the context * start marker was found */ - public JsonLocation startLocation(ContentReference srcRef, long byteOffset) { + public TokenStreamLocation startLocation(ContentReference srcRef, long byteOffset) { // not much we can tell - return new JsonLocation(srcRef, byteOffset, -1, -1); + return new TokenStreamLocation(srcRef, byteOffset, -1, -1); } /* diff --git a/smile/src/main/java/tools/jackson/dataformat/smile/SmileParserBase.java b/smile/src/main/java/tools/jackson/dataformat/smile/SmileParserBase.java index 8b958cc2f..51006bef5 100644 --- a/smile/src/main/java/tools/jackson/dataformat/smile/SmileParserBase.java +++ b/smile/src/main/java/tools/jackson/dataformat/smile/SmileParserBase.java @@ -280,12 +280,12 @@ public final boolean mayContainRawBinary() { * but we do have byte offset to specify. */ @Override - public final JsonLocation currentTokenLocation() + public final TokenStreamLocation currentTokenLocation() { // token location is correctly managed... long total = _currInputProcessed + _tokenOffsetForTotal; // 2.4: used to be: _tokenInputTotal - return new JsonLocation(_ioContext.contentReference(), + return new TokenStreamLocation(_ioContext.contentReference(), total, // bytes -1, -1, (int) total); // char offset, line, column } @@ -295,10 +295,10 @@ public final JsonLocation currentTokenLocation() * but we do have byte offset to specify. */ @Override - public final JsonLocation currentLocation() + public final TokenStreamLocation currentLocation() { final long offset = _currInputProcessed + _inputPtr; - return new JsonLocation(_ioContext.contentReference(), + return new TokenStreamLocation(_ioContext.contentReference(), offset, // bytes -1, -1, (int) offset); // char offset, line, column } @@ -700,7 +700,7 @@ protected void _reportMismatchedEndMarker(int actCh, char expCh) throws StreamRe /** * Helper method used to encapsulate logic of including (or not) of - * "source reference" when constructing {@link JsonLocation} instances. + * "source reference" when constructing {@link TokenStreamLocation} instances. */ protected ContentReference _sourceReference() { if (isEnabled(StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION)) { diff --git a/smile/src/test/java/tools/jackson/dataformat/smile/parse/ParserLocationTest.java b/smile/src/test/java/tools/jackson/dataformat/smile/parse/ParserLocationTest.java index fbdc21c73..667b3e118 100644 --- a/smile/src/test/java/tools/jackson/dataformat/smile/parse/ParserLocationTest.java +++ b/smile/src/test/java/tools/jackson/dataformat/smile/parse/ParserLocationTest.java @@ -16,7 +16,7 @@ public void testSimpleOffsets() throws IOException JsonParser p = _smileParser(data); assertNull(p.currentToken()); - JsonLocation loc = p.currentLocation(); + TokenStreamLocation loc = p.currentLocation(); assertNotNull(loc); // first: -1 for "not known", for character-based stuff assertEquals(-1, loc.getCharOffset());