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, emptyTypedHashtablewith a default initial capacity (11) and load factor of0.75.TypedHashtable(int initialCapacity) Constructs a new, emptyTypedHashtablewith the specified initial capacity and default load factor of0.75.TypedHashtable(int initialCapacity, float loadFactor) Constructs a new, emptyTypedHashtablewith the specified initial capacity and the specified load factor.Constructs a newTypedHashtablewith the same mappings as the given Map. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the boolean value associated with the specifiedkeyin this hashtable.byteReturns the byte value associated with the specifiedkeyin this hashtable.charReturns the char value associated with the specifiedkeyin this hashtable.doubleReturns the double value associated with the specifiedkeyin this hashtable.floatReturns the float value associated with the specifiedkeyin this hashtable.intReturns the int value associated with the specifiedkeyin this hashtable.longReturns the long value associated with the specifiedkeyin this hashtable.shortReturns the short value associated with the specifiedkeyin this hashtable.getBoolean(Object key) Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Booleanbefore returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Bytebefore returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Characterbefore returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Doublebefore returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Floatbefore returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Integerbefore returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Longbefore returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Shortbefore returning.Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Stringbefore returning.voidMaps the specifiedkeyto the specified booleanvaluein this hashtable.voidMaps the specifiedkeyto the specified bytevaluein this hashtable.voidMaps the specifiedkeyto the specified charvaluein this hashtable.voidMaps the specifiedkeyto the specified doublevaluein this hashtable.voidMaps the specifiedkeyto the specified floatvaluein this hashtable.voidMaps the specifiedkeyto the specified intvaluein this hashtable.voidMaps the specifiedkeyto the specified longvaluein this hashtable.voidMaps the specifiedkeyto the specified shortvaluein this hashtable.Maps the specifiedkeyto the specifiedvaluein 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, emptyTypedHashtablewith a default initial capacity (11) and load factor of0.75. -
TypedHashtable
public TypedHashtable(int initialCapacity) Constructs a new, emptyTypedHashtablewith 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, emptyTypedHashtablewith 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 newTypedHashtablewith 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 specifiedkeyto the specified booleanvaluein this hashtable. Since hashtables requireObjectvalues, this method will put eitherBoolean.TRUEorBoolean.FALSEin the hashtable. Ifkeyisnullthen 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 specifiedkeyto the specified bytevaluein this hashtable. Since hashtables requireObjectvalues, this method will wrap the specified byte in ajava.lang.Bytebefore inserting. Ifkeyisnullthen 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 specifiedkeyto the specified shortvaluein this hashtable. Since hashtables requireObjectvalues, this method will wrap the specified short in ajava.lang.Shortbefore inserting. Ifkeyisnullthen 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 specifiedkeyto the specified intvaluein this hashtable. Since hashtables requireObjectvalues, this method will wrap the specified int in ajava.lang.Integerbefore inserting. Ifkeyisnullthen 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 specifiedkeyto the specified longvaluein this hashtable. Since hashtables requireObjectvalues, this method will wrap the specified long in ajava.lang.Longbefore inserting. Ifkeyisnullthen 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 specifiedkeyto the specified floatvaluein this hashtable. Since hashtables requireObjectvalues, this method will wrap the specified float in ajava.lang.Floatbefore inserting. Ifkeyisnullthen 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 specifiedkeyto the specified doublevaluein this hashtable. Since hashtables requireObjectvalues, this method will wrap the specified double in ajava.lang.Doublebefore inserting. Ifkeyisnullthen 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 specifiedkeyto the specified charvaluein this hashtable. Since hashtables requireObjectvalues, this method will wrap the specified char in ajava.lang.Characterbefore inserting. Ifkeyisnullthen 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 specifiedkeyto the specifiedvaluein this hashtable. If thekeyisnull, then this method returns with no action taken. If thevalueisnull, then this method removes any existing mapping in the hashtable for the specifiedkeyby 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 specifiedkeyin this hashtable. This method attempts to cast the value in this hashtable for the specifiedkeyto ajava.lang.Booleanand invoke itsbooleanValue()method. If the key does not exist in the hashtable, or it maps to a non-Booleanvalue, 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
keyin this hashtable. - See Also:
-
get
Returns the byte value associated with the specifiedkeyin this hashtable. This method attempts to cast the value in this hashtable for the specifiedkeyto ajava.lang.Byteand invoke itsbyteValue()method. If the key does not exist in the hashtable, or it maps to a non-Bytevalue, 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
keyin this hashtable. - See Also:
-
get
Returns the short value associated with the specifiedkeyin this hashtable. This method attempts to cast the value in this hashtable for the specifiedkeyto ajava.lang.Shortand invoke itsshortValue()method. If the key does not exist in the hashtable, or it maps to a non-Shortvalue, 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
keyin this hashtable. - See Also:
-
get
Returns the int value associated with the specifiedkeyin this hashtable. This method attempts to cast the value in this hashtable for the specifiedkeyto ajava.lang.Integerand invoke itsintValue()method. If the key does not exist in the hashtable, or it maps to a non-Integervalue, 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
keyin this hashtable. - See Also:
-
get
Returns the long value associated with the specifiedkeyin this hashtable. This method attempts to cast the value in this hashtable for the specifiedkeyto ajava.lang.Longand invoke itslongValue()method. If the key does not exist in the hashtable, or it maps to a non-Longvalue, 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
keyin this hashtable. - See Also:
-
get
Returns the float value associated with the specifiedkeyin this hashtable. This method attempts to cast the value in this hashtable for the specifiedkeyto ajava.lang.Floatand invoke itsfloatValue()method. If the key does not exist in the hashtable, or it maps to a non-Floatvalue, 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
keyin this hashtable. - See Also:
-
get
Returns the double value associated with the specifiedkeyin this hashtable. This method attempts to cast the value in this hashtable for the specifiedkeyto ajava.lang.Doubleand invoke itsdoubleValue()method. If the key does not exist in the hashtable, or it maps to a non-Doublevalue, 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
keyin this hashtable. - See Also:
-
get
Returns the char value associated with the specifiedkeyin this hashtable. This method attempts to cast the value in this hashtable for the specifiedkeyto ajava.lang.Characterand invoke itscharValue()method. If the key does not exist in the hashtable, or it maps to a non-Charactervalue, 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
keyin this hashtable. - See Also:
-
getString
Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Stringbefore returning. If the specifiedkeymaps to an object type other than aStringvalue, then this method throws aClassCastException.- Parameters:
key- a key in the hashtable.- Returns:
- the
Stringvalue to which the key is mapped in this hashtable;nullif 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.Booleanbefore returning. If the specifiedkeymaps to an object type other than aBooleanvalue, then this method throws aClassCastException.- Parameters:
key- a key in the hashtable.- Returns:
- the
Booleanvalue to which the key is mapped in this hashtable;nullif 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.Bytebefore returning. If the specifiedkeymaps to an object type other than aBytevalue, then this method throws aClassCastException.- Parameters:
key- a key in the hashtable.- Returns:
- the
Bytevalue to which the key is mapped in this hashtable;nullif 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.Shortbefore returning. If the specifiedkeymaps to an object type other than aShortvalue, then this method throws aClassCastException.- Parameters:
key- a key in the hashtable.- Returns:
- the
Shortvalue to which the key is mapped in this hashtable;nullif 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.Integerbefore returning. If the specifiedkeymaps to an object type other than aIntegervalue, then this method throws aClassCastException.- Parameters:
key- a key in the hashtable.- Returns:
- the
Integervalue to which the key is mapped in this hashtable;nullif 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.Longbefore returning. If the specifiedkeymaps to an object type other than aLongvalue, then this method throws aClassCastException.- Parameters:
key- a key in the hashtable.- Returns:
- the
Longvalue to which the key is mapped in this hashtable;nullif 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.Floatbefore returning. If the specifiedkeymaps to an object type other than aFloatvalue, then this method throws aClassCastException.- Parameters:
key- a key in the hashtable.- Returns:
- the
Floatvalue to which the key is mapped in this hashtable;nullif 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.Doublebefore returning. If the specifiedkeymaps to an object type other than aDoublevalue, then this method throws aClassCastException.- Parameters:
key- a key in the hashtable.- Returns:
- the
Doublevalue to which the key is mapped in this hashtable;nullif 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.Characterbefore returning. If the specifiedkeymaps to an object type other than aCharactervalue, then this method throws aClassCastException.- Parameters:
key- a key in the hashtable.- Returns:
- the
Charactervalue to which the key is mapped in this hashtable;nullif 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:
-