org.flexdock.util
public class TypedHashtable extends Hashtable
Constructor and Description |
---|
TypedHashtable()
Constructs a new, empty
TypedHashtable with a default initial capacity (11)
and load factor of 0.75 . |
TypedHashtable(int initialCapacity)
Constructs a new, empty
TypedHashtable with the specified initial capacity
and default load factor of 0.75 . |
TypedHashtable(int initialCapacity,
float loadFactor)
Constructs a new, empty
TypedHashtable with the specified initial
capacity and the specified load factor. |
TypedHashtable(Map t)
Constructs a new
TypedHashtable with the same mappings as the given
Map. |
Modifier and Type | Method and Description |
---|---|
boolean |
get(Object key,
boolean defaultValue)
Returns the boolean value associated with the specified
key in this hashtable. |
byte |
get(Object key,
byte defaultValue)
Returns the byte value associated with the specified
key in this hashtable. |
char |
get(Object key,
char defaultValue)
Returns the char value associated with the specified
key in this hashtable. |
double |
get(Object key,
double defaultValue)
Returns the double value associated with the specified
key in this hashtable. |
float |
get(Object key,
float defaultValue)
Returns the float value associated with the specified
key in this hashtable. |
int |
get(Object key,
int defaultValue)
Returns the int value associated with the specified
key in this hashtable. |
long |
get(Object key,
long defaultValue)
Returns the long value associated with the specified
key in this hashtable. |
short |
get(Object key,
short defaultValue)
Returns the short value associated with the specified
key in this hashtable. |
Boolean |
getBoolean(Object key)
Retrieves the value to which the specified key is mapped in this hashtable and casts to a
java.lang.Boolean before returning. |
Byte |
getByte(Object key)
Retrieves the value to which the specified key is mapped in this hashtable and casts to a
java.lang.Byte before returning. |
Character |
getChar(Object key)
Retrieves the value to which the specified key is mapped in this hashtable and casts to a
java.lang.Character before returning. |
Double |
getDouble(Object key)
Retrieves the value to which the specified key is mapped in this hashtable and casts to a
java.lang.Double before returning. |
Float |
getFloat(Object key)
Retrieves the value to which the specified key is mapped in this hashtable and casts to a
java.lang.Float before returning. |
Integer |
getInt(Object key)
Retrieves the value to which the specified key is mapped in this hashtable and casts to a
java.lang.Integer before returning. |
Long |
getLong(Object key)
Retrieves the value to which the specified key is mapped in this hashtable and casts to a
java.lang.Long before returning. |
Short |
getShort(Object key)
Retrieves the value to which the specified key is mapped in this hashtable and casts to a
java.lang.Short before returning. |
String |
getString(Object key)
Retrieves the value to which the specified key is mapped in this hashtable and casts to a
java.lang.String before returning. |
void |
put(Object key,
boolean value)
Maps the specified
key to the specified boolean value in this
hashtable. |
void |
put(Object key,
byte value)
Maps the specified
key to the specified byte value in this
hashtable. |
void |
put(Object key,
char value)
Maps the specified
key to the specified char value in this
hashtable. |
void |
put(Object key,
double value)
Maps the specified
key to the specified double value in this
hashtable. |
void |
put(Object key,
float value)
Maps the specified
key to the specified float value in this
hashtable. |
void |
put(Object key,
int value)
Maps the specified
key to the specified int value in this
hashtable. |
void |
put(Object key,
long value)
Maps the specified
key to the specified long value in this
hashtable. |
Object |
put(Object key,
Object value)
Maps the specified
key to the specified
value in this hashtable. |
void |
put(Object key,
short value)
Maps the specified
key to the specified short value in this
hashtable. |
public TypedHashtable()
TypedHashtable
with a default initial capacity (11)
and load factor of 0.75
.public TypedHashtable(int initialCapacity)
TypedHashtable
with the specified initial capacity
and default load factor of 0.75
.initialCapacity
- the initial capacity of the hashtable.IllegalArgumentException
- if the initial capacity is less
than zero.public TypedHashtable(int initialCapacity, float loadFactor)
TypedHashtable
with the specified initial
capacity and the specified load factor.initialCapacity
- the initial capacity of the hashtable.loadFactor
- the load factor of the hashtable.IllegalArgumentException
- if the initial capacity is less
than zero, or if the load factor is nonpositive.public TypedHashtable(Map t)
TypedHashtable
with the same mappings as the given
Map. The hashtable is created with an initial capacity sufficient to
hold the mappings in the given Map and a default load factor of 0.75
.t
- the map whose mappings are to be placed in this map.NullPointerException
- if the specified map is null.public void put(Object key, boolean value)
key
to the specified boolean value
in this
hashtable. Since hashtables require Object
values, this method will put either
Boolean.TRUE
or Boolean.FALSE
in the hashtable. If key
is
null
then this method returns with no action taken.key
- the hashtable key.value
- the boolean value to be mapped to the specified key
.Boolean.TRUE
,
Boolean.FALSE
,
put(Object, Object)
public void put(Object key, byte value)
key
to the specified byte value
in this
hashtable. Since hashtables require Object
values, this method will wrap the
specified byte in a java.lang.Byte
before inserting. If key
is
null
then this method returns with no action taken.key
- the hashtable key.value
- the byte value to be mapped to the specified key
.Byte.Byte(byte)
,
put(Object, Object)
public void put(Object key, short value)
key
to the specified short value
in this
hashtable. Since hashtables require Object
values, this method will wrap the
specified short in a java.lang.Short
before inserting. If key
is
null
then this method returns with no action taken.key
- the hashtable key.value
- the short value to be mapped to the specified key
.Short.Short(short)
,
put(Object, Object)
public void put(Object key, int value)
key
to the specified int value
in this
hashtable. Since hashtables require Object
values, this method will wrap the
specified int in a java.lang.Integer
before inserting. If key
is
null
then this method returns with no action taken.key
- the hashtable key.value
- the int value to be mapped to the specified key
.Integer.Integer(int)
,
put(Object, Object)
public void put(Object key, long value)
key
to the specified long value
in this
hashtable. Since hashtables require Object
values, this method will wrap the
specified long in a java.lang.Long
before inserting. If key
is
null
then this method returns with no action taken.key
- the hashtable key.value
- the long value to be mapped to the specified key
.Long.Long(long)
,
put(Object, Object)
public void put(Object key, float value)
key
to the specified float value
in this
hashtable. Since hashtables require Object
values, this method will wrap the
specified float in a java.lang.Float
before inserting. If key
is
null
then this method returns with no action taken.key
- the hashtable key.value
- the float value to be mapped to the specified key
.Float.Float(float)
,
put(Object, Object)
public void put(Object key, double value)
key
to the specified double value
in this
hashtable. Since hashtables require Object
values, this method will wrap the
specified double in a java.lang.Double
before inserting. If key
is
null
then this method returns with no action taken.key
- the hashtable key.value
- the double value to be mapped to the specified key
.Double.Double(double)
,
put(Object, Object)
public void put(Object key, char value)
key
to the specified char value
in this
hashtable. Since hashtables require Object
values, this method will wrap the
specified char in a java.lang.Character
before inserting. If key
is
null
then this method returns with no action taken.key
- the hashtable key.value
- the char value to be mapped to the specified key
.Character.Character(char)
,
put(Object, Object)
public Object put(Object key, Object value)
key
to the specified
value
in this hashtable. If the key
is null
, then this
method returns with no action taken. If the value
is null
, then
this method removes any existing mapping in the hashtable for the specified key
by calling remove(Object key)
.
The value can be retrieved by calling the get(Object key)
method
with a key that is equal to the original key.put
in interface Map
put
in class Hashtable
key
- the hashtable key.value
- the value.Object.equals(Object)
,
Hashtable.get(Object)
,
Hashtable.remove(java.lang.Object)
public boolean get(Object key, boolean defaultValue)
key
in this hashtable.
This method attempts to cast the value in this hashtable for the specified key
to
a java.lang.Boolean
and invoke its booleanValue()
method.
If the key does not exist in the hashtable, or it maps to a non-Boolean
value,
then this method returns the specified defaultValue
.key
- the hashtable keydefaultValue
- the value to return if a valid boolean cannot be found for the specified keykey
in this hashtable.put(Object, boolean)
,
getBoolean(Object)
,
Boolean.booleanValue()
public byte get(Object key, byte defaultValue)
key
in this hashtable.
This method attempts to cast the value in this hashtable for the specified key
to
a java.lang.Byte
and invoke its byteValue()
method.
If the key does not exist in the hashtable, or it maps to a non-Byte
value,
then this method returns the specified defaultValue
.key
- the hashtable keydefaultValue
- the value to return if a valid byte cannot be found for the specified keykey
in this hashtable.put(Object, byte)
,
getByte(Object)
,
Byte.byteValue()
public short get(Object key, short defaultValue)
key
in this hashtable.
This method attempts to cast the value in this hashtable for the specified key
to
a java.lang.Short
and invoke its shortValue()
method.
If the key does not exist in the hashtable, or it maps to a non-Short
value,
then this method returns the specified defaultValue
.key
- the hashtable keydefaultValue
- the value to return if a valid short cannot be found for the specified keykey
in this hashtable.put(Object, short)
,
getShort(Object)
,
Short.shortValue()
public int get(Object key, int defaultValue)
key
in this hashtable.
This method attempts to cast the value in this hashtable for the specified key
to
a java.lang.Integer
and invoke its intValue()
method.
If the key does not exist in the hashtable, or it maps to a non-Integer
value,
then this method returns the specified defaultValue
.key
- the hashtable keydefaultValue
- the value to return if a valid int cannot be found for the specified keykey
in this hashtable.put(Object, int)
,
getInt(Object)
,
Integer.intValue()
public long get(Object key, long defaultValue)
key
in this hashtable.
This method attempts to cast the value in this hashtable for the specified key
to
a java.lang.Long
and invoke its longValue()
method.
If the key does not exist in the hashtable, or it maps to a non-Long
value,
then this method returns the specified defaultValue
.key
- the hashtable keydefaultValue
- the value to return if a valid long cannot be found for the specified keykey
in this hashtable.put(Object, long)
,
getLong(Object)
,
Long.longValue()
public float get(Object key, float defaultValue)
key
in this hashtable.
This method attempts to cast the value in this hashtable for the specified key
to
a java.lang.Float
and invoke its floatValue()
method.
If the key does not exist in the hashtable, or it maps to a non-Float
value,
then this method returns the specified defaultValue
.key
- the hashtable keydefaultValue
- the value to return if a valid float cannot be found for the specified keykey
in this hashtable.put(Object, float)
,
getFloat(Object)
,
Float.floatValue()
public double get(Object key, double defaultValue)
key
in this hashtable.
This method attempts to cast the value in this hashtable for the specified key
to
a java.lang.Double
and invoke its doubleValue()
method.
If the key does not exist in the hashtable, or it maps to a non-Double
value,
then this method returns the specified defaultValue
.key
- the hashtable keydefaultValue
- the value to return if a valid double cannot be found for the specified keykey
in this hashtable.put(Object, double)
,
getDouble(Object)
,
Double.doubleValue()
public char get(Object key, char defaultValue)
key
in this hashtable.
This method attempts to cast the value in this hashtable for the specified key
to
a java.lang.Character
and invoke its charValue()
method.
If the key does not exist in the hashtable, or it maps to a non-Character
value,
then this method returns the specified defaultValue
.key
- the hashtable keydefaultValue
- the value to return if a valid char cannot be found for the specified keykey
in this hashtable.put(Object, char)
,
getChar(Object)
,
Character.charValue()
public String getString(Object key)
java.lang.String
before returning. If the specified key
maps to an
object type other than a String
value, then this method throws a
ClassCastException
.key
- a key in the hashtable.String
value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in this hashtable.NullPointerException
- if the key is null
.ClassCastException
- if the returns value is not a String
put(Object, Object)
public Boolean getBoolean(Object key)
java.lang.Boolean
before returning. If the specified key
maps to an
object type other than a Boolean
value, then this method throws a
ClassCastException
.key
- a key in the hashtable.Boolean
value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in this hashtable.NullPointerException
- if the key is null
.ClassCastException
- if the returns value is not a Boolean
put(Object, Object)
public Byte getByte(Object key)
java.lang.Byte
before returning. If the specified key
maps to an
object type other than a Byte
value, then this method throws a
ClassCastException
.key
- a key in the hashtable.Byte
value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in this hashtable.NullPointerException
- if the key is null
.ClassCastException
- if the returns value is not a Byte
put(Object, Object)
public Short getShort(Object key)
java.lang.Short
before returning. If the specified key
maps to an
object type other than a Short
value, then this method throws a
ClassCastException
.key
- a key in the hashtable.Short
value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in this hashtable.NullPointerException
- if the key is null
.ClassCastException
- if the returns value is not a Short
put(Object, Object)
public Integer getInt(Object key)
java.lang.Integer
before returning. If the specified key
maps to an
object type other than a Integer
value, then this method throws a
ClassCastException
.key
- a key in the hashtable.Integer
value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in this hashtable.NullPointerException
- if the key is null
.ClassCastException
- if the returns value is not a Integer
put(Object, Object)
public Long getLong(Object key)
java.lang.Long
before returning. If the specified key
maps to an
object type other than a Long
value, then this method throws a
ClassCastException
.key
- a key in the hashtable.Long
value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in this hashtable.NullPointerException
- if the key is null
.ClassCastException
- if the returns value is not a Long
put(Object, Object)
public Float getFloat(Object key)
java.lang.Float
before returning. If the specified key
maps to an
object type other than a Float
value, then this method throws a
ClassCastException
.key
- a key in the hashtable.Float
value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in this hashtable.NullPointerException
- if the key is null
.ClassCastException
- if the returns value is not a Float
put(Object, Object)
public Double getDouble(Object key)
java.lang.Double
before returning. If the specified key
maps to an
object type other than a Double
value, then this method throws a
ClassCastException
.key
- a key in the hashtable.Double
value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in this hashtable.NullPointerException
- if the key is null
.ClassCastException
- if the returns value is not a Double
put(Object, Object)
public Character getChar(Object key)
java.lang.Character
before returning. If the specified key
maps to an
object type other than a Character
value, then this method throws a
ClassCastException
.key
- a key in the hashtable.Character
value to which the key is mapped in this hashtable;
null
if the key is not mapped to any value in this hashtable.NullPointerException
- if the key is null
.ClassCastException
- if the returns value is not a Character
put(Object, Object)