public final class WNameTable extends NameTable
WName
s.Modifier and Type | Class and Description |
---|---|
(package private) static class |
WNameTable.Bucket |
Modifier and Type | Field and Description |
---|---|
(package private) static int |
INITIAL_COLLISION_LEN |
(package private) static int |
LAST_VALID_BUCKET
Bucket index is 8 bits, and value 0 is reserved to represent
'empty' status.
|
private int |
mCollCount
Total number of WNames in collision buckets (included in
mCount along with primary entries) |
private int |
mCollEnd
Index of the first unused collision bucket entry (== size of
the used portion of collision list): less than
or equal to 0xFF (255), since max number of entries is 255
(8-bit, minus 0 used as 'empty' marker)
|
private WNameTable.Bucket[] |
mCollList
Array of heads of collision bucket chains; size dynamically
|
private boolean |
mCollListShared
Flag that indicates whether underlying data structures for
the collision list are shared or not.
|
private int |
mCount
Total number of WNames in the symbol table
|
(package private) static int |
MIN_HASH_SIZE |
private int[] |
mMainHash
Array of 2^N size, which contains combination
of 24-bits of hash (0 to indicate 'empty' slot),
and 8-bit collision bucket index (0 to indicate empty
collision bucket chain; otherwise subtract one from index)
|
private int |
mMainHashMask
Mask used to truncate 32-bit hash value to current hash array
size; essentially, hash array size - 1 (since hash array sizes
are 2^N).
|
private boolean |
mMainHashShared
Flag that indicates whether underlying data structures for
the main hash area are shared or not.
|
private WName[] |
mMainNames
Array that contains
WName instances matching
entries in mMainHash . |
private boolean |
mMainNamesShared |
(package private) WNameFactory |
mNameFactory |
private boolean |
mNeedRehash
This flag is set if, after adding a new entry, it is deemed
that a rehash is warranted if any more entries are to be added.
|
(package private) WNameTable |
mParent
Parent reference is needed to be able to merge new symbols
if and as necessary
|
Modifier | Constructor and Description |
---|---|
protected |
WNameTable(int hashSize) |
private |
WNameTable(WNameTable parent,
WNameFactory f)
Constructor used when creating a child instance
|
Modifier and Type | Method and Description |
---|---|
private void |
addSymbol(WName symbol) |
protected WNameTable |
createChild(WNameFactory f) |
private void |
expandCollision() |
private int |
findBestBucket()
Method called to find the best bucket to spill a WName over to:
usually the first bucket that has only one entry, but in general
first one of the buckets with least number of entries
|
WName |
findSymbol(java.lang.String localName) |
WName |
findSymbol(java.lang.String prefix,
java.lang.String localName)
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.
|
void |
markAsShared() |
boolean |
maybeDirty()
Method called to check to quickly see if a child symbol table
may have gotten additional entries.
|
private boolean |
mergeFromChild(WNameTable child) |
boolean |
mergeToParent() |
void |
nuke()
Method used by test code, to reset state of the name table.
|
private void |
rehash() |
int |
size() |
java.lang.String |
toDebugString() |
java.lang.String |
toString() |
private void |
unshareCollision() |
private void |
unshareMain()
Method that needs to be called, if the main hash structure
is (may be) shared.
|
private void |
unshareNames() |
static final int MIN_HASH_SIZE
static final int INITIAL_COLLISION_LEN
static final int LAST_VALID_BUCKET
final WNameFactory mNameFactory
final WNameTable mParent
private int mCount
private int mMainHashMask
private int[] mMainHash
private WName[] mMainNames
WName
instances matching
entries in mMainHash
. Contains nulls for unused
entries.private WNameTable.Bucket[] mCollList
private int mCollCount
mCount
along with primary entries)private int mCollEnd
private transient boolean mNeedRehash
private boolean mMainHashShared
This flag needs to be checked both when adding new main entries, and when adding new collision list queues (i.e. creating a new collision list head entry)
private boolean mMainNamesShared
private boolean mCollListShared
This flag needs to be checked when adding new collision entries.
protected WNameTable(int hashSize)
private WNameTable(WNameTable parent, WNameFactory f)
protected WNameTable createChild(WNameFactory f)
public boolean mergeToParent()
private boolean mergeFromChild(WNameTable child)
public void markAsShared()
public void nuke()
public boolean maybeDirty()
maybeDirty
in class NameTable
public WName findSymbol(java.lang.String localName) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public WName findSymbol(java.lang.String prefix, java.lang.String localName) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toDebugString()
private void addSymbol(WName symbol)
private void rehash()
private int findBestBucket()
private void unshareMain()
private void unshareCollision()
private void unshareNames()
private void expandCollision()