/** * Method returns an index of the passed character buffer in * <code>CharArrayIntMap</code>. * * @return index of character buffer in <code>CharArrayIntMap</code>, * otherwise NOT_PRESENT. */ public final int get(char[] ch, int start, int length) { final int hash = hashHash(CharArray.hashCode(ch, start, length)); return get(ch, start, length, hash); }
/** * Checks whether character content table has enough memory to * store character content chunk with the given length * * @param length the length of character content chunk is checking to be added to Map. * @param map the custom CharArrayIntMap, which memory limits will be checked. * @return whether character content map has enough memory */ public boolean canAddCharacterContentToTable(int length, CharArrayIntMap map) { return map.getTotalCharacterCount() + length < characterContentChunkMapTotalCharactersConstraint; }
private final int get(char[] ch, int start, int length, int hash) { if (_readOnlyMap != null) { final int i = _readOnlyMap.get(ch, start, length, hash); if (i != -1) { return i; } } final int tableIndex = indexFor(hash, _table.length); for (Entry e = _table[tableIndex]; e != null; e = e._next) { if (e._hash == hash && e.equalsCharArray(ch, start, length)) { return e._value; } } return NOT_PRESENT; }
_v.characterContentChunk.obtainIndex(ch, offset, length, true) : _v.characterContentChunk.get(ch, offset, length);
final int hash = hashHash(CharArray.hashCode(ch, start, length)); final int index = _readOnlyMap.get(ch, start, length, hash); if (index != -1) { return index; final int tableIndex = indexFor(hash, _table.length); for (Entry e = _table[tableIndex]; e != null; e = e._next) { if (e._hash == hash && e.equalsCharArray(ch, start, length)) { addEntry(ch, start, length, hash, _size + _readOnlyMapSize, tableIndex); return NOT_PRESENT;
private void addToTable(String s, CharArrayIntMap m) { if (s.length() == 0) { return; } char[] c = s.toCharArray(); m.obtainIndex(c, 0, c.length, false); }
public final void setReadOnlyMap(KeyIntMap readOnlyMap, boolean clear) { if (!(readOnlyMap instanceof CharArrayIntMap)) { throw new IllegalArgumentException(CommonResourceBundle.getInstance(). getString("message.illegalClass", new Object[]{readOnlyMap})); } setReadOnlyMap((CharArrayIntMap)readOnlyMap, clear); }
private final void addEntry(char[] ch, int start, int length, int hash, int value, int bucketIndex) { Entry e = _table[bucketIndex]; _table[bucketIndex] = new Entry(ch, start, length, hash, value, e); _totalCharacterCount += length; if (_size++ >= _threshold) { resize(2 * _table.length); } }
public SerializerVocabulary() { tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4); tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4); tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8); tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8); tables[LOCAL_NAME] = localName = new StringIntMap(); tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4); tables[OTHER_URI] = otherURI = new StringIntMap(4); tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap(); tables[OTHER_STRING] = otherString = new CharArrayIntMap(4); tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap(); tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap(); tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap(); }
private final void transfer(Entry[] newTable) { Entry[] src = _table; int newCapacity = newTable.length; for (int j = 0; j < src.length; j++) { Entry e = src[j]; if (e != null) { src[j] = null; do { Entry next = e._next; int i = indexFor(e._hash, newCapacity); e._next = newTable[i]; newTable[i] = e; e = next; } while (e != null); } } } }
_v.characterContentChunk.obtainIndex(ch, offset, length, true) : _v.characterContentChunk.get(ch, offset, length);
final int hash = hashHash(CharArray.hashCode(ch, start, length)); final int index = _readOnlyMap.get(ch, start, length, hash); if (index != -1) { return index; final int tableIndex = indexFor(hash, _table.length); for (Entry e = _table[tableIndex]; e != null; e = e._next) { if (e._hash == hash && e.equalsCharArray(ch, start, length)) { addEntry(ch, start, length, hash, _size + _readOnlyMapSize, tableIndex); return NOT_PRESENT;
private final int get(char[] ch, int start, int length, int hash) { if (_readOnlyMap != null) { final int i = _readOnlyMap.get(ch, start, length, hash); if (i != -1) { return i; } } final int tableIndex = indexFor(hash, _table.length); for (Entry e = _table[tableIndex]; e != null; e = e._next) { if (e._hash == hash && e.equalsCharArray(ch, start, length)) { return e._value; } } return NOT_PRESENT; }
private void addToTable(String s, CharArrayIntMap m) { if (s.length() == 0) { return; } char[] c = s.toCharArray(); m.obtainIndex(c, 0, c.length, false); }
public final void setReadOnlyMap(KeyIntMap readOnlyMap, boolean clear) { if (!(readOnlyMap instanceof CharArrayIntMap)) { throw new IllegalArgumentException(CommonResourceBundle.getInstance(). getString("message.illegalClass", new Object[]{readOnlyMap})); } setReadOnlyMap((CharArrayIntMap)readOnlyMap, clear); }
private final void addEntry(char[] ch, int start, int length, int hash, int value, int bucketIndex) { Entry e = _table[bucketIndex]; _table[bucketIndex] = new Entry(ch, start, length, hash, value, e); _totalCharacterCount += length; if (_size++ >= _threshold) { resize(2 * _table.length); } }
public SerializerVocabulary() { tables[RESTRICTED_ALPHABET] = restrictedAlphabet = new StringIntMap(4); tables[ENCODING_ALGORITHM] = encodingAlgorithm = new StringIntMap(4); tables[PREFIX] = prefix = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_PREFIX, 8); tables[NAMESPACE_NAME] = namespaceName = new FixedEntryStringIntMap(EncodingConstants.XML_NAMESPACE_NAME, 8); tables[LOCAL_NAME] = localName = new StringIntMap(); tables[OTHER_NCNAME] = otherNCName = new StringIntMap(4); tables[OTHER_URI] = otherURI = new StringIntMap(4); tables[ATTRIBUTE_VALUE] = attributeValue = new StringIntMap(); tables[OTHER_STRING] = otherString = new CharArrayIntMap(4); tables[CHARACTER_CONTENT_CHUNK] = characterContentChunk = new CharArrayIntMap(); tables[ELEMENT_NAME] = elementName = new LocalNameQualifiedNamesMap(); tables[ATTRIBUTE_NAME] = attributeName = new LocalNameQualifiedNamesMap(); }
private final void transfer(Entry[] newTable) { Entry[] src = _table; int newCapacity = newTable.length; for (int j = 0; j < src.length; j++) { Entry e = src[j]; if (e != null) { src[j] = null; do { Entry next = e._next; int i = indexFor(e._hash, newCapacity); e._next = newTable[i]; newTable[i] = e; e = next; } while (e != null); } } } }
_v.characterContentChunk.obtainIndex(ch, offset, length, true) : _v.characterContentChunk.get(ch, offset, length);