/** * Overridable factory method that actually instantiates parser * using given <code>char[]</code> object for accessing content. * * @since 2.4 */ protected JsonParser _createParser(char[] data, int offset, int len, IOContext ctxt, boolean recyclable) throws IOException { return new ReaderBasedJsonParser(ctxt, _parserFeatures, null, _objectCodec, _rootCharSymbols.makeChild(_factoryFeatures), data, offset, offset+len, recyclable); }
protected final String _parseName() throws IOException { // First: let's try to see if we have a simple name: one that does // not cross input buffer boundary, and does not contain escape sequences. int ptr = _inputPtr; int hash = _hashSeed; final int[] codes = _icLatin1; while (ptr < _inputEnd) { int ch = _inputBuffer[ptr]; if (ch < codes.length && codes[ch] != 0) { if (ch == '"') { int start = _inputPtr; _inputPtr = ptr+1; // to skip the quote return _symbols.findSymbol(_inputBuffer, start, ptr - start, hash); } break; } hash = (hash * CharsToNameCanonicalizer.HASH_MULT) + ch; ++ptr; } int start = _inputPtr; _inputPtr = ptr; return _parseName2(start, hash, INT_QUOTE); }
/** * Method called to release internal buffers owned by the base * reader. This may be called along with {@link #_closeInput} (for * example, when explicitly closing this reader instance), or * separately (if need be). */ @Override protected void _releaseBuffers() throws IOException { super._releaseBuffers(); // merge new symbols, if any _symbols.release(); // and release buffers, if they are recyclable ones if (_bufferRecyclable) { char[] buf = _inputBuffer; if (buf != null) { _inputBuffer = null; _ioContext.releaseTokenBuffer(buf); } } }
/** * Method called by the using code to indicate it is done with this instance. * This lets instance merge accumulated changes into parent (if need be), * safely and efficiently, and without calling code having to know about parent * information. */ public void release() { // If nothing has been added, nothing to do if (!maybeDirty()) { return; } // we will try to merge if child table has new entries if (_parent != null && _canonicalize) { // canonicalize set to false if max size was reached _parent.mergeChild(new TableInfo(this)); // Let's also mark this instance as dirty, so that just in // case release was too early, there's no corruption of possibly shared data. _hashShared = true; } }
private String _addSymbol(char[] buffer, int start, int len, int h, int index) copyArrays(); _hashShared = false; } else if (_size >= _sizeThreshold) { // Need to expand? rehash(); index = _hashToIndex(calcHash(buffer, start, len)); _handleSpillOverflow(bix, newB); } else { _buckets[bix] = newB;
int index = _hashToIndex(h); String sym = _symbols[index]; return sym; sym = _findSymbol2(buffer, start, len, b.next); if (sym != null) { return sym; return _addSymbol(buffer, start, len, h, index);
_sizeThreshold = _thresholdSize(newSize); if (symbol != null) { ++count; int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol; ++count; String symbol = b.symbol; int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol;
int index = _hashToIndex(h); String sym = _symbols[index]; copyArrays(); _dirty = true; } else if (_size >= _sizeThreshold) { // Need to expand? rehash(); index = _hashToIndex(calcHash(buffer, start, len)); _longestCollisionList = Math.max(newB.length(), _longestCollisionList); if (_longestCollisionList > MAX_COLL_CHAIN_LENGTH) { reportTooManyCollisions(MAX_COLL_CHAIN_LENGTH);
copyArrays(); _dirty = true; } else if (_size >= _sizeThreshold) { // Need to expand? rehash(); hash = calcHash(buffer, start, len) & _indexMask;
protected static CharsToNameCanonicalizer createRoot(int seed) { return new CharsToNameCanonicalizer(seed); } /**
private String _addSymbol(char[] buffer, int start, int len, int h, int index) copyArrays(); _hashShared = false; } else if (_size >= _sizeThreshold) { // Need to expand? rehash(); index = _hashToIndex(calcHash(buffer, start, len)); _handleSpillOverflow(bix, newB); } else { _buckets[bix] = newB;
_sizeThreshold = _thresholdSize(newSize); if (symbol != null) { ++count; int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol; ++count; String symbol = b.symbol; int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol;
/** * Method called by the using code to indicate it is done with this instance. * This lets instance merge accumulated changes into parent (if need be), * safely and efficiently, and without calling code having to know about parent * information. */ public void release() { // If nothing has been added, nothing to do if (!maybeDirty()) { return; } // we will try to merge if child table has new entries if (_parent != null && _canonicalize) { // canonicalize set to false if max size was reached _parent.mergeChild(new TableInfo(this)); // Let's also mark this instance as dirty, so that just in // case release was too early, there's no corruption of possibly shared data. _hashShared = true; } }
int index = _hashToIndex(h); String sym = _symbols[index]; return sym; sym = _findSymbol2(buffer, start, len, b.next); if (sym != null) { return sym; return _addSymbol(buffer, start, len, h, index);
protected static CharsToNameCanonicalizer createRoot(int seed) { return new CharsToNameCanonicalizer(seed); } /**
private String _addSymbol(char[] buffer, int start, int len, int h, int index) copyArrays(); _dirty = true; } else if (_size >= _sizeThreshold) { // Need to expand? rehash(); index = _hashToIndex(calcHash(buffer, start, len)); _handleSpillOverflow(bix, newB); } else { _buckets[bix] = newB;
_sizeThreshold = _thresholdSize(newSize); if (symbol != null) { ++count; int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol; ++count; String symbol = b.symbol; int index = _hashToIndex(calcHash(symbol)); if (_symbols[index] == null) { _symbols[index] = symbol;
/** * Overridable factory method that actually instantiates parser * using given {@link Reader} object for reading content. *<p> * This method is specifically designed to remain * compatible between minor versions so that sub-classes can count * on it being called as expected. That is, it is part of official * interface from sub-class perspective, although not a public * method available to users of factory implementations. * * @since 2.1 */ protected JsonParser _createParser(Reader r, IOContext ctxt) throws IOException { return new ReaderBasedJsonParser(ctxt, _parserFeatures, r, _objectCodec, _rootCharSymbols.makeChild(_factoryFeatures)); }
public void release(){ // If nothing has been added, nothing to do if (!maybeDirty()) { return; } if (_parent != null && _canonicalize) { // canonicalize set to false if max size was reached _parent.mergeChild(this); /* Let's also mark this instance as dirty, so that just in * case release was too early, there's no corruption * of possibly shared data. */ _dirty = false; } }