Package org.flexdock.util
Class TypedHashtable
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable
-
- org.flexdock.util.TypedHashtable
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map
- Direct Known Subclasses:
BasicDockablePropertySet,BasicDockingPortPropertySet
public class TypedHashtable extends java.util.Hashtable- Author:
- Christopher Butler
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TypedHashtable()Constructs 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.TypedHashtable(java.util.Map t)Constructs a newTypedHashtablewith the same mappings as the given Map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanget(java.lang.Object key, boolean defaultValue)Returns the boolean value associated with the specifiedkeyin this hashtable.byteget(java.lang.Object key, byte defaultValue)Returns the byte value associated with the specifiedkeyin this hashtable.charget(java.lang.Object key, char defaultValue)Returns the char value associated with the specifiedkeyin this hashtable.doubleget(java.lang.Object key, double defaultValue)Returns the double value associated with the specifiedkeyin this hashtable.floatget(java.lang.Object key, float defaultValue)Returns the float value associated with the specifiedkeyin this hashtable.intget(java.lang.Object key, int defaultValue)Returns the int value associated with the specifiedkeyin this hashtable.longget(java.lang.Object key, long defaultValue)Returns the long value associated with the specifiedkeyin this hashtable.shortget(java.lang.Object key, short defaultValue)Returns the short value associated with the specifiedkeyin this hashtable.java.lang.BooleangetBoolean(java.lang.Object key)Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Booleanbefore returning.java.lang.BytegetByte(java.lang.Object key)Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Bytebefore returning.java.lang.CharactergetChar(java.lang.Object key)Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Characterbefore returning.java.lang.DoublegetDouble(java.lang.Object key)Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Doublebefore returning.java.lang.FloatgetFloat(java.lang.Object key)Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Floatbefore returning.java.lang.IntegergetInt(java.lang.Object key)Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Integerbefore returning.java.lang.LonggetLong(java.lang.Object key)Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Longbefore returning.java.lang.ShortgetShort(java.lang.Object key)Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Shortbefore returning.java.lang.StringgetString(java.lang.Object key)Retrieves the value to which the specified key is mapped in this hashtable and casts to ajava.lang.Stringbefore returning.voidput(java.lang.Object key, boolean value)Maps the specifiedkeyto the specified booleanvaluein this hashtable.voidput(java.lang.Object key, byte value)Maps the specifiedkeyto the specified bytevaluein this hashtable.voidput(java.lang.Object key, char value)Maps the specifiedkeyto the specified charvaluein this hashtable.voidput(java.lang.Object key, double value)Maps the specifiedkeyto the specified doublevaluein this hashtable.voidput(java.lang.Object key, float value)Maps the specifiedkeyto the specified floatvaluein this hashtable.voidput(java.lang.Object key, int value)Maps the specifiedkeyto the specified intvaluein this hashtable.voidput(java.lang.Object key, long value)Maps the specifiedkeyto the specified longvaluein this hashtable.voidput(java.lang.Object key, short value)Maps the specifiedkeyto the specified shortvaluein this hashtable.java.lang.Objectput(java.lang.Object key, java.lang.Object value)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 Detail
-
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:
java.lang.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:
java.lang.IllegalArgumentException- if the initial capacity is less than zero, or if the load factor is nonpositive.
-
TypedHashtable
public TypedHashtable(java.util.Map t)
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:
java.lang.NullPointerException- if the specified map is null.
-
-
Method Detail
-
put
public void put(java.lang.Object key, boolean value)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:
Boolean.TRUE,Boolean.FALSE,put(Object, Object)
-
put
public void put(java.lang.Object key, byte value)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:
Byte(byte),put(Object, Object)
-
put
public void put(java.lang.Object key, short value)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:
Short(short),put(Object, Object)
-
put
public void put(java.lang.Object key, int value)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:
Integer(int),put(Object, Object)
-
put
public void put(java.lang.Object key, long value)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:
Long(long),put(Object, Object)
-
put
public void put(java.lang.Object key, float value)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:
Float(float),put(Object, Object)
-
put
public void put(java.lang.Object key, double value)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:
Double(double),put(Object, Object)
-
put
public void put(java.lang.Object key, char value)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:
Character(char),put(Object, Object)
-
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value)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.- Specified by:
putin interfacejava.util.Map- Overrides:
putin classjava.util.Hashtable- Parameters:
key- the hashtable key.value- the value.- See Also:
Object.equals(Object),Hashtable.get(Object),Hashtable.remove(java.lang.Object)
-
get
public boolean get(java.lang.Object key, boolean defaultValue)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:
put(Object, boolean),getBoolean(Object),Boolean.booleanValue()
-
get
public byte get(java.lang.Object key, byte defaultValue)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:
put(Object, byte),getByte(Object),Byte.byteValue()
-
get
public short get(java.lang.Object key, short defaultValue)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:
put(Object, short),getShort(Object),Short.shortValue()
-
get
public int get(java.lang.Object key, int defaultValue)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:
put(Object, int),getInt(Object),Integer.intValue()
-
get
public long get(java.lang.Object key, long defaultValue)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:
put(Object, long),getLong(Object),Long.longValue()
-
get
public float get(java.lang.Object key, float defaultValue)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:
put(Object, float),getFloat(Object),Float.floatValue()
-
get
public double get(java.lang.Object key, double defaultValue)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:
put(Object, double),getDouble(Object),Double.doubleValue()
-
get
public char get(java.lang.Object key, char defaultValue)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:
put(Object, char),getChar(Object),Character.charValue()
-
getString
public java.lang.String getString(java.lang.Object key)
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:
java.lang.NullPointerException- if the key isnull.java.lang.ClassCastException- if the returns value is not aString- See Also:
put(Object, Object)
-
getBoolean
public java.lang.Boolean getBoolean(java.lang.Object key)
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:
java.lang.NullPointerException- if the key isnull.java.lang.ClassCastException- if the returns value is not aBoolean- See Also:
put(Object, Object)
-
getByte
public java.lang.Byte getByte(java.lang.Object key)
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:
java.lang.NullPointerException- if the key isnull.java.lang.ClassCastException- if the returns value is not aByte- See Also:
put(Object, Object)
-
getShort
public java.lang.Short getShort(java.lang.Object key)
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:
java.lang.NullPointerException- if the key isnull.java.lang.ClassCastException- if the returns value is not aShort- See Also:
put(Object, Object)
-
getInt
public java.lang.Integer getInt(java.lang.Object key)
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:
java.lang.NullPointerException- if the key isnull.java.lang.ClassCastException- if the returns value is not aInteger- See Also:
put(Object, Object)
-
getLong
public java.lang.Long getLong(java.lang.Object key)
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:
java.lang.NullPointerException- if the key isnull.java.lang.ClassCastException- if the returns value is not aLong- See Also:
put(Object, Object)
-
getFloat
public java.lang.Float getFloat(java.lang.Object key)
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:
java.lang.NullPointerException- if the key isnull.java.lang.ClassCastException- if the returns value is not aFloat- See Also:
put(Object, Object)
-
getDouble
public java.lang.Double getDouble(java.lang.Object key)
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:
java.lang.NullPointerException- if the key isnull.java.lang.ClassCastException- if the returns value is not aDouble- See Also:
put(Object, Object)
-
getChar
public java.lang.Character getChar(java.lang.Object key)
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:
java.lang.NullPointerException- if the key isnull.java.lang.ClassCastException- if the returns value is not aCharacter- See Also:
put(Object, Object)
-
-