Skip to content

Commit

Permalink
Changes for core/1364: JsonLocation->TokenStreamLocation renaming (#4816
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cowtowncoder authored Nov 30, 2024
1 parent baee8a3 commit 0206e87
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/main/java/tools/jackson/databind/DatabindException.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ protected DatabindException(Closeable processor, String msg, Throwable problem)
super(processor, msg, problem);
}

protected DatabindException(Closeable processor, String msg, JsonLocation loc)
protected DatabindException(Closeable processor, String msg, TokenStreamLocation loc)
{
super(msg, loc, null);
}

protected DatabindException(String msg, JsonLocation loc, Throwable rootCause) {
protected DatabindException(String msg, TokenStreamLocation loc, Throwable rootCause) {
super(msg, loc, rootCause);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tools/jackson/databind/MappingIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public FormatSchema parserSchema() {
*
* @return Location of the input stream of the underlying parser
*/
public JsonLocation currentLocation() {
public TokenStreamLocation currentLocation() {
return _parser.currentLocation();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.fasterxml.jackson.annotation.ObjectIdResolver;

import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonLocation;
import tools.jackson.core.TokenStreamLocation;
import tools.jackson.databind.DeserializationContext;
import tools.jackson.databind.JavaType;

Expand Down Expand Up @@ -139,7 +139,7 @@ public Referring(UnresolvedForwardReference ref, JavaType beanType) {
_beanType = beanType.getRawClass();
}

public JsonLocation getLocation() { return _reference.getLocation(); }
public TokenStreamLocation getLocation() { return _reference.getLocation(); }
public Class<?> getBeanType() { return _beanType; }

public abstract void handleResolvedForwardReference(Object id, Object value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Iterator;
import java.util.List;

import tools.jackson.core.JsonLocation;
import tools.jackson.core.TokenStreamLocation;
import tools.jackson.core.JsonParser;
import tools.jackson.databind.DatabindException;

Expand All @@ -18,7 +18,7 @@ public class UnresolvedForwardReference extends DatabindException
private ReadableObjectId _roid;
private List<UnresolvedId> _unresolvedIds;

public UnresolvedForwardReference(JsonParser p, String msg, JsonLocation loc,
public UnresolvedForwardReference(JsonParser p, String msg, TokenStreamLocation loc,
ReadableObjectId roid)
{
super(p, msg, loc);
Expand All @@ -44,7 +44,7 @@ public Object getUnresolvedId() {
return _roid.getKey().key;
}

public void addUnresolvedId(Object id, Class<?> type, JsonLocation where) {
public void addUnresolvedId(Object id, Class<?> type, TokenStreamLocation where) {
_unresolvedIds.add(new UnresolvedId(id, type, where));
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/tools/jackson/databind/deser/UnresolvedId.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tools.jackson.databind.deser;

import tools.jackson.core.JsonLocation;
import tools.jackson.core.TokenStreamLocation;
import tools.jackson.databind.util.ClassUtil;

/**
Expand All @@ -10,10 +10,10 @@
*/
public class UnresolvedId {
private final Object _id;
private final JsonLocation _location;
private final TokenStreamLocation _location;
private final Class<?> _type;

public UnresolvedId(Object id, Class<?> type, JsonLocation where) {
public UnresolvedId(Object id, Class<?> type, TokenStreamLocation where) {
_id = id;
_type = type;
_location = where;
Expand All @@ -28,7 +28,7 @@ public UnresolvedId(Object id, Class<?> type, JsonLocation where) {
* The type of object which was expected.
*/
public Class<?> getType() { return _type; }
public JsonLocation getLocation() { return _location; }
public TokenStreamLocation getLocation() { return _location; }

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tools.jackson.databind.deser.jackson;

import tools.jackson.core.JsonLocation;
import tools.jackson.core.TokenStreamLocation;
import tools.jackson.core.io.ContentReference;
import tools.jackson.databind.DeserializationConfig;
import tools.jackson.databind.DeserializationContext;
Expand All @@ -12,15 +12,15 @@
import tools.jackson.databind.deser.ValueInstantiator;

/**
* For {@link JsonLocation}, we should be able to just implement
* For {@link TokenStreamLocation}, we should be able to just implement
* {@link ValueInstantiator} (not that explicit one would be very
* hard but...)
*/
public class JsonLocationInstantiator
public class TokenStreamLocationInstantiator
extends ValueInstantiator.Base
{
public JsonLocationInstantiator() {
super(JsonLocation.class);
public TokenStreamLocationInstantiator() {
super(TokenStreamLocation.class);
}

@Override
Expand Down Expand Up @@ -55,7 +55,7 @@ public Object createFromObjectWith(DeserializationContext ctxt, Object[] args) {
// with 2.13 changed to use `InputSourceReference`... left almost as is,
// for compatibility.
final ContentReference srcRef = ContentReference.unknown();
return new JsonLocation(srcRef, _long(args[0]), _long(args[1]),
return new TokenStreamLocation(srcRef, _long(args[0]), _long(args[1]),
_int(args[2]), _int(args[3]));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

import tools.jackson.core.JsonLocation;
import tools.jackson.core.TokenStreamLocation;
import tools.jackson.databind.DeserializationConfig;
import tools.jackson.databind.DeserializationContext;
import tools.jackson.databind.deser.ValueInstantiator;
import tools.jackson.databind.deser.jackson.JsonLocationInstantiator;
import tools.jackson.databind.deser.jackson.TokenStreamLocationInstantiator;

/**
* Container for a set of {@link ValueInstantiator}s used for certain critical
Expand All @@ -19,8 +19,8 @@ public abstract class JDKValueInstantiators
public static ValueInstantiator findStdValueInstantiator(DeserializationConfig config,
Class<?> raw)
{
if (raw == JsonLocation.class) {
return new JsonLocationInstantiator();
if (raw == TokenStreamLocation.class) {
return new TokenStreamLocationInstantiator();
}
// [databind#1868]: empty List/Set/Map
// [databind#2416]: optimize commonly needed default creators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.*;

import tools.jackson.core.JsonLocation;
import tools.jackson.core.TokenStreamLocation;
import tools.jackson.core.JsonParser;
import tools.jackson.databind.DatabindException;

Expand All @@ -16,7 +16,7 @@ public class IgnoredPropertyException
{
private static final long serialVersionUID = 1L;

public IgnoredPropertyException(JsonParser p, String msg, JsonLocation loc,
public IgnoredPropertyException(JsonParser p, String msg, TokenStreamLocation loc,
Class<?> referringClass, String propName,
Collection<Object> propertyIds)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tools.jackson.databind.exc;

import tools.jackson.core.JsonLocation;
import tools.jackson.core.TokenStreamLocation;
import tools.jackson.core.JsonParser;
import tools.jackson.databind.DatabindException;
import tools.jackson.databind.JavaType;
Expand Down Expand Up @@ -34,7 +34,7 @@ protected MismatchedInputException(JsonParser p, String msg) {
this(p, msg, (JavaType) null);
}

protected MismatchedInputException(JsonParser p, String msg, JsonLocation loc) {
protected MismatchedInputException(JsonParser p, String msg, TokenStreamLocation loc) {
super(p, msg, loc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Collections;
import java.util.Iterator;

import tools.jackson.core.JsonLocation;
import tools.jackson.core.TokenStreamLocation;
import tools.jackson.core.JsonParser;

/**
Expand Down Expand Up @@ -41,7 +41,7 @@ public abstract class PropertyBindingException
*/
protected transient String _propertiesAsString;

protected PropertyBindingException(JsonParser p, String msg, JsonLocation loc,
protected PropertyBindingException(JsonParser p, String msg, TokenStreamLocation loc,
Class<?> referringClass, String propName,
Collection<Object> propertyIds)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.*;

import tools.jackson.core.JsonLocation;
import tools.jackson.core.TokenStreamLocation;
import tools.jackson.core.JsonParser;

/**
Expand All @@ -16,7 +16,7 @@ public class UnrecognizedPropertyException
{
private static final long serialVersionUID = 1L;

public UnrecognizedPropertyException(JsonParser p, String msg, JsonLocation loc,
public UnrecognizedPropertyException(JsonParser p, String msg, TokenStreamLocation loc,
Class<?> referringClass, String propName,
Collection<Object> propertyIds)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ public TokenStreamContext streamReadContext() {
@Override public Object currentValue() { return _nodeCursor.currentValue(); }

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

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

/*
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/tools/jackson/databind/util/TokenBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ protected final static class Parser

protected transient ByteArrayBuilder _byteBuilder;

protected JsonLocation _location = null;
protected TokenStreamLocation _location = null;

/*
/******************************************************************
Expand All @@ -1540,7 +1540,7 @@ public Parser(ObjectReadContext readCtxt, TokenBuffer source,
_hasNativeIds = (hasNativeTypeIds || hasNativeObjectIds);
}

public void setLocation(JsonLocation l) {
public void setLocation(TokenStreamLocation l) {
_location = l;
}

Expand Down Expand Up @@ -1702,11 +1702,11 @@ public int nextNameMatch(PropertyNameMatcher matcher) {
@Override public Object currentValue() { return _parsingContext.currentValue(); }

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

@Override
public JsonLocation currentLocation() {
return (_location == null) ? JsonLocation.NA : _location;
public TokenStreamLocation currentLocation() {
return (_location == null) ? TokenStreamLocation.NA : _location;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class TokenBufferReadContext extends TokenStreamContext
{
protected final TokenStreamContext _parent;

protected final JsonLocation _startLocation;
protected final TokenStreamLocation _startLocation;

// Benefit for reusing?
// protected JsonReadContext _child;
Expand All @@ -39,11 +39,11 @@ protected TokenBufferReadContext(TokenStreamContext base, ContentReference conte
JsonReadContext rc = (JsonReadContext) base;
_startLocation = rc.startLocation(contentRef);
} else {
_startLocation = JsonLocation.NA;
_startLocation = TokenStreamLocation.NA;
}
}

protected TokenBufferReadContext(TokenStreamContext base, JsonLocation startLoc) {
protected TokenBufferReadContext(TokenStreamContext base, TokenStreamLocation startLoc) {
super(base);
_parent = base.getParent();
_currentName = base.currentName();
Expand All @@ -58,7 +58,7 @@ protected TokenBufferReadContext(TokenStreamContext base, JsonLocation startLoc)
protected TokenBufferReadContext() {
super(TYPE_ROOT, -1);
_parent = null;
_startLocation = JsonLocation.NA;
_startLocation = TokenStreamLocation.NA;
}

protected TokenBufferReadContext(TokenBufferReadContext parent, int type, int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public class JacksonTypesDeserTest
private final ObjectMapper MAPPER = sharedMapper();

@Test
public void testJsonLocation() throws Exception
public void testTokenStreamLocation() throws Exception
{
// note: source reference is untyped, only String guaranteed to work
JsonLocation loc = new JsonLocation(ContentReference.rawReference("whatever"),
TokenStreamLocation loc = new TokenStreamLocation(ContentReference.rawReference("whatever"),
-1, -1, 100, 13);
// Let's use serializer here; goal is round-tripping
String ser = MAPPER.writerWithDefaultPrettyPrinter()
.writeValueAsString(loc);
JsonLocation result = MAPPER.readValue(ser, JsonLocation.class);
TokenStreamLocation result = MAPPER.readValue(ser, TokenStreamLocation.class);
assertNotNull(result);
// 14-Mar-2021, tatu: Should NOT count on this being retained actually,
// after 2.13 (will retain for now)...
Expand All @@ -45,9 +45,9 @@ public void testJsonLocation() throws Exception

// doesn't really belong here but...
@Test
public void testJsonLocationProps()
public void testTokenStreamLocationProps()
{
JsonLocation loc = new JsonLocation(null, -1, -1, 100, 13);
TokenStreamLocation loc = new TokenStreamLocation(null, -1, -1, 100, 13);
assertTrue(loc.equals(loc));
assertFalse(loc.equals(null));
final Object value = "abx";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testLocationAddition() throws Exception
if (str.length != 2) {
fail("Should only get one 'at [' marker, got "+(str.length-1)+", source: "+msg);
}
JsonLocation loc = e.getLocation();
TokenStreamLocation loc = e.getLocation();
// String expectedLocation = "line: 4, column: 3";
assertEquals(4, loc.getLineNr());
// 12-Feb-2024, tatu: varies depending on whether [core#1173] is fixed or not...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class JacksonTypesSerTest
public void testLocation() throws IOException
{
File f = new File("/tmp/test.json");
JsonLocation loc = new JsonLocation(ContentReference.rawReference(f),
TokenStreamLocation loc = new TokenStreamLocation(ContentReference.rawReference(f),
-1, 100, 13);
Map<String,Object> result = writeAndMap(MAPPER, loc);
// 04-Apr-2021, tatu: Jackson 2.x used to output "sourceRef"; no longer in 3.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public static void assertToken(JsonToken expToken, JsonToken actToken)
}
}

public static void assertValidLocation(JsonLocation location) {
public static void assertValidLocation(TokenStreamLocation location) {
assertNotNull(location, "Should have non-null location");
assertTrue(location.getLineNr() > 0, "Should have positive line number");
}
Expand Down

0 comments on commit 0206e87

Please sign in to comment.