Package org.flexdock.util
Class TypedHashtable
java.lang.Object
java.util.Dictionary
java.util.Hashtable
org.flexdock.util.TypedHashtable
- All Implemented Interfaces:
Serializable
,Cloneable
,Map
- Direct Known Subclasses:
BasicDockablePropertySet
,BasicDockingPortPropertySet
- Author:
- Christopher Butler
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, emptyTypedHashtable
with a default initial capacity (11) and load factor of0.75
.TypedHashtable
(int initialCapacity) Constructs a new, emptyTypedHashtable
with the specified initial capacity and default load factor of0.75
.TypedHashtable
(int initialCapacity, float loadFactor) Constructs a new, emptyTypedHashtable
with the specified initial capacity and the specified load factor.Constructs a newTypedHashtable
with the same mappings as the given Map. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the boolean value associated with the specifiedkey
in this hashtable.byte
Returns the byte value associated with the specifiedkey
in this hashtable.char
Returns the char value associated with the specifiedkey
in this hashtable.double
Returns the double value associated with the specifiedkey
in this hashtable.float
Returns the float value associated with the specifiedkey
in this hashtable.int
Returns the int value associated with the specifiedkey
in this hashtable.long
Returns the long value associated with the specifiedkey
in this hashtable.short
Returns the short value associated with the specifiedkey
in this hashtable.getBoolean
(Object key) Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Boolean
before returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Byte
before returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Character
before returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Double
before returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Float
before returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Integer
before returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Long
before returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Short
before returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.String
before returning.void
Maps the specifiedkey
to the specified booleanvalue
in this hashtable.void
Maps the specifiedkey
to the specified bytevalue
in this hashtable.void
Maps the specifiedkey
to the specified charvalue
in this hashtable.void
Maps the specifiedkey
to the specified doublevalue
in this hashtable.void
Maps the specifiedkey
to the specified floatvalue
in this hashtable.void
Maps the specifiedkey
to the specified intvalue
in this hashtable.void
Maps the specifiedkey
to the specified longvalue
in this hashtable.void
Maps the specifiedkey
to the specified shortvalue
in this hashtable.Maps the specifiedkey
to the specifiedvalue
in this hashtable.Methods inherited from class java.util.Hashtable
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
-
Constructor Details
-
TypedHashtable
public TypedHashtable()Constructs a new, emptyTypedHashtable
with a default initial capacity (11) and load factor of0.75
. -
TypedHashtable
public TypedHashtable(int initialCapacity) Constructs a new, emptyTypedHashtable
with the specified initial capacity and default load factor of0.75
.- Parameters:
initialCapacity
- the initial capacity of the hashtable.- Throws:
IllegalArgumentException
- if the initial capacity is less than zero.
-
TypedHashtable
public TypedHashtable(int initialCapacity, float loadFactor) Constructs a new, emptyTypedHashtable
with the specified initial capacity and the specified load factor.- Parameters:
initialCapacity
- the initial capacity of the hashtable.loadFactor
- the load factor of the hashtable.- Throws:
IllegalArgumentException
- if the initial capacity is less than zero, or if the load factor is nonpositive.
-
TypedHashtable
Constructs a newTypedHashtable
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 of0.75
.- Parameters:
t
- the map whose mappings are to be placed in this map.- Throws:
NullPointerException
- if the specified map is null.
-
-
Method Details
-
put
Maps the specifiedkey
to the specified booleanvalue
in this hashtable. Since hashtables requireObject
values, this method will put eitherBoolean.TRUE
orBoolean.FALSE
in the hashtable. Ifkey
isnull
then this method returns with no action taken.- Parameters:
key
- the hashtable key.value
- the boolean value to be mapped to the specifiedkey
.- See Also:
-
put
Maps the specifiedkey
to the specified bytevalue
in this hashtable. Since hashtables requireObject
values, this method will wrap the specified byte in ajava.lang.Byte
before inserting. Ifkey
isnull
then this method returns with no action taken.- Parameters:
key
- the hashtable key.value
- the byte value to be mapped to the specifiedkey
.- See Also:
-
put
Maps the specifiedkey
to the specified shortvalue
in this hashtable. Since hashtables requireObject
values, this method will wrap the specified short in ajava.lang.Short
before inserting. Ifkey
isnull
then this method returns with no action taken.- Parameters:
key
- the hashtable key.value
- the short value to be mapped to the specifiedkey
.- See Also:
-
put
Maps the specifiedkey
to the specified intvalue
in this hashtable. Since hashtables requireObject
values, this method will wrap the specified int in ajava.lang.Integer
before inserting. Ifkey
isnull
then this method returns with no action taken.- Parameters:
key
- the hashtable key.value
- the int value to be mapped to the specifiedkey
.- See Also:
-
put
Maps the specifiedkey
to the specified longvalue
in this hashtable. Since hashtables requireObject
values, this method will wrap the specified long in ajava.lang.Long
before inserting. Ifkey
isnull
then this method returns with no action taken.- Parameters:
key
- the hashtable key.value
- the long value to be mapped to the specifiedkey
.- See Also:
-
put
Maps the specifiedkey
to the specified floatvalue
in this hashtable. Since hashtables requireObject
values, this method will wrap the specified float in ajava.lang.Float
before inserting. Ifkey
isnull
then this method returns with no action taken.- Parameters:
key
- the hashtable key.value
- the float value to be mapped to the specifiedkey
.- See Also:
-
put
Maps the specifiedkey
to the specified doublevalue
in this hashtable. Since hashtables requireObject
values, this method will wrap the specified double in ajava.lang.Double
before inserting. Ifkey
isnull
then this method returns with no action taken.- Parameters:
key
- the hashtable key.value
- the double value to be mapped to the specifiedkey
.- See Also:
-
put
Maps the specifiedkey
to the specified charvalue
in this hashtable. Since hashtables requireObject
values, this method will wrap the specified char in ajava.lang.Character
before inserting. Ifkey
isnull
then this method returns with no action taken.- Parameters:
key
- the hashtable key.value
- the char value to be mapped to the specifiedkey
.- See Also:
-
put
Maps the specifiedkey
to the specifiedvalue
in this hashtable. If thekey
isnull
, then this method returns with no action taken. If thevalue
isnull
, then this method removes any existing mapping in the hashtable for the specifiedkey
by callingremove(Object key)
. The value can be retrieved by calling theget(Object key)
method with a key that is equal to the original key. -
get
Returns the boolean value associated with the specifiedkey
in this hashtable. This method attempts to cast the value in this hashtable for the specifiedkey
to ajava.lang.Boolean
and invoke itsbooleanValue()
method. If the key does not exist in the hashtable, or it maps to a non-Boolean
value, then this method returns the specifieddefaultValue
.- Parameters:
key
- the hashtable keydefaultValue
- the value to return if a valid boolean cannot be found for the specified key- Returns:
- the boolean value associated with the specified
key
in this hashtable. - See Also:
-
get
Returns the byte value associated with the specifiedkey
in this hashtable. This method attempts to cast the value in this hashtable for the specifiedkey
to ajava.lang.Byte
and invoke itsbyteValue()
method. If the key does not exist in the hashtable, or it maps to a non-Byte
value, then this method returns the specifieddefaultValue
.- Parameters:
key
- the hashtable keydefaultValue
- the value to return if a valid byte cannot be found for the specified key- Returns:
- the byte value associated with the specified
key
in this hashtable. - See Also:
-
get
Returns the short value associated with the specifiedkey
in this hashtable. This method attempts to cast the value in this hashtable for the specifiedkey
to ajava.lang.Short
and invoke itsshortValue()
method. If the key does not exist in the hashtable, or it maps to a non-Short
value, then this method returns the specifieddefaultValue
.- Parameters:
key
- the hashtable keydefaultValue
- the value to return if a valid short cannot be found for the specified key- Returns:
- the short value associated with the specified
key
in this hashtable. - See Also:
-
get
Returns the int value associated with the specifiedkey
in this hashtable. This method attempts to cast the value in this hashtable for the specifiedkey
to ajava.lang.Integer
and invoke itsintValue()
method. If the key does not exist in the hashtable, or it maps to a non-Integer
value, then this method returns the specifieddefaultValue
.- Parameters:
key
- the hashtable keydefaultValue
- the value to return if a valid int cannot be found for the specified key- Returns:
- the int value associated with the specified
key
in this hashtable. - See Also:
-
get
Returns the long value associated with the specifiedkey
in this hashtable. This method attempts to cast the value in this hashtable for the specifiedkey
to ajava.lang.Long
and invoke itslongValue()
method. If the key does not exist in the hashtable, or it maps to a non-Long
value, then this method returns the specifieddefaultValue
.- Parameters:
key
- the hashtable keydefaultValue
- the value to return if a valid long cannot be found for the specified key- Returns:
- the long value associated with the specified
key
in this hashtable. - See Also:
-
get
Returns the float value associated with the specifiedkey
in this hashtable. This method attempts to cast the value in this hashtable for the specifiedkey
to ajava.lang.Float
and invoke itsfloatValue()
method. If the key does not exist in the hashtable, or it maps to a non-Float
value, then this method returns the specifieddefaultValue
.- Parameters:
key
- the hashtable keydefaultValue
- the value to return if a valid float cannot be found for the specified key- Returns:
- the float value associated with the specified
key
in this hashtable. - See Also:
-
get
Returns the double value associated with the specifiedkey
in this hashtable. This method attempts to cast the value in this hashtable for the specifiedkey
to ajava.lang.Double
and invoke itsdoubleValue()
method. If the key does not exist in the hashtable, or it maps to a non-Double
value, then this method returns the specifieddefaultValue
.- Parameters:
key
- the hashtable keydefaultValue
- the value to return if a valid double cannot be found for the specified key- Returns:
- the double value associated with the specified
key
in this hashtable. - See Also:
-
get
Returns the char value associated with the specifiedkey
in this hashtable. This method attempts to cast the value in this hashtable for the specifiedkey
to ajava.lang.Character
and invoke itscharValue()
method. If the key does not exist in the hashtable, or it maps to a non-Character
value, then this method returns the specifieddefaultValue
.- Parameters:
key
- the hashtable keydefaultValue
- the value to return if a valid char cannot be found for the specified key- Returns:
- the char value associated with the specified
key
in this hashtable. - See Also:
-
getString
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.String
before returning. If the specifiedkey
maps to an object type other than aString
value, then this method throws aClassCastException
.- Parameters:
key
- a key in the hashtable.- Returns:
- the
String
value to which the key is mapped in this hashtable;null
if the key is not mapped to any value in this hashtable. - Throws:
NullPointerException
- if the key isnull
.ClassCastException
- if the returns value is not aString
- See Also:
-
getBoolean
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Boolean
before returning. If the specifiedkey
maps to an object type other than aBoolean
value, then this method throws aClassCastException
.- Parameters:
key
- a key in the hashtable.- Returns:
- the
Boolean
value to which the key is mapped in this hashtable;null
if the key is not mapped to any value in this hashtable. - Throws:
NullPointerException
- if the key isnull
.ClassCastException
- if the returns value is not aBoolean
- See Also:
-
getByte
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Byte
before returning. If the specifiedkey
maps to an object type other than aByte
value, then this method throws aClassCastException
.- Parameters:
key
- a key in the hashtable.- Returns:
- the
Byte
value to which the key is mapped in this hashtable;null
if the key is not mapped to any value in this hashtable. - Throws:
NullPointerException
- if the key isnull
.ClassCastException
- if the returns value is not aByte
- See Also:
-
getShort
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Short
before returning. If the specifiedkey
maps to an object type other than aShort
value, then this method throws aClassCastException
.- Parameters:
key
- a key in the hashtable.- Returns:
- the
Short
value to which the key is mapped in this hashtable;null
if the key is not mapped to any value in this hashtable. - Throws:
NullPointerException
- if the key isnull
.ClassCastException
- if the returns value is not aShort
- See Also:
-
getInt
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Integer
before returning. If the specifiedkey
maps to an object type other than aInteger
value, then this method throws aClassCastException
.- Parameters:
key
- a key in the hashtable.- Returns:
- the
Integer
value to which the key is mapped in this hashtable;null
if the key is not mapped to any value in this hashtable. - Throws:
NullPointerException
- if the key isnull
.ClassCastException
- if the returns value is not aInteger
- See Also:
-
getLong
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Long
before returning. If the specifiedkey
maps to an object type other than aLong
value, then this method throws aClassCastException
.- Parameters:
key
- a key in the hashtable.- Returns:
- the
Long
value to which the key is mapped in this hashtable;null
if the key is not mapped to any value in this hashtable. - Throws:
NullPointerException
- if the key isnull
.ClassCastException
- if the returns value is not aLong
- See Also:
-
getFloat
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Float
before returning. If the specifiedkey
maps to an object type other than aFloat
value, then this method throws aClassCastException
.- Parameters:
key
- a key in the hashtable.- Returns:
- the
Float
value to which the key is mapped in this hashtable;null
if the key is not mapped to any value in this hashtable. - Throws:
NullPointerException
- if the key isnull
.ClassCastException
- if the returns value is not aFloat
- See Also:
-
getDouble
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Double
before returning. If the specifiedkey
maps to an object type other than aDouble
value, then this method throws aClassCastException
.- Parameters:
key
- a key in the hashtable.- Returns:
- the
Double
value to which the key is mapped in this hashtable;null
if the key is not mapped to any value in this hashtable. - Throws:
NullPointerException
- if the key isnull
.ClassCastException
- if the returns value is not aDouble
- See Also:
-
getChar
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Character
before returning. If the specifiedkey
maps to an object type other than aCharacter
value, then this method throws aClassCastException
.- Parameters:
key
- a key in the hashtable.- Returns:
- the
Character
value to which the key is mapped in this hashtable;null
if the key is not mapped to any value in this hashtable. - Throws:
NullPointerException
- if the key isnull
.ClassCastException
- if the returns value is not aCharacter
- See Also:
-