CORBA-JAVA
view release on metacpan or search on metacpan
javaxml/XMLInputStreamImpl.java view on Meta::CPAN
hash = 31 * hash + ch [i];
hash = (hash & 0x7fffffff) % SYMBOL_TABLE_LENGTH;
// Get the bucket -- consists of {array,String} pairs
if ((bucket = symbolTable [hash]) == null) {
// first string in this bucket
bucket = new Object [8];
// Search for a matching tuple, and
// return the string if we find one.
} else {
while (index < bucket.length) {
char chFound [] = (char []) bucket [index];
// Stop when we hit a null index.
if (chFound == null)
break;
// If they're the same length, check for a match.
if (chFound.length == length) {
for (int i = 0; i < chFound.length; i++) {
// continue search on failure
if (ch [start + i] != chFound [i]) {
break;
} else if (i == length - 1) {
// That's it, we have a match!
return (String) bucket [index + 1];
}
}
}
index += 2;
}
// Not found -- we'll have to add it.
// Do we have to grow the bucket?
bucket = (Object []) extendArray (bucket, bucket.length, index);
}
symbolTable [hash] = bucket;
// OK, add it to the end of the bucket -- "local" interning.
// Intern "globally" to let applications share interning benefits.
String s = new String (ch, start, length).intern ();
bucket [index] = s.toCharArray ();
bucket [index + 1] = s;
return s;
}
/**
* Ensure the capacity of an array, allocating a new one if
* necessary. Usually called only a handful of times.
*/
private Object extendArray (Object array, int currentSize, int requiredSize)
{
if (requiredSize < currentSize) {
return array;
} else {
Object newArray = null;
int newSize = currentSize * 2;
if (newSize <= requiredSize)
newSize = requiredSize + 1;
if (array instanceof char[])
newArray = new char [newSize];
else if (array instanceof Object[])
newArray = new Object [newSize];
else
throw new RuntimeException ();
System.arraycopy (array, 0, newArray, 0, currentSize);
return newArray;
}
}
//////////////////////////////////////////////////////////////////////
// XML query routines.
//////////////////////////////////////////////////////////////////////
//
// Entities
//
/**
* Find the type of an entity.
* @returns An integer constant representing the entity type.
* @see #ENTITY_UNDECLARED
* @see #ENTITY_INTERNAL
* @see #ENTITY_NDATA
* @see #ENTITY_TEXT
*/
public int getEntityType (String ename)
{
Object entity[] = entityInfo.get (ename);
if (entity == null) {
return ENTITY_UNDECLARED;
} else {
return ((Integer) entity [0]).intValue ();
}
}
/**
* Return the value of an internal entity.
* @param ename The name of the internal entity.
* @return The entity's value, or null if the entity was
* not declared, or if it is not an internal entity.
* @see #getEntityType
*/
public String getEntityValue (String ename)
{
Object entity[] = entityInfo.get (ename);
if (entity == null) {
return null;
} else {
return (String) entity [3];
}
}
( run in 1.747 second using v1.01-cache-2.11-cpan-39bf76dae61 )