Skip to content

Commit

Permalink
Minor renaming wrt streamRead/streamWrite context impls
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 26, 2021
1 parent ada5ece commit 5440887
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 248 deletions.
6 changes: 5 additions & 1 deletion src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,16 @@ protected JsonGenerator() { }
/**********************************************************************
*/

// 25-Jan-2021, tatu: Still called by `ClassUtil` of jackson-databind, to
// prevent secondary issues when closing generator. Should probably figure
// out alternate means of safe closing...

/**
* Method for enabling or disabling specified feature:
* check {@link StreamWriteFeature} for list of available features.
*<p>
* NOTE: mostly left in 3.0 just to support disabling of
* {@link StreamWriteFeature#AUTO_CLOSE_CONTENT}.
* {@link StreamWriteFeature#AUTO_CLOSE_CONTENT} by {@code jackson-databind}
*
* @param f Feature to enable or disable
* @param state Whether to enable the feature ({@code true}) or disable ({@code false})
Expand Down
20 changes: 3 additions & 17 deletions src/main/java/com/fasterxml/jackson/core/JsonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,24 +366,10 @@ public int releaseBuffered(OutputStream out) throws JacksonException {
/**********************************************************************
*/

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

/**
* Method for disabling specified feature
* (check {@link StreamReadFeature} for list of features)
*
* @param f Feature to disable
*
* @return This parser, to allow call chaining
*/
// public abstract JsonParser enable(StreamReadFeature f);
// public abstract JsonParser disable(StreamReadFeature f);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public abstract class JsonGeneratorBase extends GeneratorBase
/**
* Object that keeps track of the current contextual state of the generator.
*/
protected JsonWriteContext _tokenWriteContext;
protected JsonWriteContext _streamWriteContext;

/*
/**********************************************************************
Expand Down Expand Up @@ -149,7 +149,7 @@ protected JsonGeneratorBase(ObjectWriteContext writeCtxt, IOContext ctxt,

final DupDetector dups = StreamWriteFeature.STRICT_DUPLICATE_DETECTION.enabledIn(streamWriteFeatures)
? DupDetector.rootDetector(this) : null;
_tokenWriteContext = JsonWriteContext.createRootContext(dups);
_streamWriteContext = JsonWriteContext.createRootContext(dups);

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

@Override
public final TokenStreamContext streamWriteContext() { return _tokenWriteContext; }
public final TokenStreamContext streamWriteContext() { return _streamWriteContext; }

@Override
public final Object currentValue() {
return _tokenWriteContext.currentValue();
return _streamWriteContext.currentValue();
}

@Override
public final void assignCurrentValue(Object v) {
_tokenWriteContext.assignCurrentValue(v);
_streamWriteContext.assignCurrentValue(v);
}

/*
Expand Down Expand Up @@ -261,9 +261,9 @@ protected void _verifyPrettyValueWrite(String typeMsg, int status) throws Jackso
break;
case JsonWriteContext.STATUS_OK_AS_IS:
// First entry, but of which context?
if (_tokenWriteContext.inArray()) {
if (_streamWriteContext.inArray()) {
_cfgPrettyPrinter.beforeArrayValues(this);
} else if (_tokenWriteContext.inObject()) {
} else if (_streamWriteContext.inObject()) {
_cfgPrettyPrinter.beforeObjectEntries(this);
}
break;
Expand All @@ -279,6 +279,6 @@ protected void _verifyPrettyValueWrite(String typeMsg, int status) throws Jackso
protected void _reportCantWriteValueExpectName(String typeMsg) throws JacksonException
{
throw _constructWriteException("Cannot %s, expecting a property name (context: %s)",
typeMsg, _tokenWriteContext.typeDesc());
typeMsg, _streamWriteContext.typeDesc());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class JsonParserBase
* Information about parser context, context in which
* the next token is to be parsed (root, array, object).
*/
protected JsonReadContext _parsingContext;
protected JsonReadContext _streamReadContext;

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

/*
Expand All @@ -107,16 +107,16 @@ public JacksonFeatureSet<StreamReadCapability> streamReadCapabilities() {
/**********************************************************************
*/

@Override public TokenStreamContext streamReadContext() { return _parsingContext; }
@Override public TokenStreamContext streamReadContext() { return _streamReadContext; }

@Override
public Object currentValue() {
return _parsingContext.currentValue();
return _streamReadContext.currentValue();
}

@Override
public void assignCurrentValue(Object v) {
_parsingContext.assignCurrentValue(v);
_streamReadContext.assignCurrentValue(v);
}

/**
Expand All @@ -126,12 +126,12 @@ public void assignCurrentValue(Object v) {
@Override public String currentName() {
// [JACKSON-395]: start markers require information from parent
if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) {
JsonReadContext parent = _parsingContext.getParent();
JsonReadContext parent = _streamReadContext.getParent();
if (parent != null) {
return parent.currentName();
}
}
return _parsingContext.currentName();
return _streamReadContext.currentName();
}

@Override
Expand Down Expand Up @@ -314,7 +314,7 @@ protected char[] currentNameInBuffer() {
if (_nameCopied) {
return _nameCopyBuffer;
}
final String name = _parsingContext.currentName();
final String name = _streamReadContext.currentName();
final int nameLen = name.length();
if (_nameCopyBuffer.length < nameLen) {
_nameCopyBuffer = new char[Math.max(32, nameLen)];
Expand Down
Loading

0 comments on commit 5440887

Please sign in to comment.