Package com.fasterxml.aalto.in
Class ByteBasedPNameTable
- java.lang.Object
-
- com.fasterxml.aalto.util.NameTable
-
- com.fasterxml.aalto.in.ByteBasedPNameTable
-
public final class ByteBasedPNameTable extends NameTable
This is a symbol table implementation used for storing byte-basedPNames, specifically, instances of (ByteBasedPName).
-
-
Constructor Summary
Constructors Constructor Description ByteBasedPNameTable(int hashSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBasedPNameaddSymbol(int hash, java.lang.String symbolStr, int colonIx, int[] quads, int qlen)ByteBasedPNameaddSymbol(int hash, java.lang.String symbolStr, int colonIx, int firstQuad, int secondQuad)static intcalcHash(int firstQuad)static intcalcHash(int[] quads, int qlen)static intcalcHash(int firstQuad, int secondQuad)static int[]calcQuads(byte[] wordBytes)ByteBasedPNamefindSymbol(int hash, int[] quads, int qlen)Finds and returns name matching the specified symbol, if such name already exists in the table; or if not, creates name object, adds to the table, and returns it.ByteBasedPNamefindSymbol(int hash, int firstQuad, int secondQuad)Finds and returns name matching the specified symbol, if such name already exists in the table; or if not, creates name object, adds to the table, and returns it.voidmarkAsShared()booleanmaybeDirty()Method called to check to quickly see if a child symbol table may have gotten additional entries.booleanmergeFromChild(ByteBasedPNameTable child)voidnuke()Method used by test code, to reset state of the name table.intsize()java.lang.StringtoString()
-
-
-
Method Detail
-
mergeFromChild
public boolean mergeFromChild(ByteBasedPNameTable child)
-
markAsShared
public void markAsShared()
-
nuke
public void nuke()
Method used by test code, to reset state of the name table.
-
maybeDirty
public boolean maybeDirty()
Method called to check to quickly see if a child symbol table may have gotten additional entries. Used for checking to see if a child table should be merged into shared table.- Specified by:
maybeDirtyin classNameTable
-
findSymbol
public ByteBasedPName findSymbol(int hash, int firstQuad, int secondQuad)
Finds and returns name matching the specified symbol, if such name already exists in the table; or if not, creates name object, adds to the table, and returns it.Note: separate methods to optimize common case of relatively short element/attribute names (8 or less ascii characters)
- Parameters:
firstQuad- int32 containing first 4 bytes of the pname; if the whole name less than 4 bytes, padded with zero bytes in front (zero MSBs, ie. right aligned)secondQuad- int32 containing bytes 5 through 8 of the pname; if less than 8 bytes, padded with up to 4 zero bytes in front (zero MSBs, ie. right aligned)- Returns:
- PName matching the symbol passed (or constructed for it)
-
findSymbol
public ByteBasedPName findSymbol(int hash, int[] quads, int qlen)
Finds and returns name matching the specified symbol, if such name already exists in the table; or if not, creates name object, adds to the table, and returns it.Note: this is the general purpose method that can be called for names of any length. However, if name is less than 9 bytes long, it is preferable to call the version optimized for short names.
- Parameters:
quads- Array of int32s, each of which contain 4 bytes of encoded nameqlen- Number of int32s, starting from index 0, in quads parameter- Returns:
- PName matching the symbol passed (or constructed for it)
-
addSymbol
public ByteBasedPName addSymbol(int hash, java.lang.String symbolStr, int colonIx, int firstQuad, int secondQuad)
-
addSymbol
public ByteBasedPName addSymbol(int hash, java.lang.String symbolStr, int colonIx, int[] quads, int qlen)
-
calcHash
public static final int calcHash(int firstQuad)
-
calcHash
public static final int calcHash(int firstQuad, int secondQuad)
-
calcHash
public static final int calcHash(int[] quads, int qlen)
-
calcQuads
public static int[] calcQuads(byte[] wordBytes)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-