From 54408875016f5658a3c4d18c955eae131761bb01 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 25 Jan 2021 21:22:24 -0800 Subject: [PATCH] Minor renaming wrt streamRead/streamWrite context impls --- .../fasterxml/jackson/core/JsonGenerator.java | 6 +- .../fasterxml/jackson/core/JsonParser.java | 20 +---- .../jackson/core/json/JsonGeneratorBase.java | 16 ++-- .../jackson/core/json/JsonParserBase.java | 16 ++-- .../core/json/ReaderBasedJsonParser.java | 82 ++++++++--------- .../core/json/UTF8DataInputJsonParser.java | 64 +++++++------- .../jackson/core/json/UTF8JsonGenerator.java | 42 ++++----- .../core/json/UTF8StreamJsonParser.java | 88 +++++++++---------- .../core/json/WriterBasedJsonGenerator.java | 38 ++++---- .../json/async/NonBlockingJsonParser.java | 12 +-- .../json/async/NonBlockingJsonParserBase.java | 26 +++--- ...text.java => SimpleStreamReadContext.java} | 37 ++++---- ...ext.java => SimpleStreamWriteContext.java} | 46 +++++----- 13 files changed, 245 insertions(+), 248 deletions(-) rename src/main/java/com/fasterxml/jackson/core/util/{SimpleTokenReadContext.java => SimpleStreamReadContext.java} (80%) rename src/main/java/com/fasterxml/jackson/core/util/{SimpleTokenWriteContext.java => SimpleStreamWriteContext.java} (77%) diff --git a/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java b/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java index eb0cfebf00..1373c56a4b 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java @@ -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. *

* 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}) diff --git a/src/main/java/com/fasterxml/jackson/core/JsonParser.java b/src/main/java/com/fasterxml/jackson/core/JsonParser.java index 43fa557374..d48770e692 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonParser.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonParser.java @@ -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); /** diff --git a/src/main/java/com/fasterxml/jackson/core/json/JsonGeneratorBase.java b/src/main/java/com/fasterxml/jackson/core/json/JsonGeneratorBase.java index 35c939e7f0..ef46dffa11 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/JsonGeneratorBase.java +++ b/src/main/java/com/fasterxml/jackson/core/json/JsonGeneratorBase.java @@ -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; /* /********************************************************************** @@ -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 @@ -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); } /* @@ -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; @@ -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()); } } diff --git a/src/main/java/com/fasterxml/jackson/core/json/JsonParserBase.java b/src/main/java/com/fasterxml/jackson/core/json/JsonParserBase.java index 23567913c4..3ae8194178 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/JsonParserBase.java +++ b/src/main/java/com/fasterxml/jackson/core/json/JsonParserBase.java @@ -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; @@ -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); } /* @@ -107,16 +107,16 @@ public JacksonFeatureSet 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); } /** @@ -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 @@ -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)]; diff --git a/src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java b/src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java index 59bfd7fbeb..ecad4508c3 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java +++ b/src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java @@ -312,7 +312,7 @@ public int getText(Writer writer) throws JacksonException return _textBuffer.contentsToWriter(writer); } if (t == JsonToken.PROPERTY_NAME) { - String n = _parsingContext.currentName(); + String n = _streamReadContext.currentName(); writer.write(n); return n.length(); } @@ -369,7 +369,7 @@ protected final String _getText2(JsonToken t) { } switch (t.id()) { case ID_PROPERTY_NAME: - return _parsingContext.currentName(); + return _streamReadContext.currentName(); case ID_STRING: // fall through @@ -410,7 +410,7 @@ public final int getTextLength() throws JacksonException if (_currToken != null) { // null only before/after document switch (_currToken.id()) { case ID_PROPERTY_NAME: - return _parsingContext.currentName().length(); + return _streamReadContext.currentName().length(); case ID_STRING: if (_tokenIncomplete) { _tokenIncomplete = false; @@ -690,7 +690,7 @@ public final JsonToken nextToken() throws JacksonException } // Nope: do we then expect a comma? - if (_parsingContext.expectComma()) { + if (_streamReadContext.expectComma()) { i = _skipComma(i); // Was that a trailing comma? @@ -705,12 +705,12 @@ public final JsonToken nextToken() throws JacksonException /* And should we now have a name? Always true for Object contexts, since * the intermediate 'expect-value' state is never retained. */ - boolean inObject = _parsingContext.inObject(); + boolean inObject = _streamReadContext.inObject(); if (inObject) { // First, the property name itself: _updateNameLocation(); String name = (i == INT_QUOTE) ? _parseName() : _handleOddName(i); - _parsingContext.setCurrentName(name); + _streamReadContext.setCurrentName(name); _currToken = JsonToken.PROPERTY_NAME; i = _skipColon(); } @@ -727,13 +727,13 @@ public final JsonToken nextToken() throws JacksonException break; case '[': if (!inObject) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } t = JsonToken.START_ARRAY; break; case '{': if (!inObject) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } t = JsonToken.START_OBJECT; break; @@ -799,9 +799,9 @@ private final JsonToken _nextAfterName() // Also: may need to start new context? if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return (_currToken = t); } @@ -847,7 +847,7 @@ public boolean nextName(SerializableString sstr) throws JacksonException return false; } - if (_parsingContext.expectComma()) { + if (_streamReadContext.expectComma()) { i = _skipComma(i); // Was that a trailing comma? @@ -859,7 +859,7 @@ public boolean nextName(SerializableString sstr) throws JacksonException } } - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _updateLocation(); _nextTokenNotInObject(i); return false; @@ -880,7 +880,7 @@ public boolean nextName(SerializableString sstr) throws JacksonException int ptr = _inputPtr; while (true) { if (ptr == end) { // yes, match! - _parsingContext.setCurrentName(sstr.getValue()); + _streamReadContext.setCurrentName(sstr.getValue()); _isNextTokenNameYes(_skipColonFast(ptr+1)); return true; } @@ -920,7 +920,7 @@ public String nextName() throws JacksonException _closeScope(i); return null; } - if (_parsingContext.expectComma()) { + if (_streamReadContext.expectComma()) { i = _skipComma(i); if ((_formatReadFeatures & FEAT_MASK_TRAILING_COMMA) != 0) { if ((i == INT_RBRACKET) || (i == INT_RCURLY)) { @@ -929,7 +929,7 @@ public String nextName() throws JacksonException } } } - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _updateLocation(); _nextTokenNotInObject(i); return null; @@ -937,7 +937,7 @@ public String nextName() throws JacksonException _updateNameLocation(); String name = (i == INT_QUOTE) ? _parseName() : _handleOddName(i); - _parsingContext.setCurrentName(name); + _streamReadContext.setCurrentName(name); _currToken = JsonToken.PROPERTY_NAME; i = _skipColon(); @@ -1051,7 +1051,7 @@ protected boolean _isNextTokenNameMaybe(int i, String nameToMatch) throws Jackso { // // // and this is back to standard nextToken() String name = (i == INT_QUOTE) ? _parseName() : _handleOddName(i); - _parsingContext.setCurrentName(name); + _streamReadContext.setCurrentName(name); _currToken = JsonToken.PROPERTY_NAME; i = _skipColon(); _updateLocation(); @@ -1115,10 +1115,10 @@ private final JsonToken _nextTokenNotInObject(int i) throws JacksonException } switch (i) { case '[': - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); return (_currToken = JsonToken.START_ARRAY); case '{': - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); return (_currToken = JsonToken.START_OBJECT); case 't': _matchToken("true", 1); @@ -1159,7 +1159,7 @@ private final JsonToken _nextTokenNotInObject(int i) throws JacksonException // case ']': // 11-May-2020, tatu: related to [core#616], this should never be reached case ',': // 11-May-2020, tatu: [core#616] No commas in root level - if (!_parsingContext.inRoot()) { + if (!_streamReadContext.inRoot()) { if ((_formatReadFeatures & FEAT_MASK_ALLOW_MISSING) != 0) { --_inputPtr; return (_currToken = JsonToken.VALUE_NULL); @@ -1185,9 +1185,9 @@ public final String nextTextValue() throws JacksonException return _textBuffer.contentsAsString(); } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return null; } @@ -1208,9 +1208,9 @@ public final int nextIntValue(int defaultValue) throws JacksonException return getIntValue(); } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return defaultValue; } @@ -1231,9 +1231,9 @@ public final long nextLongValue(long defaultValue) throws JacksonException return getLongValue(); } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return defaultValue; } @@ -1257,9 +1257,9 @@ public final Boolean nextBooleanValue() throws JacksonException return Boolean.FALSE; } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return null; } @@ -1355,7 +1355,7 @@ protected final JsonToken _parsePosNumber(int ch) throws JacksonException --ptr; // need to push back following separator _inputPtr = ptr; // As per #105, need separating space between root values; check here - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(ch); } int len = ptr-startPtr; @@ -1418,7 +1418,7 @@ private final JsonToken _parseFloat(int ch, int startPtr, int ptr, boolean neg, --ptr; // need to push back following separator _inputPtr = ptr; // As per #105, need separating space between root values; check here - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(ch); } int len = ptr-startPtr; @@ -1467,7 +1467,7 @@ protected final JsonToken _parseNegNumber() throws JacksonException } --ptr; _inputPtr = ptr; - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(ch); } int len = ptr-startPtr; @@ -1610,7 +1610,7 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws JacksonE // Ok; unless we hit end-of-input, need to push last char read back if (!eof) { --_inputPtr; - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(c); } } @@ -1937,13 +1937,13 @@ protected JsonToken _handleOddValue(int i) throws JacksonException // 28-Mar-2016: [core#116]: If Feature.ALLOW_MISSING_VALUES is enabled // we may allow "missing values", that is, encountering a trailing // comma or closing marker where value would be expected - if (!_parsingContext.inArray()) { + if (!_streamReadContext.inArray()) { break; } // fall through case ',': // 11-May-2020, tatu: [core#616] No commas in root level - if (!_parsingContext.inRoot()) { + if (!_streamReadContext.inRoot()) { if ((_formatReadFeatures & FEAT_MASK_ALLOW_MISSING) != 0) { --_inputPtr; return JsonToken.VALUE_NULL; @@ -2297,7 +2297,7 @@ private final int _skipColon2(boolean gotColon) throws JacksonException } } } - _reportInvalidEOF(" within/between "+_parsingContext.typeDesc()+" entries", + _reportInvalidEOF(" within/between "+_streamReadContext.typeDesc()+" entries", null); return -1; } @@ -2354,7 +2354,7 @@ private final int _skipColonFast(int ptr) throws JacksonException private final int _skipComma(int i) throws JacksonException { if (i != INT_COMMA) { - _reportUnexpectedChar(i, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); + _reportUnexpectedChar(i, "was expecting comma to separate "+_streamReadContext.typeDesc()+" entries"); } while (_inputPtr < _inputEnd) { i = (int) _inputBuffer[_inputPtr++]; @@ -2406,7 +2406,7 @@ private final int _skipAfterComma2() throws JacksonException } } } - throw _constructReadException("Unexpected end-of-input within/between "+_parsingContext.typeDesc()+" entries"); + throw _constructReadException("Unexpected end-of-input within/between "+_streamReadContext.typeDesc()+" entries"); } private final int _skipWSOrEnd() throws JacksonException @@ -2946,18 +2946,18 @@ private void _closeScope(int i) throws StreamReadException { if (i == INT_RBRACKET) { _updateLocation(); - if (!_parsingContext.inArray()) { + if (!_streamReadContext.inArray()) { _reportMismatchedEndMarker(i, '}'); } - _parsingContext = _parsingContext.clearAndGetParent(); + _streamReadContext = _streamReadContext.clearAndGetParent(); _currToken = JsonToken.END_ARRAY; } if (i == INT_RCURLY) { _updateLocation(); - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _reportMismatchedEndMarker(i, ']'); } - _parsingContext = _parsingContext.clearAndGetParent(); + _streamReadContext = _streamReadContext.clearAndGetParent(); _currToken = JsonToken.END_OBJECT; } } diff --git a/src/main/java/com/fasterxml/jackson/core/json/UTF8DataInputJsonParser.java b/src/main/java/com/fasterxml/jackson/core/json/UTF8DataInputJsonParser.java index c6a475178c..496380899a 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/UTF8DataInputJsonParser.java +++ b/src/main/java/com/fasterxml/jackson/core/json/UTF8DataInputJsonParser.java @@ -186,7 +186,7 @@ public int getText(Writer writer) throws JacksonException return _textBuffer.contentsToWriter(writer); } if (t == JsonToken.PROPERTY_NAME) { - String n = _parsingContext.currentName(); + String n = _streamReadContext.currentName(); writer.write(n); return n.length(); } @@ -282,7 +282,7 @@ protected final String _getText2(JsonToken t) } switch (t.id()) { case ID_PROPERTY_NAME: - return _parsingContext.currentName(); + return _streamReadContext.currentName(); case ID_STRING: // fall through @@ -330,7 +330,7 @@ public int getTextLength() throws JacksonException return _textBuffer.size(); } if (_currToken == JsonToken.PROPERTY_NAME) { - return _parsingContext.currentName().length(); + return _streamReadContext.currentName().length(); } if (_currToken != null) { // null only before/after document if (_currToken.isNumeric()) { @@ -594,9 +594,9 @@ private final JsonToken _nextToken() throws IOException } // Nope: do we then expect a comma? - if (_parsingContext.expectComma()) { + if (_streamReadContext.expectComma()) { if (i != INT_COMMA) { - _reportUnexpectedChar(i, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); + _reportUnexpectedChar(i, "was expecting comma to separate "+_streamReadContext.typeDesc()+" entries"); } i = _skipWS(); @@ -613,12 +613,12 @@ private final JsonToken _nextToken() throws IOException * Object contexts, since the intermediate 'expect-value' * state is never retained. */ - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { return _nextTokenNotInObject(i); } // So first parse the property name itself: String n = _parseName(i); - _parsingContext.setCurrentName(n); + _streamReadContext.setCurrentName(n); _currToken = JsonToken.PROPERTY_NAME; i = _skipColon(); @@ -688,10 +688,10 @@ private final JsonToken _nextTokenNotInObject(int i) throws IOException } switch (i) { case '[': - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); return (_currToken = JsonToken.START_ARRAY); case '{': - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); return (_currToken = JsonToken.START_OBJECT); case 't': _matchToken("true", 1); @@ -732,9 +732,9 @@ private final JsonToken _nextAfterName() // Also: may need to start new context? if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return (_currToken = t); } @@ -787,9 +787,9 @@ private final String _nextName() throws IOException } // Nope: do we then expect a comma? - if (_parsingContext.expectComma()) { + if (_streamReadContext.expectComma()) { if (i != INT_COMMA) { - _reportUnexpectedChar(i, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); + _reportUnexpectedChar(i, "was expecting comma to separate "+_streamReadContext.typeDesc()+" entries"); } i = _skipWS(); @@ -802,13 +802,13 @@ private final String _nextName() throws IOException } } - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _nextTokenNotInObject(i); return null; } final String nameStr = _parseName(i); - _parsingContext.setCurrentName(nameStr); + _streamReadContext.setCurrentName(nameStr); _currToken = JsonToken.PROPERTY_NAME; i = _skipColon(); @@ -879,9 +879,9 @@ public String nextTextValue() throws JacksonException return _textBuffer.contentsAsString(); } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return null; } @@ -901,9 +901,9 @@ public int nextIntValue(int defaultValue) throws JacksonException return getIntValue(); } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return defaultValue; } @@ -923,9 +923,9 @@ public long nextLongValue(long defaultValue) throws JacksonException return getLongValue(); } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return defaultValue; } @@ -948,9 +948,9 @@ public Boolean nextBooleanValue() throws JacksonException return Boolean.FALSE; } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return null; } @@ -1041,7 +1041,7 @@ protected JsonToken _parsePosNumber(int c) throws IOException } _textBuffer.setCurrentLength(outPtr); // As per [core#105], need separating space between root values; check here - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(); } else { _nextByte = c; @@ -1088,7 +1088,7 @@ protected JsonToken _parseNegNumber() throws IOException _textBuffer.setCurrentLength(outPtr); // As per [core#105], need separating space between root values; check here _nextByte = c; - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(); } // And there we have it! @@ -1186,7 +1186,7 @@ private final JsonToken _parseFloat(char[] outBuf, int outPtr, int c, // Ok; unless we hit end-of-input, need to push last char read back // As per #105, need separating space between root values; check here _nextByte = c; - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(); } _textBuffer.setCurrentLength(outPtr); @@ -2064,13 +2064,13 @@ protected JsonToken _handleUnexpectedValue(int c) // Most likely an error, unless we are to allow single-quote-strings switch (c) { case ']': - if (!_parsingContext.inArray()) { + if (!_streamReadContext.inArray()) { break; } // fall through case ',': // 11-May-2020, tatu: [core#616] No commas in root level - if (!_parsingContext.inRoot()) { + if (!_streamReadContext.inRoot()) { if (isEnabled(JsonReadFeature.ALLOW_MISSING_VALUES)) { // _inputPtr--; _nextByte = c; @@ -2933,17 +2933,17 @@ public JsonLocation currentLocation() { private void _closeScope(int i) throws StreamReadException { if (i == INT_RBRACKET) { - if (!_parsingContext.inArray()) { + if (!_streamReadContext.inArray()) { _reportMismatchedEndMarker(i, '}'); } - _parsingContext = _parsingContext.clearAndGetParent(); + _streamReadContext = _streamReadContext.clearAndGetParent(); _currToken = JsonToken.END_ARRAY; } if (i == INT_RCURLY) { - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _reportMismatchedEndMarker(i, ']'); } - _parsingContext = _parsingContext.clearAndGetParent(); + _streamReadContext = _streamReadContext.clearAndGetParent(); _currToken = JsonToken.END_OBJECT; } } diff --git a/src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java b/src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java index 4da5d68777..c1f9a6f130 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java +++ b/src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java @@ -200,7 +200,7 @@ public void writeName(String name) throws JacksonException _writePPName(name); return; } - final int status = _tokenWriteContext.writeName(name); + final int status = _streamWriteContext.writeName(name); if (status == JsonWriteContext.STATUS_EXPECT_VALUE) { _reportError("Cannot write a property name, expecting a value"); } @@ -247,7 +247,7 @@ public void writeName(SerializableString name) throws JacksonException _writePPName(name); return; } - final int status = _tokenWriteContext.writeName(name.getValue()); + final int status = _streamWriteContext.writeName(name.getValue()); if (status == JsonWriteContext.STATUS_EXPECT_VALUE) { _reportError("Cannot write a property name, expecting a value"); } @@ -296,7 +296,7 @@ private final void _writeUnq(SerializableString name) throws JacksonException { public final void writeStartArray() throws JacksonException { _verifyValueWrite("start an array"); - _tokenWriteContext = _tokenWriteContext.createChildArrayContext(null); + _streamWriteContext = _streamWriteContext.createChildArrayContext(null); if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartArray(this); } else { @@ -311,7 +311,7 @@ public final void writeStartArray() throws JacksonException public final void writeStartArray(Object forValue) throws JacksonException { _verifyValueWrite("start an array"); - _tokenWriteContext = _tokenWriteContext.createChildArrayContext(forValue); + _streamWriteContext = _streamWriteContext.createChildArrayContext(forValue); if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartArray(this); } else { @@ -326,7 +326,7 @@ public final void writeStartArray(Object forValue) throws JacksonException public final void writeStartArray(Object forValue, int len) throws JacksonException { _verifyValueWrite("start an array"); - _tokenWriteContext = _tokenWriteContext.createChildArrayContext(forValue); + _streamWriteContext = _streamWriteContext.createChildArrayContext(forValue); if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartArray(this); } else { @@ -340,25 +340,25 @@ public final void writeStartArray(Object forValue, int len) throws JacksonExcept @Override public final void writeEndArray() throws JacksonException { - if (!_tokenWriteContext.inArray()) { - _reportError("Current context not Array but "+_tokenWriteContext.typeDesc()); + if (!_streamWriteContext.inArray()) { + _reportError("Current context not Array but "+_streamWriteContext.typeDesc()); } if (_cfgPrettyPrinter != null) { - _cfgPrettyPrinter.writeEndArray(this, _tokenWriteContext.getEntryCount()); + _cfgPrettyPrinter.writeEndArray(this, _streamWriteContext.getEntryCount()); } else { if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_RBRACKET; } - _tokenWriteContext = _tokenWriteContext.clearAndGetParent(); + _streamWriteContext = _streamWriteContext.clearAndGetParent(); } @Override public final void writeStartObject() throws JacksonException { _verifyValueWrite("start an object"); - _tokenWriteContext = _tokenWriteContext.createChildObjectContext(null); + _streamWriteContext = _streamWriteContext.createChildObjectContext(null); if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartObject(this); } else { @@ -373,8 +373,8 @@ public final void writeStartObject() throws JacksonException public void writeStartObject(Object forValue) throws JacksonException { _verifyValueWrite("start an object"); - JsonWriteContext ctxt = _tokenWriteContext.createChildObjectContext(forValue); - _tokenWriteContext = ctxt; + JsonWriteContext ctxt = _streamWriteContext.createChildObjectContext(forValue); + _streamWriteContext = ctxt; if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartObject(this); } else { @@ -389,8 +389,8 @@ public void writeStartObject(Object forValue) throws JacksonException public void writeStartObject(Object forValue, int size) throws JacksonException { _verifyValueWrite("start an object"); - JsonWriteContext ctxt = _tokenWriteContext.createChildObjectContext(forValue); - _tokenWriteContext = ctxt; + JsonWriteContext ctxt = _streamWriteContext.createChildObjectContext(forValue); + _streamWriteContext = ctxt; if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartObject(this); } else { @@ -404,25 +404,25 @@ public void writeStartObject(Object forValue, int size) throws JacksonException @Override public final void writeEndObject() throws JacksonException { - if (!_tokenWriteContext.inObject()) { - _reportError("Current context not Object but "+_tokenWriteContext.typeDesc()); + if (!_streamWriteContext.inObject()) { + _reportError("Current context not Object but "+_streamWriteContext.typeDesc()); } if (_cfgPrettyPrinter != null) { - _cfgPrettyPrinter.writeEndObject(this, _tokenWriteContext.getEntryCount()); + _cfgPrettyPrinter.writeEndObject(this, _streamWriteContext.getEntryCount()); } else { if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_RCURLY; } - _tokenWriteContext = _tokenWriteContext.clearAndGetParent(); + _streamWriteContext = _streamWriteContext.clearAndGetParent(); } // Specialized version of {@code _writeName}, off-lined // to keep the "fast path" as simple (and hopefully fast) as possible. protected final void _writePPName(String name) throws JacksonException { - int status = _tokenWriteContext.writeName(name); + int status = _streamWriteContext.writeName(name); if (status == JsonWriteContext.STATUS_EXPECT_VALUE) { _reportError("Cannot write a property name, expecting a value"); } @@ -462,7 +462,7 @@ protected final void _writePPName(String name) throws JacksonException protected final void _writePPName(SerializableString name) throws JacksonException { - final int status = _tokenWriteContext.writeName(name.getValue()); + final int status = _streamWriteContext.writeName(name.getValue()); if (status == JsonWriteContext.STATUS_EXPECT_VALUE) { _reportError("Cannot write a property name, expecting a value"); } @@ -1140,7 +1140,7 @@ public void writeNull() throws JacksonException @Override protected final void _verifyValueWrite(String typeMsg) throws JacksonException { - final int status = _tokenWriteContext.writeValue(); + final int status = _streamWriteContext.writeValue(); if (_cfgPrettyPrinter != null) { // Otherwise, pretty printer knows what to do... _verifyPrettyValueWrite(typeMsg, status); diff --git a/src/main/java/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java b/src/main/java/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java index 19a40688b5..f09509b82a 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java +++ b/src/main/java/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java @@ -305,7 +305,7 @@ public int getText(Writer writer) throws JacksonException return _textBuffer.contentsToWriter(writer); } if (t == JsonToken.PROPERTY_NAME) { - String n = _parsingContext.currentName(); + String n = _streamReadContext.currentName(); writer.write(n); return n.length(); } @@ -404,7 +404,7 @@ protected final String _getText2(JsonToken t) } switch (t.id()) { case ID_PROPERTY_NAME: - return _parsingContext.currentName(); + return _streamReadContext.currentName(); case ID_STRING: // fall through @@ -448,7 +448,7 @@ public int getTextLength() throws JacksonException switch (_currToken.id()) { case ID_PROPERTY_NAME: - return _parsingContext.currentName().length(); + return _streamReadContext.currentName().length(); case ID_STRING: if (_tokenIncomplete) { _tokenIncomplete = false; @@ -723,9 +723,9 @@ public JsonToken nextToken() throws JacksonException } // Nope: do we then expect a comma? - if (_parsingContext.expectComma()) { + if (_streamReadContext.expectComma()) { if (i != INT_COMMA) { - _reportUnexpectedChar(i, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); + _reportUnexpectedChar(i, "was expecting comma to separate "+_streamReadContext.typeDesc()+" entries"); } i = _skipWS(); // Was that a trailing comma? @@ -739,14 +739,14 @@ public JsonToken nextToken() throws JacksonException /* And should we now have a name? Always true for Object contexts * since the intermediate 'expect-value' state is never retained. */ - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _updateLocation(); return _nextTokenNotInObject(i); } // So first parse the property name itself: _updateNameLocation(); String n = _parseName(i); - _parsingContext.setCurrentName(n); + _streamReadContext.setCurrentName(n); _currToken = JsonToken.PROPERTY_NAME; i = _skipColon(); @@ -816,10 +816,10 @@ private final JsonToken _nextTokenNotInObject(int i) throws JacksonException } switch (i) { case '[': - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); return (_currToken = JsonToken.START_ARRAY); case '{': - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); return (_currToken = JsonToken.START_OBJECT); case 't': _matchTrue(); @@ -862,9 +862,9 @@ private final JsonToken _nextAfterName() // Also: may need to start new context? if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return (_currToken = t); } @@ -916,9 +916,9 @@ public String nextName() throws JacksonException } // Nope: do we then expect a comma? - if (_parsingContext.expectComma()) { + if (_streamReadContext.expectComma()) { if (i != INT_COMMA) { - _reportUnexpectedChar(i, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); + _reportUnexpectedChar(i, "was expecting comma to separate "+_streamReadContext.typeDesc()+" entries"); } i = _skipWS(); // Was that a trailing comma? @@ -930,7 +930,7 @@ public String nextName() throws JacksonException } } - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _updateLocation(); _nextTokenNotInObject(i); return null; @@ -938,7 +938,7 @@ public String nextName() throws JacksonException _updateNameLocation(); final String nameStr = _parseName(i); - _parsingContext.setCurrentName(nameStr); + _streamReadContext.setCurrentName(nameStr); _currToken = JsonToken.PROPERTY_NAME; i = _skipColon(); @@ -1024,9 +1024,9 @@ public boolean nextName(SerializableString str) throws JacksonException } // Nope: do we then expect a comma? - if (_parsingContext.expectComma()) { + if (_streamReadContext.expectComma()) { if (i != INT_COMMA) { - _reportUnexpectedChar(i, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); + _reportUnexpectedChar(i, "was expecting comma to separate "+_streamReadContext.typeDesc()+" entries"); } i = _skipWS(); @@ -1038,7 +1038,7 @@ public boolean nextName(SerializableString str) throws JacksonException } } } - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _updateLocation(); _nextTokenNotInObject(i); return false; @@ -1060,7 +1060,7 @@ public boolean nextName(SerializableString str) throws JacksonException int ptr = _inputPtr; while (true) { if (ptr == end) { // yes, match! - _parsingContext.setCurrentName(str.getValue()); + _streamReadContext.setCurrentName(str.getValue()); i = _skipColonFast(ptr+1); _isNextTokenNameYes(i); return true; @@ -1109,9 +1109,9 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException } // Nope: do we then expect a comma? - if (_parsingContext.expectComma()) { + if (_streamReadContext.expectComma()) { if (i != INT_COMMA) { - _reportUnexpectedChar(i, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); + _reportUnexpectedChar(i, "was expecting comma to separate "+_streamReadContext.typeDesc()+" entries"); } i = _skipWS(); // Was that a trailing comma? @@ -1124,7 +1124,7 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException } } - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _updateLocation(); _nextTokenNotInObject(i); return PropertyNameMatcher.MATCH_ODD_TOKEN; @@ -1149,7 +1149,7 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException match = matcher.matchName(name); } - _parsingContext.setCurrentName(name); + _streamReadContext.setCurrentName(name); _currToken = JsonToken.PROPERTY_NAME; // Otherwise, try again... @@ -1310,7 +1310,7 @@ private final boolean _isNextTokenNameMaybe(int i, SerializableString str) throw // // // and this is back to standard nextToken() String n = _parseName(i); - _parsingContext.setCurrentName(n); + _streamReadContext.setCurrentName(n); final boolean match = n.equals(str.getValue()); _currToken = JsonToken.PROPERTY_NAME; i = _skipColon(); @@ -1614,9 +1614,9 @@ public String nextTextValue() throws JacksonException return _textBuffer.contentsAsString(); } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return null; } @@ -1637,9 +1637,9 @@ public int nextIntValue(int defaultValue) throws JacksonException return getIntValue(); } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return defaultValue; } @@ -1660,9 +1660,9 @@ public long nextLongValue(long defaultValue) throws JacksonException return getLongValue(); } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return defaultValue; } @@ -1686,9 +1686,9 @@ public Boolean nextBooleanValue() throws JacksonException return Boolean.FALSE; } if (t == JsonToken.START_ARRAY) { - _parsingContext = _parsingContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol); } else if (t == JsonToken.START_OBJECT) { - _parsingContext = _parsingContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); + _streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol); } return null; } @@ -1774,7 +1774,7 @@ protected JsonToken _parsePosNumber(int c) throws JacksonException --_inputPtr; // to push back trailing char (comma etc) _textBuffer.setCurrentLength(outPtr); // As per #105, need separating space between root values; check here - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(c); } // And there we have it! @@ -1831,7 +1831,7 @@ protected JsonToken _parseNegNumber() throws JacksonException --_inputPtr; // to push back trailing char (comma etc) _textBuffer.setCurrentLength(outPtr); // As per #105, need separating space between root values; check here - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(c); } @@ -1867,7 +1867,7 @@ private final JsonToken _parseNumber2(char[] outBuf, int outPtr, boolean negativ --_inputPtr; // to push back trailing char (comma etc) _textBuffer.setCurrentLength(outPtr); // As per #105, need separating space between root values; check here - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(_inputBuffer[_inputPtr] & 0xFF); } @@ -1997,7 +1997,7 @@ private final JsonToken _parseFloat(char[] outBuf, int outPtr, int c, if (!eof) { --_inputPtr; // As per [core#105], need separating space between root values; check here - if (_parsingContext.inRoot()) { + if (_streamReadContext.inRoot()) { _verifyRootSpace(c); } } @@ -2986,7 +2986,7 @@ protected JsonToken _handleUnexpectedValue(int c) throws JacksonException * Also the case returns NULL as current token in case of ',' or ']'. */ case ']': - if (!_parsingContext.inArray()) { + if (!_streamReadContext.inArray()) { break; } // fall through @@ -2995,7 +2995,7 @@ protected JsonToken _handleUnexpectedValue(int c) throws JacksonException // we may allow "missing values", that is, encountering a trailing // comma or closing marker where value would be expected // 11-May-2020, tatu: [core#616] No commas in root level - if (!_parsingContext.inRoot()) { + if (!_streamReadContext.inRoot()) { if ((_formatReadFeatures & FEAT_MASK_ALLOW_MISSING) != 0) { --_inputPtr; return JsonToken.VALUE_NULL; @@ -3330,7 +3330,7 @@ private final int _skipWS2() throws JacksonException } } } - throw _constructReadException("Unexpected end-of-input within/between "+_parsingContext.typeDesc()+" entries"); + throw _constructReadException("Unexpected end-of-input within/between "+_streamReadContext.typeDesc()+" entries"); } private final int _skipWSOrEnd() throws JacksonException @@ -3502,7 +3502,7 @@ private final int _skipColon2(boolean gotColon) throws JacksonException } } } - _reportInvalidEOF(" within/between "+_parsingContext.typeDesc()+" entries", + _reportInvalidEOF(" within/between "+_streamReadContext.typeDesc()+" entries", null); return -1; } @@ -4151,17 +4151,17 @@ private final JsonToken _closeScope(int i) throws StreamReadException { private final void _closeArrayScope() throws StreamReadException { _updateLocation(); - if (!_parsingContext.inArray()) { + if (!_streamReadContext.inArray()) { _reportMismatchedEndMarker(']', '}'); } - _parsingContext = _parsingContext.clearAndGetParent(); + _streamReadContext = _streamReadContext.clearAndGetParent(); } private final void _closeObjectScope() throws StreamReadException { _updateLocation(); - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _reportMismatchedEndMarker('}', ']'); } - _parsingContext = _parsingContext.clearAndGetParent(); + _streamReadContext = _streamReadContext.clearAndGetParent(); } } diff --git a/src/main/java/com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.java b/src/main/java/com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.java index e494b2de0b..8b67eb4357 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.java +++ b/src/main/java/com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.java @@ -146,7 +146,7 @@ public int getOutputBuffered() { @Override public void writeName(String name) throws JacksonException { - int status = _tokenWriteContext.writeName(name); + int status = _streamWriteContext.writeName(name); if (status == JsonWriteContext.STATUS_EXPECT_VALUE) { _reportError("Cannot write a property name, expecting a value"); } @@ -157,7 +157,7 @@ public void writeName(String name) throws JacksonException public void writeName(SerializableString name) throws JacksonException { // Object is a value, need to verify it's allowed - int status = _tokenWriteContext.writeName(name.getValue()); + int status = _streamWriteContext.writeName(name.getValue()); if (status == JsonWriteContext.STATUS_EXPECT_VALUE) { _reportError("Cannot write a property name, expecting a value"); } @@ -248,7 +248,7 @@ private final void _writeNameTail(SerializableString name) throws JacksonExcepti public void writeStartArray() throws JacksonException { _verifyValueWrite("start an array"); - _tokenWriteContext = _tokenWriteContext.createChildArrayContext(null); + _streamWriteContext = _streamWriteContext.createChildArrayContext(null); if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartArray(this); } else { @@ -263,7 +263,7 @@ public void writeStartArray() throws JacksonException public void writeStartArray(Object forValue) throws JacksonException { _verifyValueWrite("start an array"); - _tokenWriteContext = _tokenWriteContext.createChildArrayContext(forValue); + _streamWriteContext = _streamWriteContext.createChildArrayContext(forValue); if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartArray(this); } else { @@ -278,7 +278,7 @@ public void writeStartArray(Object forValue) throws JacksonException public void writeStartArray(Object forValue, int len) throws JacksonException { _verifyValueWrite("start an array"); - _tokenWriteContext = _tokenWriteContext.createChildArrayContext(forValue); + _streamWriteContext = _streamWriteContext.createChildArrayContext(forValue); if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartArray(this); } else { @@ -292,25 +292,25 @@ public void writeStartArray(Object forValue, int len) throws JacksonException @Override public void writeEndArray() throws JacksonException { - if (!_tokenWriteContext.inArray()) { - _reportError("Current context not Array but "+_tokenWriteContext.typeDesc()); + if (!_streamWriteContext.inArray()) { + _reportError("Current context not Array but "+_streamWriteContext.typeDesc()); } if (_cfgPrettyPrinter != null) { - _cfgPrettyPrinter.writeEndArray(this, _tokenWriteContext.getEntryCount()); + _cfgPrettyPrinter.writeEndArray(this, _streamWriteContext.getEntryCount()); } else { if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = ']'; } - _tokenWriteContext = _tokenWriteContext.clearAndGetParent(); + _streamWriteContext = _streamWriteContext.clearAndGetParent(); } @Override public void writeStartObject() throws JacksonException { _verifyValueWrite("start an object"); - _tokenWriteContext = _tokenWriteContext.createChildObjectContext(null); + _streamWriteContext = _streamWriteContext.createChildObjectContext(null); if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartObject(this); } else { @@ -325,8 +325,8 @@ public void writeStartObject() throws JacksonException public void writeStartObject(Object forValue) throws JacksonException { _verifyValueWrite("start an object"); - JsonWriteContext ctxt = _tokenWriteContext.createChildObjectContext(forValue); - _tokenWriteContext = ctxt; + JsonWriteContext ctxt = _streamWriteContext.createChildObjectContext(forValue); + _streamWriteContext = ctxt; if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartObject(this); } else { @@ -341,8 +341,8 @@ public void writeStartObject(Object forValue) throws JacksonException public void writeStartObject(Object forValue, int size) throws JacksonException { _verifyValueWrite("start an object"); - JsonWriteContext ctxt = _tokenWriteContext.createChildObjectContext(forValue); - _tokenWriteContext = ctxt; + JsonWriteContext ctxt = _streamWriteContext.createChildObjectContext(forValue); + _streamWriteContext = ctxt; if (_cfgPrettyPrinter != null) { _cfgPrettyPrinter.writeStartObject(this); } else { @@ -356,18 +356,18 @@ public void writeStartObject(Object forValue, int size) throws JacksonException @Override public void writeEndObject() throws JacksonException { - if (!_tokenWriteContext.inObject()) { - _reportError("Current context not Object but "+_tokenWriteContext.typeDesc()); + if (!_streamWriteContext.inObject()) { + _reportError("Current context not Object but "+_streamWriteContext.typeDesc()); } if (_cfgPrettyPrinter != null) { - _cfgPrettyPrinter.writeEndObject(this, _tokenWriteContext.getEntryCount()); + _cfgPrettyPrinter.writeEndObject(this, _streamWriteContext.getEntryCount()); } else { if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = '}'; } - _tokenWriteContext = _tokenWriteContext.clearAndGetParent(); + _streamWriteContext = _streamWriteContext.clearAndGetParent(); } // Specialized version of _writeName, off-lined @@ -956,7 +956,7 @@ public void writeNull() throws JacksonException { @Override protected final void _verifyValueWrite(String typeMsg) throws JacksonException { - final int status = _tokenWriteContext.writeValue(); + final int status = _streamWriteContext.writeValue(); if (_cfgPrettyPrinter != null) { // Otherwise, pretty printer knows what to do... _verifyPrettyValueWrite(typeMsg, status); diff --git a/src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParser.java b/src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParser.java index d8f5e4a22f..68ac245723 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParser.java +++ b/src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParser.java @@ -571,7 +571,7 @@ private final JsonToken _startPropertyNameAfterComma(int ch) throws JacksonExcep if (ch == INT_SLASH) { return _startSlashComment(MINOR_PROPERTY_LEADING_COMMA); } - _reportUnexpectedChar(ch, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); + _reportUnexpectedChar(ch, "was expecting comma to separate "+_streamReadContext.typeDesc()+" entries"); } int ptr = _inputPtr; if (ptr >= _inputEnd) { @@ -629,7 +629,7 @@ private final JsonToken _startValue(int ch) throws JacksonException } _updateTokenLocation(); // 17-Sep-2019, tatu: [core#563] Need to call this to update index within array - _parsingContext.expectComma(); + _streamReadContext.expectComma(); if (ch == INT_QUOTE) { return _startString(); @@ -708,11 +708,11 @@ private final JsonToken _startValueExpectComma(int ch) throws JacksonException if (ch == INT_HASH) { return _finishHashComment(MINOR_VALUE_EXPECTING_COMMA); } - _reportUnexpectedChar(ch, "was expecting comma to separate "+_parsingContext.typeDesc()+" entries"); + _reportUnexpectedChar(ch, "was expecting comma to separate "+_streamReadContext.typeDesc()+" entries"); } // 17-Sep-2019, tatu: [core#563] Need to call this to update index within array - _parsingContext.expectComma(); + _streamReadContext.expectComma(); int ptr = _inputPtr; if (ptr >= _inputEnd) { @@ -925,7 +925,7 @@ protected JsonToken _startUnexpectedValue(boolean leadingComma, int ch) { switch (ch) { case INT_RBRACKET: - if (!_parsingContext.inArray()) { + if (!_streamReadContext.inArray()) { break; } // fall through @@ -934,7 +934,7 @@ protected JsonToken _startUnexpectedValue(boolean leadingComma, int ch) // we may allow "missing values", that is, encountering a trailing // comma or closing marker where value would be expected // 11-May-2020, tatu: [core#616] No commas in root level - if (!_parsingContext.inRoot()) { + if (!_streamReadContext.inRoot()) { if ((_formatReadFeatures & FEAT_MASK_ALLOW_MISSING) != 0) { --_inputPtr; return _valueComplete(JsonToken.VALUE_NULL); diff --git a/src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParserBase.java b/src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParserBase.java index c8f6b62fae..a4a7f8a0f8 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParserBase.java +++ b/src/main/java/com/fasterxml/jackson/core/json/async/NonBlockingJsonParserBase.java @@ -372,7 +372,7 @@ protected final String _getText2(JsonToken t) case ID_NOT_AVAILABLE: return null; case ID_PROPERTY_NAME: - return _parsingContext.currentName(); + return _streamReadContext.currentName(); case ID_STRING: // fall through case ID_NUMBER_INT: @@ -392,7 +392,7 @@ public int getText(Writer writer) throws JacksonException return _textBuffer.contentsToWriter(writer); } if (t == JsonToken.PROPERTY_NAME) { - String n = _parsingContext.currentName(); + String n = _streamReadContext.currentName(); writer.write(n); return n.length(); } @@ -467,7 +467,7 @@ public int getTextLength() throws JacksonException switch (_currToken.id()) { case ID_PROPERTY_NAME: - return _parsingContext.currentName().length(); + return _streamReadContext.currentName().length(); case ID_STRING: // fall through case ID_NUMBER_INT: @@ -551,7 +551,7 @@ public Object getEmbeddedObject() throws JacksonException protected final JsonToken _startArrayScope() throws JacksonException { - _parsingContext = _parsingContext.createChildArrayContext(-1, -1); + _streamReadContext = _streamReadContext.createChildArrayContext(-1, -1); _majorState = MAJOR_ARRAY_ELEMENT_FIRST; _majorStateAfterValue = MAJOR_ARRAY_ELEMENT_NEXT; return (_currToken = JsonToken.START_ARRAY); @@ -559,7 +559,7 @@ protected final JsonToken _startArrayScope() throws JacksonException protected final JsonToken _startObjectScope() throws JacksonException { - _parsingContext = _parsingContext.createChildObjectContext(-1, -1); + _streamReadContext = _streamReadContext.createChildObjectContext(-1, -1); _majorState = MAJOR_OBJECT_PROPERTY_FIRST; _majorStateAfterValue = MAJOR_OBJECT_PROPERTY_NEXT; return (_currToken = JsonToken.START_OBJECT); @@ -567,11 +567,11 @@ protected final JsonToken _startObjectScope() throws JacksonException protected final JsonToken _closeArrayScope() throws JacksonException { - if (!_parsingContext.inArray()) { + if (!_streamReadContext.inArray()) { _reportMismatchedEndMarker(']', '}'); } - JsonReadContext ctxt = _parsingContext.getParent(); - _parsingContext = ctxt; + JsonReadContext ctxt = _streamReadContext.getParent(); + _streamReadContext = ctxt; int st; if (ctxt.inObject()) { st = MAJOR_OBJECT_PROPERTY_NEXT; @@ -587,11 +587,11 @@ protected final JsonToken _closeArrayScope() throws JacksonException protected final JsonToken _closeObjectScope() throws JacksonException { - if (!_parsingContext.inObject()) { + if (!_streamReadContext.inObject()) { _reportMismatchedEndMarker('}', ']'); } - JsonReadContext ctxt = _parsingContext.getParent(); - _parsingContext = ctxt; + JsonReadContext ctxt = _streamReadContext.getParent(); + _streamReadContext = ctxt; int st; if (ctxt.inObject()) { st = MAJOR_OBJECT_PROPERTY_NEXT; @@ -780,7 +780,7 @@ protected final static int _padLastQuad(int q, int bytes) { // input feeder has indicated no more input will be forthcoming. protected final JsonToken _eofAsNextToken() throws JacksonException { _majorState = MAJOR_CLOSED; - if (!_parsingContext.inRoot()) { + if (!_streamReadContext.inRoot()) { _handleEOF(); } close(); @@ -790,7 +790,7 @@ protected final JsonToken _eofAsNextToken() throws JacksonException { protected final JsonToken _fieldComplete(String name) throws JacksonException { _majorState = MAJOR_OBJECT_VALUE; - _parsingContext.setCurrentName(name); + _streamReadContext.setCurrentName(name); return (_currToken = JsonToken.PROPERTY_NAME); } diff --git a/src/main/java/com/fasterxml/jackson/core/util/SimpleTokenReadContext.java b/src/main/java/com/fasterxml/jackson/core/util/SimpleStreamReadContext.java similarity index 80% rename from src/main/java/com/fasterxml/jackson/core/util/SimpleTokenReadContext.java rename to src/main/java/com/fasterxml/jackson/core/util/SimpleStreamReadContext.java index 6c8765f567..bc4d3c615a 100644 --- a/src/main/java/com/fasterxml/jackson/core/util/SimpleTokenReadContext.java +++ b/src/main/java/com/fasterxml/jackson/core/util/SimpleStreamReadContext.java @@ -4,12 +4,19 @@ import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.core.json.DupDetector; -public class SimpleTokenReadContext extends TokenStreamContext +/** + * Basic implementation of {@link TokenStreamContext} useful for most + * format backend {@link JsonParser} implementations + * (with notable exception of JSON that needs bit more advanced state). + * + * @since 3.0 + */ +public class SimpleStreamReadContext extends TokenStreamContext { /** * Parent context for this context; null for root context. */ - protected final SimpleTokenReadContext _parent; + protected final SimpleStreamReadContext _parent; // // // Optional duplicate detection @@ -22,7 +29,7 @@ public class SimpleTokenReadContext extends TokenStreamContext /********************************************************************** */ - protected SimpleTokenReadContext _childToRecycle; + protected SimpleStreamReadContext _childToRecycle; /* /********************************************************************** @@ -43,7 +50,7 @@ public class SimpleTokenReadContext extends TokenStreamContext /********************************************************** */ - public SimpleTokenReadContext(int type, SimpleTokenReadContext parent, DupDetector dups, + public SimpleStreamReadContext(int type, SimpleStreamReadContext parent, DupDetector dups, int lineNr, int colNr) { super(); _parent = parent; @@ -82,18 +89,18 @@ public void assignCurrentValue(Object v) { /********************************************************************** */ - public static SimpleTokenReadContext createRootContext(int lineNr, int colNr, DupDetector dups) { - return new SimpleTokenReadContext(TYPE_ROOT, null, dups, lineNr, colNr); + public static SimpleStreamReadContext createRootContext(int lineNr, int colNr, DupDetector dups) { + return new SimpleStreamReadContext(TYPE_ROOT, null, dups, lineNr, colNr); } - public static SimpleTokenReadContext createRootContext(DupDetector dups) { + public static SimpleStreamReadContext createRootContext(DupDetector dups) { return createRootContext(1, 0, dups); } - public SimpleTokenReadContext createChildArrayContext(int lineNr, int colNr) { - SimpleTokenReadContext ctxt = _childToRecycle; + public SimpleStreamReadContext createChildArrayContext(int lineNr, int colNr) { + SimpleStreamReadContext ctxt = _childToRecycle; if (ctxt == null) { - _childToRecycle = ctxt = new SimpleTokenReadContext(TYPE_ARRAY, this, + _childToRecycle = ctxt = new SimpleStreamReadContext(TYPE_ARRAY, this, (_dups == null) ? null : _dups.child(), lineNr, colNr); } else { ctxt.reset(TYPE_ARRAY, lineNr, colNr); @@ -101,10 +108,10 @@ public SimpleTokenReadContext createChildArrayContext(int lineNr, int colNr) { return ctxt; } - public SimpleTokenReadContext createChildObjectContext(int lineNr, int colNr) { - SimpleTokenReadContext ctxt = _childToRecycle; + public SimpleStreamReadContext createChildObjectContext(int lineNr, int colNr) { + SimpleStreamReadContext ctxt = _childToRecycle; if (ctxt == null) { - _childToRecycle = ctxt = new SimpleTokenReadContext(TYPE_OBJECT, this, + _childToRecycle = ctxt = new SimpleStreamReadContext(TYPE_OBJECT, this, (_dups == null) ? null : _dups.child(), lineNr, colNr); return ctxt; } @@ -125,7 +132,7 @@ public SimpleTokenReadContext createChildObjectContext(int lineNr, int colNr) { @Override public boolean hasCurrentName() { return _currentName != null; } - @Override public SimpleTokenReadContext getParent() { return _parent; } + @Override public SimpleStreamReadContext getParent() { return _parent; } @Override public JsonLocation getStartLocation(Object srcRef) { @@ -150,7 +157,7 @@ public JsonLocation getStartLocation(Object srcRef) { * * @return Parent context of this context node, if any; {@code null} for root context */ - public SimpleTokenReadContext clearAndGetParent() { + public SimpleStreamReadContext clearAndGetParent() { _currentValue = null; // could also clear the current name, but seems cheap enough to leave? return _parent; diff --git a/src/main/java/com/fasterxml/jackson/core/util/SimpleTokenWriteContext.java b/src/main/java/com/fasterxml/jackson/core/util/SimpleStreamWriteContext.java similarity index 77% rename from src/main/java/com/fasterxml/jackson/core/util/SimpleTokenWriteContext.java rename to src/main/java/com/fasterxml/jackson/core/util/SimpleStreamWriteContext.java index 10e63a8e07..8dcd296252 100644 --- a/src/main/java/com/fasterxml/jackson/core/util/SimpleTokenWriteContext.java +++ b/src/main/java/com/fasterxml/jackson/core/util/SimpleStreamWriteContext.java @@ -5,18 +5,18 @@ import com.fasterxml.jackson.core.json.DupDetector; /** - * Basic implementation of {@code TokenStreamContext} useful for most - * format backends (with notable exception of JSON that needs bit more - * advanced state). + * Basic implementation of {@link TokenStreamContext} useful for most + * format backend {@link JsonGenerator} implementations + * (with notable exception of JSON that needs bit more advanced state). * * @since 3.0 */ -public final class SimpleTokenWriteContext extends TokenStreamContext +public final class SimpleStreamWriteContext extends TokenStreamContext { /** * Parent context for this context; null for root context. */ - protected final SimpleTokenWriteContext _parent; + protected final SimpleStreamWriteContext _parent; // // // Optional duplicate detection @@ -29,7 +29,7 @@ public final class SimpleTokenWriteContext extends TokenStreamContext /********************************************************************** */ - protected SimpleTokenWriteContext _childToRecycle; + protected SimpleStreamWriteContext _childToRecycle; /* /********************************************************************** @@ -39,15 +39,15 @@ public final class SimpleTokenWriteContext extends TokenStreamContext /** * Name of the property of which value is to be written; only - * used for OBJECT contexts + * used for OBJECT contexts. */ protected String _currentName; protected Object _currentValue; /** - * Marker used to indicate that we just wrote a property name - * and now expect a value to write + * Marker used to indicate that we just wrote a property name (or possibly + * property id for some backends) and now expect a value to write. */ protected boolean _gotFieldId; @@ -57,8 +57,8 @@ public final class SimpleTokenWriteContext extends TokenStreamContext /********************************************************************** */ - protected SimpleTokenWriteContext(int type, SimpleTokenWriteContext parent, DupDetector dups, - Object currentValue) { + protected SimpleStreamWriteContext(int type, SimpleStreamWriteContext parent, + DupDetector dups, Object currentValue) { super(); _type = type; _parent = parent; @@ -67,7 +67,7 @@ protected SimpleTokenWriteContext(int type, SimpleTokenWriteContext parent, DupD _currentValue = currentValue; } - private SimpleTokenWriteContext reset(int type, Object currentValue) { + private SimpleStreamWriteContext reset(int type, Object currentValue) { _type = type; _index = -1; _currentName = null; @@ -77,7 +77,7 @@ private SimpleTokenWriteContext reset(int type, Object currentValue) { return this; } - public SimpleTokenWriteContext withDupDetector(DupDetector dups) { + public SimpleStreamWriteContext withDupDetector(DupDetector dups) { _dups = dups; return this; } @@ -98,24 +98,24 @@ public void assignCurrentValue(Object v) { /********************************************************************** */ - public static SimpleTokenWriteContext createRootContext(DupDetector dd) { - return new SimpleTokenWriteContext(TYPE_ROOT, null, dd, null); + public static SimpleStreamWriteContext createRootContext(DupDetector dd) { + return new SimpleStreamWriteContext(TYPE_ROOT, null, dd, null); } - public SimpleTokenWriteContext createChildArrayContext(Object currentValue) { - SimpleTokenWriteContext ctxt = _childToRecycle; + public SimpleStreamWriteContext createChildArrayContext(Object currentValue) { + SimpleStreamWriteContext ctxt = _childToRecycle; if (ctxt == null) { - _childToRecycle = ctxt = new SimpleTokenWriteContext(TYPE_ARRAY, this, + _childToRecycle = ctxt = new SimpleStreamWriteContext(TYPE_ARRAY, this, (_dups == null) ? null : _dups.child(), currentValue); return ctxt; } return ctxt.reset(TYPE_ARRAY, currentValue); } - public SimpleTokenWriteContext createChildObjectContext(Object currentValue) { - SimpleTokenWriteContext ctxt = _childToRecycle; + public SimpleStreamWriteContext createChildObjectContext(Object currentValue) { + SimpleStreamWriteContext ctxt = _childToRecycle; if (ctxt == null) { - _childToRecycle = ctxt = new SimpleTokenWriteContext(TYPE_OBJECT, this, + _childToRecycle = ctxt = new SimpleStreamWriteContext(TYPE_OBJECT, this, (_dups == null) ? null : _dups.child(), currentValue); return ctxt; } @@ -128,7 +128,7 @@ public SimpleTokenWriteContext createChildObjectContext(Object currentValue) { /********************************************************************** */ - @Override public final SimpleTokenWriteContext getParent() { return _parent; } + @Override public final SimpleStreamWriteContext getParent() { return _parent; } @Override public final String currentName() { // 15-Aug-2019, tatu: Should NOT check this status because otherwise name // in parent context is not accessible after new structured scope started @@ -148,7 +148,7 @@ public SimpleTokenWriteContext createChildObjectContext(Object currentValue) { * * @return Parent context of this context node, if any; {@code null} for root context */ - public SimpleTokenWriteContext clearAndGetParent() { + public SimpleStreamWriteContext clearAndGetParent() { _currentValue = null; // could also clear the current name, but seems cheap enough to leave? return _parent;