/* /********************************************************** /* Public API, traversal, nextXxxValue/nextFieldName /********************************************************** */ /// <exception cref="System.IO.IOException"/> public override bool nextFieldName(com.fasterxml.jackson.core.SerializableString str) { // // // Note: most of code below is copied from nextToken() _numTypesValid = NR_UNKNOWN; if (_currToken == com.fasterxml.jackson.core.JsonToken.FIELD_NAME) { // can't have name right after name _nextAfterName(); return false; } if (_tokenIncomplete) { _skipString(); } int i = _skipWSOrEnd(); if (i < 0) { // end-of-input close(); _currToken = null; return false; } _tokenInputTotal = _currInputProcessed + _inputPtr - 1; _tokenInputRow = _currInputRow; _tokenInputCol = _inputPtr - _currInputRowStart - 1; // finally: clear any data retained so far _binaryValue = null; // Closing scope? if (i == INT_RBRACKET) { if (!_parsingContext.inArray()) { _reportMismatchedEndMarker(i, '}'); } _parsingContext = ((com.fasterxml.jackson.core.json.JsonReadContext)_parsingContext .getParent()); _currToken = com.fasterxml.jackson.core.JsonToken.END_ARRAY; return false; } if (i == INT_RCURLY) { if (!_parsingContext.inObject()) { _reportMismatchedEndMarker(i, ']'); } _parsingContext = ((com.fasterxml.jackson.core.json.JsonReadContext)_parsingContext .getParent()); _currToken = com.fasterxml.jackson.core.JsonToken.END_OBJECT; return false; } // Nope: do we then expect a comma? if (_parsingContext.expectComma()) { if (i != INT_COMMA) { _reportUnexpectedChar(i, "was expecting comma to separate " + _parsingContext.getTypeDesc () + " entries"); } i = _skipWS(); } if (!_parsingContext.inObject()) { _nextTokenNotInObject(i); return false; } // // // This part differs, name parsing if (i == INT_QUOTE) { // when doing literal match, must consider escaping: byte[] nameBytes = str.asQuotedUTF8(); int len = nameBytes.Length; // 22-May-2014, tatu: Actually, let's require 4 more bytes for faster skipping // of colon that follows name if ((_inputPtr + len + 4) < _inputEnd) { // maybe... // first check length match by int end = _inputPtr + len; if (_inputBuffer[end] == INT_QUOTE) { int offset = 0; int ptr = _inputPtr; while (true) { if (ptr == end) { // yes, match! _parsingContext.setCurrentName(str.getValue()); _isNextTokenNameYes(_skipColonFast(ptr + 1)); return true; } if (nameBytes[offset] != _inputBuffer[ptr]) { break; } ++offset; ++ptr; } } } } return _isNextTokenNameMaybe(i, str); }
//public abstract void writeString(String text) throws IOException; //public abstract void writeString(char[] text, int offset, int len) throws IOException; //public abstract void writeRaw(String text) throws IOException,; //public abstract void writeRaw(char[] text, int offset, int len) throws IOException; /// <exception cref="System.IO.IOException"/> public override void writeString(com.fasterxml.jackson.core.SerializableString text ) { writeString(text.getValue()); }
/// <exception cref="System.IO.IOException"/> private bool _isNextTokenNameMaybe(int i, com.fasterxml.jackson.core.SerializableString str) { // // // and this is back to standard nextToken() string n = _parseName(i); _parsingContext.setCurrentName(n); bool match = n.Equals(str.getValue()); _currToken = com.fasterxml.jackson.core.JsonToken.FIELD_NAME; i = _skipColon(); // Ok: we must have a value... what is it? Strings are very common, check first: if (i == INT_QUOTE) { _tokenIncomplete = true; _nextToken = com.fasterxml.jackson.core.JsonToken.VALUE_STRING; return match; } com.fasterxml.jackson.core.JsonToken t; switch (i) { case '[': { t = com.fasterxml.jackson.core.JsonToken.START_ARRAY; break; } case '{': { t = com.fasterxml.jackson.core.JsonToken.START_OBJECT; break; } case 't': { _matchToken("true", 1); t = com.fasterxml.jackson.core.JsonToken.VALUE_TRUE; break; } case 'f': { _matchToken("false", 1); t = com.fasterxml.jackson.core.JsonToken.VALUE_FALSE; break; } case 'n': { _matchToken("null", 1); t = com.fasterxml.jackson.core.JsonToken.VALUE_NULL; break; } case '-': { t = _parseNegNumber(); break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { t = _parsePosNumber(i); break; } default: { t = _handleUnexpectedValue(i); break; } } _nextToken = t; return match; }
/// <exception cref="System.IO.IOException"/> public override void writeFieldName(com.fasterxml.jackson.core.SerializableString name) { if (_cfgPrettyPrinter != null) { _writePPFieldName(name); return; } int status = _writeContext.writeFieldName(name.getValue()); if (status == com.fasterxml.jackson.core.json.JsonWriteContext.STATUS_EXPECT_VALUE) { _reportError("Can not write a field name, expecting a value"); } if (status == com.fasterxml.jackson.core.json.JsonWriteContext.STATUS_OK_AFTER_COMMA) { if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_COMMA; } if (_cfgUnqNames) { _writeUnq(name); return; } if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; int len = name.appendQuotedUTF8(_outputBuffer, _outputTail); if (len < 0) { // couldn't append, bit longer processing _writeBytes(name.asQuotedUTF8()); } else { _outputTail += len; } if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; }
/* /********************************************************** /* Public API, write methods, structural /********************************************************** */ //public void writeStartArray() throws IOException //public void writeEndArray() throws IOException //public void writeStartObject() throws IOException //public void writeEndObject() throws IOException /* /********************************************************** /* Public API, write methods, textual /********************************************************** */ /// <exception cref="System.IO.IOException"/> public override void writeFieldName(com.fasterxml.jackson.core.SerializableString name) { writeFieldName(name.getValue()); }
/// <exception cref="System.IO.IOException"/> protected internal void _writePPFieldName(com.fasterxml.jackson.core.SerializableString name) { int status = _writeContext.writeFieldName(name.getValue()); if (status == com.fasterxml.jackson.core.json.JsonWriteContext.STATUS_EXPECT_VALUE) { _reportError("Can not write a field name, expecting a value"); } if (status == com.fasterxml.jackson.core.json.JsonWriteContext.STATUS_OK_AFTER_COMMA) { _cfgPrettyPrinter.writeObjectEntrySeparator(this); } else { _cfgPrettyPrinter.beforeObjectEntries(this); } bool addQuotes = !_cfgUnqNames; // standard if (addQuotes) { if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; } _writeBytes(name.asQuotedUTF8()); if (addQuotes) { if (_outputTail >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = BYTE_QUOTE; } }
/// <summary> /// Method similar to /// <see cref="writeRawValue(string)"/> /// , but potentially more /// efficient as it may be able to use pre-encoded content (similar to /// <see cref="writeRaw(SerializableString)"/> /// . /// </summary> /// <since>2.5</since> /// <exception cref="System.IO.IOException"/> public virtual void writeRawValue(com.fasterxml.jackson.core.SerializableString raw ) { writeRawValue(raw.getValue()); }
/// <exception cref="System.IO.IOException"/> public override void writeFieldName(com.fasterxml.jackson.core.SerializableString name) { // Object is a value, need to verify it's allowed int status = _writeContext.writeFieldName(name.getValue()); if (status == com.fasterxml.jackson.core.json.JsonWriteContext.STATUS_EXPECT_VALUE) { _reportError("Can not write a field name, expecting a value"); } _writeFieldName(name, (status == com.fasterxml.jackson.core.json.JsonWriteContext .STATUS_OK_AFTER_COMMA)); }
/// <exception cref="System.IO.IOException"/> public override void writeString(com.fasterxml.jackson.core.SerializableString value ) { if (_itemFilter == null) { return; } if (_itemFilter != com.fasterxml.jackson.core.filter.TokenFilter.INCLUDE_ALL) { com.fasterxml.jackson.core.filter.TokenFilter state = _filterContext.checkValue(_itemFilter ); if (state == null) { return; } if (state != com.fasterxml.jackson.core.filter.TokenFilter.INCLUDE_ALL) { if (!state.includeString(value.getValue())) { return; } } _checkParentPath(); } delegate_.writeString(value); }
/// <exception cref="System.IO.IOException"/> public override void writeFieldName(com.fasterxml.jackson.core.SerializableString name) { com.fasterxml.jackson.core.filter.TokenFilter state = _filterContext.setFieldName (name.getValue()); if (state == null) { _itemFilter = null; return; } if (state == com.fasterxml.jackson.core.filter.TokenFilter.INCLUDE_ALL) { _itemFilter = state; delegate_.writeFieldName(name); return; } state = state.includeProperty(name.getValue()); _itemFilter = state; if (state == com.fasterxml.jackson.core.filter.TokenFilter.INCLUDE_ALL) { _checkPropertyParentPath(); } }