Top Description Inners Fields Constructors Methods
com.sun.msv.scanner.dtd

pack-priv final Class SimpleHashtable

extends Object
implements Enumeration<Object>
Class Inheritance
All Implemented Interfaces
java.util.Enumeration
Imports
java.util.Enumeration

This class implements a special purpose hashtable. It works like a normal java.util.Hashtable except that:
  1. Keys to "get" are strings which are known to be interned, so that "==" is used instead of "String.equals". (Interning could be document-relative instead of global.)
  2. It's not synchronized, since it's to be used only by one thread at a time.
  3. The keys () enumerator allocates no memory, with live updates to the data disallowed.
  4. It's got fewer bells and whistles: fixed threshold and load factor, no JDK 1.2 collection support, only keys can be enumerated, things can't be removed, simpler inheritance; more.

The overall result is that it's less expensive to use these in performance-critical locations, in terms both of CPU and memory, than java.util.Hashtable instances. In this package it makes a significant difference when normalizing attributes, which is done for each start-element construct.

Version
$Revision: 1793 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SimpleHashtable.Entry

Hashtable collision list.

Field Summary

Modifier and TypeField and Description
private int
private SimpleHashtable.Entry
private int
private static final float
private SimpleHashtable.Entry[]
private int

Constructor Summary

AccessConstructor and Description
public
SimpleHashtable(int
the initial capacity of the hashtable.
initialCapacity
)

Constructs a new, empty hashtable with the specified initial capacity.

public
SimpleHashtable()

Constructs a new, empty hashtable with a default capacity.

Method Summary

Modifier and TypeMethod and Description
public void
public Object
get(String key)

Returns the value to which the specified key is mapped in this hashtable.

public Object
getNonInterned(String key)

Returns the value to which the specified key is mapped in this hashtable ...

public boolean
hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Used to view this as an enumeration; returns true if there are more keys to be enumerated.
public Enumeration<Object>

Returns:

an enumeration of the keys in this hashtable.
keys
()

Returns an enumeration of the keys in this hashtable.

public Object
nextElement()

Implements java.util.Enumeration.nextElement.

Used to view this as an enumeration; returns the next key in the enumeration.
public Object
put(Object key, Object value)

Maps the specified key to the specified value in this hashtable.

private void
rehash()

Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.

public int

Returns:

the number of keys in this hashtable.
size
()

Returns the number of keys in this hashtable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

countback to summary
private int count
currentback to summary
private SimpleHashtable.Entry current
currentBucketback to summary
private int currentBucket
loadFactorback to summary
private static final float loadFactor
tableback to summary
private SimpleHashtable.Entry[] table
thresholdback to summary
private int threshold

Constructor Detail

SimpleHashtableback to summary
public SimpleHashtable(int initialCapacity)

Constructs a new, empty hashtable with the specified initial capacity.

Parameters
initialCapacity:int

the initial capacity of the hashtable.

SimpleHashtableback to summary
public SimpleHashtable()

Constructs a new, empty hashtable with a default capacity.

Method Detail

clearback to summary
public void clear()
getback to summary
public Object get(String key)

Returns the value to which the specified key is mapped in this hashtable.

getNonInternedback to summary
public Object getNonInterned(String key)

Returns the value to which the specified key is mapped in this hashtable ... the key isn't necessarily interned, though.

hasMoreElementsback to summary
public boolean hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Used to view this as an enumeration; returns true if there are more keys to be enumerated.

Returns:boolean

Doc from java.util.Enumeration.hasMoreElements.

true if and only if this enumeration object contains at least one more element to provide; false otherwise.

keysback to summary
public Enumeration<Object> keys()

Returns an enumeration of the keys in this hashtable.

Returns:Enumeration<Object>

an enumeration of the keys in this hashtable.

See Also
Enumeration
nextElementback to summary
public Object nextElement()

Implements java.util.Enumeration.nextElement.

Used to view this as an enumeration; returns the next key in the enumeration.

Returns:Object

Doc from java.util.Enumeration.nextElement.

the next element of this enumeration.

putback to summary
public Object put(Object key, Object value)

Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

rehashback to summary
private void rehash()

Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently. This method is called automatically when the number of keys in the hashtable exceeds this hashtable's capacity and load factor.

sizeback to summary
public int size()

Returns the number of keys in this hashtable.

Returns:int

the number of keys in this hashtable.

com.sun.msv.scanner.dtd back to summary

private Class SimpleHashtable.Entry

extends Object
Class Inheritance

Hashtable collision list.

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv Object
pack-priv SimpleHashtable.Entry
pack-priv Object

Constructor Summary

AccessConstructor and Description
protected
Entry(int hash, Object key, Object value, SimpleHashtable.Entry next)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hashback to summary
pack-priv int hash
keyback to summary
pack-priv Object key
nextback to summary
pack-priv SimpleHashtable.Entry next
valueback to summary
pack-priv Object value

Constructor Detail

Entryback to summary
protected Entry(int hash, Object key, Object value, SimpleHashtable.Entry next)