Skip to content

Commit

Permalink
Changes for core/1364, JsonLocation->TokenStreamLocation rename (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored Nov 30, 2024
1 parent 5d27867 commit 44ff4aa
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions ion/src/main/java/tools/jackson/dataformat/ion/IonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ public Object getTypeId() throws JacksonException {
*/

@Override
public JsonLocation currentLocation() {
return JsonLocation.NA;
public TokenStreamLocation currentLocation() {
return TokenStreamLocation.NA;
}

@Override
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 44ff4aa

Please sign in to comment.