public final class ElementIdMap extends Object
ElementId
instances. ElementId
instances
represent both id definitions (values of element attributes that
have type ID in DTD), and references (values of element attributes
of type IDREF and IDREFS). These definitions and references are
stored for the purpose of verifying
that all referenced id values are defined, and that none are defined
more than once.
Note: there are 2 somewhat distinct usage modes, by DTDValidator and by MSV-based validators. DTDs pass raw character arrays, whereas MSV-based validators operate on Strings. This is the main reason for 2 distinct sets of methods.
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_SIZE
Default initial table size; set so that usually it need not
be expanded.
|
protected static int |
FILL_PCT
Let's use 80% fill factor...
|
protected ElementId |
mHead |
protected static int |
MIN_SIZE |
protected int |
mIndexMask
Mask used to get index from hash values; equal to
mBuckets.length - 1 , when mBuckets.length is
a power of two. |
protected int |
mSize
Current size (number of entries); needed to know if and when
rehash.
|
protected int |
mSizeThreshold
Limit that indicates maximum size this instance can hold before
it needs to be expanded and rehashed.
|
protected ElementId[] |
mTable
Actual hash table area
|
protected ElementId |
mTail |
Constructor and Description |
---|
ElementIdMap() |
ElementIdMap(int initialSize)
This constructor is mainly used for testing, as it can be sized
appropriately to test rehashing etc.
|
Modifier and Type | Method and Description |
---|---|
ElementId |
addDefined(char[] buffer,
int start,
int len,
int hash,
Location loc,
PrefixedName elemName,
PrefixedName attrName)
Method called when an id definition is encountered.
|
ElementId |
addDefined(String idStr,
Location loc,
PrefixedName elemName,
PrefixedName attrName) |
ElementId |
addReferenced(char[] buffer,
int start,
int len,
int hash,
Location loc,
PrefixedName elemName,
PrefixedName attrName)
Method called when a reference to id is encountered.
|
ElementId |
addReferenced(String idStr,
Location loc,
PrefixedName elemName,
PrefixedName attrName) |
static int |
calcHash(char[] buffer,
int start,
int len)
Implementation of a hashing method for variable length
Strings.
|
static int |
calcHash(String key) |
ElementId |
getFirstUndefined() |
protected static final int DEFAULT_SIZE
protected static final int MIN_SIZE
protected static final int FILL_PCT
protected ElementId[] mTable
protected int mSize
protected int mSizeThreshold
protected int mIndexMask
mBuckets.length - 1
, when mBuckets.length is
a power of two.protected ElementId mHead
protected ElementId mTail
public ElementIdMap()
public ElementIdMap(int initialSize)
public ElementId getFirstUndefined()
public ElementId addReferenced(char[] buffer, int start, int len, int hash, Location loc, PrefixedName elemName, PrefixedName attrName)
public ElementId addReferenced(String idStr, Location loc, PrefixedName elemName, PrefixedName attrName)
public ElementId addDefined(char[] buffer, int start, int len, int hash, Location loc, PrefixedName elemName, PrefixedName attrName)
public ElementId addDefined(String idStr, Location loc, PrefixedName elemName, PrefixedName attrName)
public static int calcHash(char[] buffer, int start, int len)
Note: identical to SymbolTable.calcHash(char[], int, int)
,
although not required to be.
len
- Length of String; has to be at least 1 (caller guarantees
this pre-condition)public static int calcHash(String key)
Copyright © 2018 FasterXML. All rights reserved.