Skip to content

Commit 5440887

Browse files
committed
Minor renaming wrt streamRead/streamWrite context impls
1 parent ada5ece commit 5440887

13 files changed

+245
-248
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,16 @@ protected JsonGenerator() { }
151151
/**********************************************************************
152152
*/
153153

154+
// 25-Jan-2021, tatu: Still called by `ClassUtil` of jackson-databind, to
155+
// prevent secondary issues when closing generator. Should probably figure
156+
// out alternate means of safe closing...
157+
154158
/**
155159
* Method for enabling or disabling specified feature:
156160
* check {@link StreamWriteFeature} for list of available features.
157161
*<p>
158162
* NOTE: mostly left in 3.0 just to support disabling of
159-
* {@link StreamWriteFeature#AUTO_CLOSE_CONTENT}.
163+
* {@link StreamWriteFeature#AUTO_CLOSE_CONTENT} by {@code jackson-databind}
160164
*
161165
* @param f Feature to enable or disable
162166
* @param state Whether to enable the feature ({@code true}) or disable ({@code false})

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

+3-17
Original file line numberDiff line numberDiff line change
@@ -366,24 +366,10 @@ public int releaseBuffered(OutputStream out) throws JacksonException {
366366
/**********************************************************************
367367
*/
368368

369-
/**
370-
* Method for enabling specified parser feature
371-
* (check {@link StreamReadFeature} for list of features)
372-
*
373-
* @param f Feature to enable
374-
*
375-
* @return This parser, to allow call chaining
376-
*/
377-
// public abstract JsonParser enable(StreamReadFeature f);
369+
// 25-Jan-2021, tatu: Was needed by jax-rs providers until recently,
370+
// but should no longer be needed at all. Leaving here for a bit longer.
378371

379-
/**
380-
* Method for disabling specified feature
381-
* (check {@link StreamReadFeature} for list of features)
382-
*
383-
* @param f Feature to disable
384-
*
385-
* @return This parser, to allow call chaining
386-
*/
372+
// public abstract JsonParser enable(StreamReadFeature f);
387373
// public abstract JsonParser disable(StreamReadFeature f);
388374

389375
/**

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public abstract class JsonGeneratorBase extends GeneratorBase
118118
/**
119119
* Object that keeps track of the current contextual state of the generator.
120120
*/
121-
protected JsonWriteContext _tokenWriteContext;
121+
protected JsonWriteContext _streamWriteContext;
122122

123123
/*
124124
/**********************************************************************
@@ -149,7 +149,7 @@ protected JsonGeneratorBase(ObjectWriteContext writeCtxt, IOContext ctxt,
149149

150150
final DupDetector dups = StreamWriteFeature.STRICT_DUPLICATE_DETECTION.enabledIn(streamWriteFeatures)
151151
? DupDetector.rootDetector(this) : null;
152-
_tokenWriteContext = JsonWriteContext.createRootContext(dups);
152+
_streamWriteContext = JsonWriteContext.createRootContext(dups);
153153

154154
// 03-Oct-2017, tatu: Not clean (shouldn't call non-static methods from ctor),
155155
// but for now best way to avoid code duplication
@@ -201,16 +201,16 @@ public CharacterEscapes getCharacterEscapes() {
201201
*/
202202

203203
@Override
204-
public final TokenStreamContext streamWriteContext() { return _tokenWriteContext; }
204+
public final TokenStreamContext streamWriteContext() { return _streamWriteContext; }
205205

206206
@Override
207207
public final Object currentValue() {
208-
return _tokenWriteContext.currentValue();
208+
return _streamWriteContext.currentValue();
209209
}
210210

211211
@Override
212212
public final void assignCurrentValue(Object v) {
213-
_tokenWriteContext.assignCurrentValue(v);
213+
_streamWriteContext.assignCurrentValue(v);
214214
}
215215

216216
/*
@@ -261,9 +261,9 @@ protected void _verifyPrettyValueWrite(String typeMsg, int status) throws Jackso
261261
break;
262262
case JsonWriteContext.STATUS_OK_AS_IS:
263263
// First entry, but of which context?
264-
if (_tokenWriteContext.inArray()) {
264+
if (_streamWriteContext.inArray()) {
265265
_cfgPrettyPrinter.beforeArrayValues(this);
266-
} else if (_tokenWriteContext.inObject()) {
266+
} else if (_streamWriteContext.inObject()) {
267267
_cfgPrettyPrinter.beforeObjectEntries(this);
268268
}
269269
break;
@@ -279,6 +279,6 @@ protected void _verifyPrettyValueWrite(String typeMsg, int status) throws Jackso
279279
protected void _reportCantWriteValueExpectName(String typeMsg) throws JacksonException
280280
{
281281
throw _constructWriteException("Cannot %s, expecting a property name (context: %s)",
282-
typeMsg, _tokenWriteContext.typeDesc());
282+
typeMsg, _streamWriteContext.typeDesc());
283283
}
284284
}

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public abstract class JsonParserBase
4343
* Information about parser context, context in which
4444
* the next token is to be parsed (root, array, object).
4545
*/
46-
protected JsonReadContext _parsingContext;
46+
protected JsonReadContext _streamReadContext;
4747

4848
/**
4949
* Secondary token related to the next token after current one;
@@ -84,7 +84,7 @@ protected JsonParserBase(ObjectReadContext readCtxt,
8484
_formatReadFeatures = formatReadFeatures;
8585
DupDetector dups = StreamReadFeature.STRICT_DUPLICATE_DETECTION.enabledIn(streamReadFeatures)
8686
? DupDetector.rootDetector(this) : null;
87-
_parsingContext = JsonReadContext.createRootContext(dups);
87+
_streamReadContext = JsonReadContext.createRootContext(dups);
8888
}
8989

9090
/*
@@ -107,16 +107,16 @@ public JacksonFeatureSet<StreamReadCapability> streamReadCapabilities() {
107107
/**********************************************************************
108108
*/
109109

110-
@Override public TokenStreamContext streamReadContext() { return _parsingContext; }
110+
@Override public TokenStreamContext streamReadContext() { return _streamReadContext; }
111111

112112
@Override
113113
public Object currentValue() {
114-
return _parsingContext.currentValue();
114+
return _streamReadContext.currentValue();
115115
}
116116

117117
@Override
118118
public void assignCurrentValue(Object v) {
119-
_parsingContext.assignCurrentValue(v);
119+
_streamReadContext.assignCurrentValue(v);
120120
}
121121

122122
/**
@@ -126,12 +126,12 @@ public void assignCurrentValue(Object v) {
126126
@Override public String currentName() {
127127
// [JACKSON-395]: start markers require information from parent
128128
if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) {
129-
JsonReadContext parent = _parsingContext.getParent();
129+
JsonReadContext parent = _streamReadContext.getParent();
130130
if (parent != null) {
131131
return parent.currentName();
132132
}
133133
}
134-
return _parsingContext.currentName();
134+
return _streamReadContext.currentName();
135135
}
136136

137137
@Override
@@ -314,7 +314,7 @@ protected char[] currentNameInBuffer() {
314314
if (_nameCopied) {
315315
return _nameCopyBuffer;
316316
}
317-
final String name = _parsingContext.currentName();
317+
final String name = _streamReadContext.currentName();
318318
final int nameLen = name.length();
319319
if (_nameCopyBuffer.length < nameLen) {
320320
_nameCopyBuffer = new char[Math.max(32, nameLen)];

0 commit comments

Comments
 (0)