Skip to content

Commit 084865d

Browse files
committed
Fix #671
1 parent 5440887 commit 084865d

23 files changed

+99
-90
lines changed

release-notes/VERSION

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ JSON library.
1818
3.0.0 (not yet released)
1919

2020
#378: Change default for `TokenStreamFactory.Feature.INTERN_FIELD_NAMES` to `false`
21+
#402: Remove dataformat-auto-detection functionality
22+
#411: Rename `JsonStreamContext` as `TokenStreamContext`
23+
#413: Remove `ObjectCodec`: replace with `ObjectWriteContext` / `ObjectReadContext`
2124
#432: Add new `TreeNode` subtypes: `ArrayTreeNode`, `ObjectTreeNode`
2225
#433: Add Builder pattern for creating configured Stream factories
2326
#456: Add `JsonParser.readAsValue(ResolvedType)`
24-
#467: Create `JsonReadFeature` to move JSON-specific `JsonParser.Feature`s to
25-
#481: Create `JsonWriteFeature` to move JSON-specific `JsonGenerator.Feature`s to
2627
#492: Ensure primitive type names in error message enclosed in backticks
27-
#495: Create `StreamReadFeature` to move non-json specific `JsonParser.Feature`s to
28-
#496: Create `StreamWriteFeature` to take over non-json-specific `JsonGenerator.Feature`s
2928
#551: Remove `JsonGenerator.setPrettyPrinter()` from 3.0
3029
#670: Replace references to "field" in `JsonGenerator`, `JsonParser` method names with "property"
30+
#671: Replace `getCurrentLocation()`/`getTokenLocation()` with
31+
`currentLocation()`/`currentTokenLocation()`
3132
- Rename `JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT` as `AUTO_CLOSE_CONTENT`
3233
- Add `TreeCodec.nullNode()`, `TreeNode.isNull()` methods
3334
- Change the way `JsonLocation.NA` is included in exception messages

src/main/java/com/fasterxml/jackson/core/JsonGenerator.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,12 @@ protected JsonGenerator() { }
9696
*<p>
9797
* In general use of this accessor should be considered as
9898
* "last effort", i.e. only used if no other mechanism is applicable.
99+
*<p>
100+
* NOTE: was named {@code getOutputTarget()} in Jackson 2.x.
99101
*
100102
* @return Output target this generator was configured with
101103
*/
102-
public abstract Object getOutputTarget();
104+
public abstract Object streamWriteTarget();
103105

104106
/**
105107
* Method for verifying amount of content that is buffered by generator
@@ -111,11 +113,13 @@ protected JsonGenerator() { }
111113
* {@code char} for {@link java.io.Writer}),
112114
* but may differ if buffering is done before encoding.
113115
* Default JSON-backed implementations do use matching units.
116+
*<p>
117+
* NOTE: was named {@code getOutputBuffered()} in Jackson 2.x.
114118
*
115119
* @return Amount of content buffered in internal units, if amount known and
116120
* accessible; -1 if not accessible.
117121
*/
118-
public abstract int getOutputBuffered();
122+
public abstract int streamWriteOutputBuffered();
119123

120124
/**
121125
* Helper method, usually equivalent to:

src/main/java/com/fasterxml/jackson/core/JsonParser.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ protected JsonParser() { }
131131
* return {@link JsonLocation#NA} due to not having access
132132
* to input location information (when delegating actual decoding work
133133
* to other library)
134+
*<p>
135+
* NOTE: was named {@code getTokenLocation()} in Jackson 2.x.
134136
*
135137
* @return Starting location of the token parser currently points to
136138
*/
137-
public abstract JsonLocation getTokenLocation();
139+
public abstract JsonLocation currentTokenLocation();
138140

139141
/**
140142
* Method that returns location of the last processed character;
@@ -167,10 +169,12 @@ protected JsonParser() { }
167169
*<p>
168170
* In general use of this accessor should be considered as
169171
* "last effort", i.e. only used if no other mechanism is applicable.
172+
*<p>
173+
* NOTE: was named {@code getInputSource()} in Jackson 2.x.
170174
*
171175
* @return Input source this parser was configured with
172176
*/
173-
public abstract Object getInputSource();
177+
public abstract Object streamReadSource();
174178

175179
/*
176180
/**********************************************************************

src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public int releaseBuffered(Writer w) throws JacksonException {
175175
return count;
176176
}
177177

178-
@Override public Object getInputSource() { return _reader; }
178+
@Override public Object streamReadSource() { return _reader; }
179179

180180
protected char getNextChar(String eofMsg, JsonToken forToken) throws JacksonException {
181181
if (_inputPtr >= _inputEnd) {
@@ -2867,7 +2867,7 @@ protected byte[] _decodeBase64(Base64Variant b64variant) throws JacksonException
28672867
*/
28682868

28692869
@Override
2870-
public JsonLocation getTokenLocation()
2870+
public JsonLocation currentTokenLocation()
28712871
{
28722872
if (_currToken == JsonToken.PROPERTY_NAME) {
28732873
long total = _currInputProcessed + (_nameStartOffset-1);

src/main/java/com/fasterxml/jackson/core/json/UTF8DataInputJsonParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public int releaseBuffered(OutputStream out) {
127127
}
128128

129129
@Override
130-
public Object getInputSource() {
130+
public Object streamReadSource() {
131131
return _inputData;
132132
}
133133

@@ -2903,7 +2903,7 @@ protected final byte[] _decodeBase64(Base64Variant b64variant) throws IOExceptio
29032903
*/
29042904

29052905
@Override
2906-
public JsonLocation getTokenLocation() {
2906+
public JsonLocation currentTokenLocation() {
29072907
// 03-Jan-2020, tatu: Should probably track this, similar to how
29082908
// streaming parsers do it, but... not done yet
29092909

src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ public JsonGenerator setCharacterEscapes(CharacterEscapes esc)
177177
*/
178178

179179
@Override
180-
public Object getOutputTarget() {
180+
public Object streamWriteTarget() {
181181
return _outputStream;
182182
}
183183

184184
@Override
185-
public int getOutputBuffered() {
185+
public int streamWriteOutputBuffered() {
186186
// Assuming tail is always valid, set to 0 on close
187187
return _outputTail;
188188
}

src/main/java/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public int releaseBuffered(OutputStream out) throws JacksonException
181181
}
182182

183183
@Override
184-
public Object getInputSource() {
184+
public Object streamReadSource() {
185185
return _inputStream;
186186
}
187187

@@ -4097,7 +4097,7 @@ protected final byte[] _decodeBase64(Base64Variant b64variant) throws JacksonExc
40974097

40984098
// As per [core#108], must ensure we call the right method
40994099
@Override
4100-
public JsonLocation getTokenLocation()
4100+
public JsonLocation currentTokenLocation()
41014101
{
41024102
if (_currToken == JsonToken.PROPERTY_NAME) {
41034103
long total = _currInputProcessed + (_nameStartOffset-1);

src/main/java/com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ public JsonGenerator setCharacterEscapes(CharacterEscapes esc)
122122
*/
123123

124124
@Override
125-
public Object getOutputTarget() {
125+
public Object streamWriteTarget() {
126126
return _writer;
127127
}
128128

129129
@Override
130-
public int getOutputBuffered() {
130+
public int streamWriteOutputBuffered() {
131131
// Assuming tail and head are kept but... trust and verify:
132132
int len = _outputTail - _outputHead;
133133
return Math.max(0, len);

src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParserBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ protected void _releaseBuffers() throws JacksonException
289289
}
290290

291291
@Override
292-
public Object getInputSource() {
292+
public Object streamReadSource() {
293293
// since input is "pushed", to traditional source...
294294
return null;
295295
}
@@ -336,7 +336,7 @@ public JsonLocation currentLocation()
336336
}
337337

338338
@Override
339-
public JsonLocation getTokenLocation()
339+
public JsonLocation currentTokenLocation()
340340
{
341341
return new JsonLocation(_getSourceReference(),
342342
_tokenInputTotal, -1L, _tokenInputRow, _tokenInputCol);

src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public void assignCurrentValue(Object v) {
6262

6363
@Override public FormatSchema getSchema() { return delegate.getSchema(); }
6464
@Override public Version version() { return delegate.version(); }
65-
@Override public Object getOutputTarget() { return delegate.getOutputTarget(); }
66-
@Override public int getOutputBuffered() { return delegate.getOutputBuffered(); }
65+
@Override public Object streamWriteTarget() { return delegate.streamWriteTarget(); }
66+
@Override public int streamWriteOutputBuffered() { return delegate.streamWriteOutputBuffered(); }
6767

6868
/*
6969
/**********************************************************************

src/main/java/com/fasterxml/jackson/core/util/JsonParserDelegate.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public JsonParserDelegate(JsonParser d) {
4242

4343
// // // Public API, input source, location access
4444

45-
@Override public JsonLocation getTokenLocation() { return delegate.getTokenLocation(); }
45+
@Override public JsonLocation currentTokenLocation() { return delegate.currentTokenLocation(); }
4646
@Override public JsonLocation currentLocation() { return delegate.currentLocation(); }
47-
@Override public Object getInputSource() { return delegate.getInputSource(); }
47+
@Override public Object streamReadSource() { return delegate.streamReadSource(); }
4848

4949
@Override
5050
public Object currentValue() {

src/test/java/com/fasterxml/jackson/core/filter/BasicGeneratorFilteringTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public void testSingleMatchFilteringWithPath() throws Exception
181181
);
182182

183183
// Hmmh. Should we get access to eventual target?
184-
assertSame(w, gen.getOutputTarget());
184+
assertSame(w, gen.streamWriteTarget());
185185
assertNotNull(gen.getFilterContext());
186186
assertSame(filter, gen.getFilter());
187187

@@ -203,7 +203,7 @@ public void testSingleMatchFilteringWithPathSkippedArray() throws Exception
203203
);
204204

205205
// Hmmh. Should we get access to eventual target?
206-
assertSame(w, gen.getOutputTarget());
206+
assertSame(w, gen.streamWriteTarget());
207207
assertNotNull(gen.getFilterContext());
208208
assertSame(filter, gen.getFilter());
209209

src/test/java/com/fasterxml/jackson/core/json/async/AsyncInvalidCharsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private void _testUTF8BomOk(int offset, int readSize) throws Exception
5656
* "out of stream" (not part of input).
5757
*/
5858

59-
JsonLocation loc = p.parser().getTokenLocation();
59+
JsonLocation loc = p.parser().currentTokenLocation();
6060
// so if BOM was consider in-stream (part of input), this should expect 3:
6161
// (NOTE: this is location for START_ARRAY token, now)
6262
assertEquals(-1, loc.getCharOffset());

src/test/java/com/fasterxml/jackson/core/json/async/AsyncLocationTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ public void testLocationOffsets() throws Exception
2020
feeder.feedInput(input, 2, 3);
2121
assertEquals(JsonToken.START_ARRAY, parser.nextToken());
2222
assertEquals(1, parser.currentLocation().getByteOffset());
23-
assertEquals(1, parser.getTokenLocation().getByteOffset());
23+
assertEquals(1, parser.currentTokenLocation().getByteOffset());
2424
assertEquals(1, parser.currentLocation().getLineNr());
25-
assertEquals(1, parser.getTokenLocation().getLineNr());
25+
assertEquals(1, parser.currentTokenLocation().getLineNr());
2626
assertEquals(2, parser.currentLocation().getColumnNr());
27-
assertEquals(1, parser.getTokenLocation().getColumnNr());
27+
assertEquals(1, parser.currentTokenLocation().getColumnNr());
2828

2929
feeder.feedInput(input, 0, 1);
3030
assertEquals(JsonToken.START_ARRAY, parser.nextToken());
3131
assertEquals(2, parser.currentLocation().getByteOffset());
32-
assertEquals(2, parser.getTokenLocation().getByteOffset());
32+
assertEquals(2, parser.currentTokenLocation().getByteOffset());
3333
assertEquals(1, parser.currentLocation().getLineNr());
34-
assertEquals(1, parser.getTokenLocation().getLineNr());
34+
assertEquals(1, parser.currentTokenLocation().getLineNr());
3535
assertEquals(3, parser.currentLocation().getColumnNr());
36-
assertEquals(2, parser.getTokenLocation().getColumnNr());
36+
assertEquals(2, parser.currentTokenLocation().getColumnNr());
3737
parser.close();
3838
}
3939
}

src/test/java/com/fasterxml/jackson/core/json/async/ConfigTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void testAsyncParerDefaults() throws IOException
2323
JsonParser p = r.parser();
2424

2525
assertTrue(p.canParseAsync());
26-
assertNull(p.getInputSource());
26+
assertNull(p.streamReadSource());
2727
assertEquals(-1, p.releaseBuffered(new StringWriter()));
2828
assertEquals(0, p.releaseBuffered(new ByteArrayOutputStream()));
2929

src/test/java/com/fasterxml/jackson/core/read/LocationDuringReaderParsingTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private void assertCurrentLocation(JsonParser p, LocData loc)
7575

7676
private void assertTokenLocation(JsonParser p, LocData loc)
7777
{
78-
assertLocation(p.getTokenLocation(), loc);
78+
assertLocation(p.currentTokenLocation(), loc);
7979
}
8080

8181
private void assertLocation(JsonLocation pLoc, LocData loc)

src/test/java/com/fasterxml/jackson/core/read/LocationDuringStreamParsingTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private void assertCurrentLocation(JsonParser p, LocData loc)
7575

7676
private void assertTokenLocation(JsonParser p, LocData loc)
7777
{
78-
assertLocation(p.getTokenLocation(), loc);
78+
assertLocation(p.currentTokenLocation(), loc);
7979
}
8080

8181
private void assertLocation(JsonLocation pLoc, LocData loc)

src/test/java/com/fasterxml/jackson/core/read/LocationInArrayTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ private void _testOffsetInArrays(boolean useBytes) throws Exception
2727
p = useBytes ? JSON_F.createParser(ObjectReadContext.empty(), DOC.getBytes("UTF-8"))
2828
: JSON_F.createParser(ObjectReadContext.empty(), DOC.toCharArray());
2929
assertToken(JsonToken.START_ARRAY, p.nextToken());
30-
_assertLocation(useBytes, p.getTokenLocation(), 2L, 1, 3);
30+
_assertLocation(useBytes, p.currentTokenLocation(), 2L, 1, 3);
3131
_assertLocation(useBytes, p.currentLocation(), 3L, 1, 4);
3232

3333
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
34-
_assertLocation(useBytes, p.getTokenLocation(), 3L, 1, 4);
34+
_assertLocation(useBytes, p.currentTokenLocation(), 3L, 1, 4);
3535
assertEquals(10, p.getIntValue()); // just to ensure read proceeds to end
3636
// 2-digits so
3737
_assertLocation(useBytes, p.currentLocation(), 5L, 1, 6);
3838

3939
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
40-
_assertLocation(useBytes, p.getTokenLocation(), 7L, 1, 8);
40+
_assertLocation(useBytes, p.currentTokenLocation(), 7L, 1, 8);
4141
assertEquals(251, p.getIntValue()); // just to ensure read proceeds to end
4242
_assertLocation(useBytes, p.currentLocation(), 10L, 1, 11);
4343

4444
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
45-
_assertLocation(useBytes, p.getTokenLocation(), 15L, 2, 4);
45+
_assertLocation(useBytes, p.currentTokenLocation(), 15L, 2, 4);
4646
assertEquals(3, p.getIntValue());
4747
_assertLocation(useBytes, p.currentLocation(), 16L, 2, 5);
4848

4949
assertToken(JsonToken.END_ARRAY, p.nextToken());
50-
_assertLocation(useBytes, p.getTokenLocation(), 18L, 2, 7);
50+
_assertLocation(useBytes, p.currentTokenLocation(), 18L, 2, 7);
5151
_assertLocation(useBytes, p.currentLocation(), 19L, 2, 8);
5252

5353
p.close();

0 commit comments

Comments
 (0)