public class Dict
extends java.lang.Object
Constructor and Description |
---|
Dict()
Creates a new empty dictionary.
|
Dict(int initialCapacity)
Creates a new empty dictionary.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
add(java.lang.String key,
java.lang.Object value)
Adds a dictionary value using the specified key if possible.
|
void |
addAll(Dict dict)
Adds all key-value pairs from another dictionary to this one.
|
java.lang.String |
addBoolean(java.lang.String key,
boolean value)
Adds a boolean property value using the specified key if
possible.
|
java.lang.String |
addInt(java.lang.String key,
int value)
Adds an integer property value using the specified key if
possible.
|
boolean |
containsKey(java.lang.String key)
Checks if the specified key is defined in this dictionary.
|
boolean |
containsValue(java.lang.Object value)
Checks if the specified value is contained in this dictionary.
|
Dict |
copy()
Creates a copy of this dictionary.
|
java.lang.Object |
get(java.lang.String key)
Returns the dictionary value for the specified key.
|
java.lang.Object |
get(java.lang.String key,
java.lang.Object defaultValue)
Returns the dictionary value for the specified key.
|
Array |
getArray(java.lang.String key)
Returns the dictionary array value for the specified key.
|
boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Returns the dictionary boolean value for the specified key.
|
java.util.Date |
getDate(java.lang.String key,
java.util.Date defaultValue)
Returns the dictionary date value for the specified key.
|
Dict |
getDict(java.lang.String key)
Returns the dictionary dictionary value for the specified key.
|
int |
getInt(java.lang.String key,
int defaultValue)
Returns the dictionary integer value for the specified key.
|
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Returns the dictionary string value for the specified key.
|
java.lang.String |
keyOf(java.lang.Object value)
Returns the first dictionary key having the specified value.
|
java.lang.String[] |
keys()
Returns an array with all the defined dictionary key names.
|
void |
remove(java.lang.String key)
Deletes the specified dictionary key and its value.
|
void |
seal(boolean recursive)
Seals this dictionary and prohibits further modifications.
|
void |
set(java.lang.String key,
java.lang.Object value)
Modifies or defines the dictionary value for the specified key.
|
void |
setAll(Dict dict)
Modifies or defines all keys from another dictionary.
|
void |
setBoolean(java.lang.String key,
boolean value)
Modifies or defines the boolean dictionary value for the
specified key.
|
void |
setInt(java.lang.String key,
int value)
Modifies or defines the integer dictionary value for the
specified key.
|
int |
size()
Returns the size of the dictionary, i.e.
|
java.lang.String |
toString()
Returns a string representation of this object.
|
public Dict()
public Dict(int initialCapacity)
initialCapacity
- the initial dictionary capacitypublic java.lang.String toString()
toString
in class java.lang.Object
public Dict copy()
public void seal(boolean recursive)
recursive
- the recursive flagpublic int size()
public boolean containsKey(java.lang.String key)
key
- the key namepublic boolean containsValue(java.lang.Object value)
value
- the value to check forpublic java.lang.String keyOf(java.lang.Object value)
value
- the value to check forpublic java.lang.String[] keys()
public java.lang.Object get(java.lang.String key)
key
- the dictionary key namepublic java.lang.Object get(java.lang.String key, java.lang.Object defaultValue)
key
- the dictionary key namedefaultValue
- the default valuepublic java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
key
- the dictionary key namedefaultValue
- the default valuepublic boolean getBoolean(java.lang.String key, boolean defaultValue)
key
- the dictionary key namedefaultValue
- the default valuepublic int getInt(java.lang.String key, int defaultValue) throws java.lang.NumberFormatException
key
- the dictionary key namedefaultValue
- the default valuejava.lang.NumberFormatException
- if the value didn't contain a
valid integerpublic java.util.Date getDate(java.lang.String key, java.util.Date defaultValue) throws java.lang.NumberFormatException
key
- the dictionary key namedefaultValue
- the default valuejava.lang.NumberFormatException
- if the value didn't contain a
valid date, number or numeric stringpublic Dict getDict(java.lang.String key) throws java.lang.ClassCastException
key
- the dictionary key namejava.lang.ClassCastException
- if the value is not a dictionarypublic Array getArray(java.lang.String key) throws java.lang.ClassCastException
key
- the dictionary key namejava.lang.ClassCastException
- if the value is not an arraypublic void set(java.lang.String key, java.lang.Object value) throws java.lang.NullPointerException, java.lang.UnsupportedOperationException
key
- the dictionary key namevalue
- the value to setjava.lang.NullPointerException
- if the key is null or an empty
stringjava.lang.UnsupportedOperationException
- if this object has been
sealedpublic void setBoolean(java.lang.String key, boolean value) throws java.lang.NullPointerException, java.lang.UnsupportedOperationException
key
- the dictionary key namevalue
- the value to setjava.lang.NullPointerException
- if the key is null or an empty
stringjava.lang.UnsupportedOperationException
- if this object has been
sealedpublic void setInt(java.lang.String key, int value) throws java.lang.NullPointerException, java.lang.UnsupportedOperationException
key
- the dictionary key namevalue
- the value to setjava.lang.NullPointerException
- if the key is null or an empty
stringjava.lang.UnsupportedOperationException
- if this object has been
sealedpublic void setAll(Dict dict)
dict
- the dictionary to copy fromjava.lang.UnsupportedOperationException
- if this object has been
sealedpublic java.lang.String add(java.lang.String key, java.lang.Object value) throws java.lang.UnsupportedOperationException
key
- the suggested dictionary key namevalue
- the value to setjava.lang.UnsupportedOperationException
- if this object has been
sealedpublic java.lang.String addBoolean(java.lang.String key, boolean value) throws java.lang.UnsupportedOperationException
key
- the suggested dictionary key namevalue
- the value to setjava.lang.UnsupportedOperationException
- if this object has been
sealedpublic java.lang.String addInt(java.lang.String key, int value) throws java.lang.UnsupportedOperationException
key
- the suggested dictionary key namevalue
- the value to setjava.lang.UnsupportedOperationException
- if this object has been
sealedpublic void addAll(Dict dict)
dict
- the dictionary to add fromjava.lang.UnsupportedOperationException
- if this object has been
sealedpublic void remove(java.lang.String key) throws java.lang.UnsupportedOperationException
key
- the dictionary key namejava.lang.UnsupportedOperationException
- if this object has been
sealed