| Method from org.apache.jasper.xmlparser.SymbolTable Detail: |
public String addSymbol(String symbol) {
// search for identical symbol
int bucket = hash(symbol) % fTableSize;
int length = symbol.length();
OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
for (int i = 0; i < length; i++) {
if (symbol.charAt(i) != entry.characters[i]) {
continue OUTER;
}
}
return entry.symbol;
}
}
// create new entry
Entry entry = new Entry(symbol, fBuckets[bucket]);
fBuckets[bucket] = entry;
return entry.symbol;
}
Adds the specified symbol to the symbol table and returns a
reference to the unique symbol. If the symbol already exists,
the previous symbol reference is returned instead, in order
guarantee that symbol references remain unique. |
public String addSymbol(char[] buffer,
int offset,
int length) {
// search for identical symbol
int bucket = hash(buffer, offset, length) % fTableSize;
OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
for (int i = 0; i < length; i++) {
if (buffer[offset + i] != entry.characters[i]) {
continue OUTER;
}
}
return entry.symbol;
}
}
// add new entry
Entry entry = new Entry(buffer, offset, length, fBuckets[bucket]);
fBuckets[bucket] = entry;
return entry.symbol;
}
Adds the specified symbol to the symbol table and returns a
reference to the unique symbol. If the symbol already exists,
the previous symbol reference is returned instead, in order
guarantee that symbol references remain unique. |
public boolean containsSymbol(String symbol) {
// search for identical symbol
int bucket = hash(symbol) % fTableSize;
int length = symbol.length();
OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
for (int i = 0; i < length; i++) {
if (symbol.charAt(i) != entry.characters[i]) {
continue OUTER;
}
}
return true;
}
}
return false;
}
Returns true if the symbol table already contains the specified
symbol. |
public boolean containsSymbol(char[] buffer,
int offset,
int length) {
// search for identical symbol
int bucket = hash(buffer, offset, length) % fTableSize;
OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
for (int i = 0; i < length; i++) {
if (buffer[offset + i] != entry.characters[i]) {
continue OUTER;
}
}
return true;
}
}
return false;
}
Returns true if the symbol table already contains the specified
symbol. |
public int hash(String symbol) {
int code = 0;
int length = symbol.length();
for (int i = 0; i < length; i++) {
code = code * 37 + symbol.charAt(i);
}
return code & 0x7FFFFFF;
}
Returns a hashcode value for the specified symbol. The value
returned by this method must be identical to the value returned
by the hash(char[],int,int) method when called
with the character array that comprises the symbol string. |
public int hash(char[] buffer,
int offset,
int length) {
int code = 0;
for (int i = 0; i < length; i++) {
code = code * 37 + buffer[offset + i];
}
return code & 0x7FFFFFF;
}
Returns a hashcode value for the specified symbol information.
The value returned by this method must be identical to the value
returned by the hash(String) method when called
with the string object created from the symbol information. |