|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.collection.Dictionary
public class Dictionary
A Dictionary stores and retrieves values by a key.
This class is an implementation of com.sas.collection.DictionaryInterface
This class uses a Hashtable internally but provides
a more consistent interface as well as event notification of changes
to the dictionary.
| Field Summary | |
|---|---|
static java.lang.String |
RB_KEY
|
protected java.util.Hashtable |
table
|
| Fields inherited from class com.sas.collection.BaseCollection |
|---|
allContentsChangedListeners, mappingObject |
| Constructor Summary | |
|---|---|
Dictionary()
Default Constructor. |
|
Dictionary(int initialCapacity)
Constructs a new, empty Dictionary with the specified initial capacity and default load factor. |
|
Dictionary(int initialCapacity,
float loadFactor)
Constructs a new, empty Dictionary with the specified initial capacity and the specified load factor. |
|
Dictionary(java.lang.String data)
Constructs a new dictionary populated with elements parsed from a string. |
|
| Method Summary | |
|---|---|
void |
add(java.lang.Object item)
Add an item to this dictionary. |
void |
addItems(java.util.Enumeration items)
Add all elements of an enumeration to this dictionary. |
java.lang.Object |
clone()
Clone a Dictionary |
java.lang.Object |
clone(com.sas.DeepCloneSupport support,
boolean deeply)
Clone this object using a deep copy. |
boolean |
contains(java.lang.Object item)
Test the existence of an object in this dictionary. |
boolean |
containsKey(java.lang.Object key)
Test the existence of an key in a dictionary. |
int |
count()
Returns the number of key/value pairs in this dictionary. |
int |
count(java.lang.Object value)
Count the number of times the value exists in this dictionary. |
int |
countKey(java.lang.Object key)
Count the number of times the given key is used in this dictionary. |
void |
dumpComponent()
Prints the object. |
java.lang.Object |
get(java.lang.Object key)
Fetch the item corresponding to a key. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
|
java.util.Enumeration |
getItems()
Return an enumeration of all the items. |
java.lang.Object |
getKey(java.lang.Object item)
Get the key corrsponding to an item. |
java.util.Enumeration |
getKeys()
Return an Enumeration of all the keys in this dictionary. |
java.util.Enumeration |
getKeys(java.lang.Object item)
Return an Enumeration of all the keys for a given item. |
boolean |
remove(java.lang.Object item)
Remove an item from this dictionary. |
void |
removeAll()
Remove all items from this collection. |
int |
removeAll(java.lang.Object item)
Remove an item from this collection. |
void |
removeAt(java.lang.Object key)
Remove the item corresponding to the specified key. |
void |
set(java.lang.Object key,
java.lang.Object item)
Put an item into this dictionary, possibly replacing a previous item that was there by the same key. |
java.lang.String |
toString()
Convert this dictionary to a single string. |
java.lang.String |
toString(char delimiter,
char separator,
boolean alwaysQuote)
Convert this dictionary to a single string. |
| Methods inherited from class com.sas.collection.BaseCollection |
|---|
addContentsChangedListener, anyContentsChangedListeners, apply, disableEvents, enableEvents, enableEvents, fireContentsChanged, map, removeContentsChangedListener, unmap |
| Methods inherited from interface com.sas.collection.StaticCollectionInterface |
|---|
apply |
| Methods inherited from interface com.sas.collection.ContentsChangedSource |
|---|
addContentsChangedListener, removeContentsChangedListener |
| Methods inherited from interface com.sas.beans.PropertyChangeSource |
|---|
addPropertyChangeListener, removePropertyChangeListener |
| Field Detail |
|---|
public static final java.lang.String RB_KEY
protected java.util.Hashtable table
| Constructor Detail |
|---|
public Dictionary()
Hashtable
Hashtable
public Dictionary(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacity of the internal hashtable.loadFactor - a number between 0.0 and 1.0 which determines
how full this dictionary can get before the internal
structure is extended. The default is 0.75.
java.lang.IllegalArgumentException - if the initial capacity is less
than or equal to zero, or if the load factor is less than
or equal to zero.public Dictionary(int initialCapacity)
initialCapacity - the initial capacity of the hashtable.
java.lang.IllegalArgumentException - if the initial capacity is less
than or equal to zero.Dictionary(int, float)public Dictionary(java.lang.String data)
data - a string of key=value pairs, separated by commas.
Boolean and number objects are recognized and parsed into
appropriate Boolean, Integer, Long,
or Double objects (for either the key or the value);
everything else is parsed into a String
or Character.
For example, new AssociationList("A=1,two=2,3=true")
results in an dictionary with three values. The keys
are "A", "two", and the Integer 3,
and the corresponding values are the Integer 1, the
Integer 2, and Boolean.TRUE.
java.lang.IllegalArgumentException - if the data string
is invalidStringToDictionaryInterfaceTransform| Method Detail |
|---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void add(java.lang.Object item)
set(item, item), so as to minimize conflicts with preexisting items.
add in interface CollectionInterfaceitem - an object to add to this dictionarypublic void addItems(java.util.Enumeration items)
set(item, item) for each element of the enumeration.
addItems in interface CollectionInterfaceitems - an Enumeration of items to add to this dictionarypublic void removeAll()
removeAll in interface CollectionInterfacepublic boolean contains(java.lang.Object item)
contains in interface StaticCollectionInterfacecontains in class BaseCollectionitem - the item to search for.
StaticCollectionInterface.contains(java.lang.Object)public boolean containsKey(java.lang.Object key)
containsKey in interface StaticDictionaryInterfacekey - the key to search for
public int count()
count in interface com.sas.util.Countablecount in class BaseCollectionpublic int countKey(java.lang.Object key)
key - the key to count
Dictionary, this count is always 1 or 0.public int count(java.lang.Object value)
value - a value to count
public void dumpComponent()
dumpComponent in interface ComponentInterfacedumpComponent in class ComponentComponentInterface.dumpComponent()public java.lang.Object get(java.lang.Object key)
get in interface StaticDictionaryInterfacekey - the Object key with which the item was added to this dictionary.
com.sas.collection.Dictionary
may contains null values for either the
key or the value items, so you would not know if a
return value of null meant the
key does not exists or the key exists but is associated
with the null value.
java.util.NoSuchElementException - when there is no entry for
the specified key. (Note that null
is a valid value for a key.)public java.util.Enumeration getItems()
getItems in interface com.sas.util.EnumerablegetItems in class BaseCollectionEnumeration of the elements
stored in this dictionary (not the keys).Enumerable.getItems()public java.lang.Object getKey(java.lang.Object item)
getItems() or getKeys() enumerations).
getKey in interface StaticDictionaryInterfaceitem - the item whose key you wish to find.
java.util.NoSuchElementException - if the item does not exist in this dictionary.public java.util.Enumeration getKeys(java.lang.Object item)
Enumeration of all the keys for a given item.
The order is unspecified.
If the item does not exist, a zero length array
is returned.
getKeys in interface StaticDictionaryInterfaceitem - the item to search for
Enumeration of keys corresponding to the item.public java.util.Enumeration getKeys()
Enumeration of all the keys in this dictionary.
getKeys in interface StaticDictionaryInterfacepublic boolean remove(java.lang.Object item)
remove in interface CollectionInterfaceremove in interface DictionaryInterfaceitem - the item to remove
removeAll(Object)public int removeAll(java.lang.Object item)
removeAll in interface CollectionInterfaceitem - the item to remove
remove(Object)public void removeAt(java.lang.Object key)
removeAt in interface DictionaryInterfacekey - remove the key/value pair which corresponds to this key.
public void set(java.lang.Object key,
java.lang.Object item)
set in interface DictionaryInterfacekey - the key by which the item may be retrieved later.item - the value to put into this dictionary.
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface CollectionInterfaceclone in interface DictionaryInterfaceclone in interface StaticCollectionInterfaceclone in interface StaticDictionaryInterfaceclone in interface com.sas.PublicClonableclone in class BaseCollectionjava.lang.CloneNotSupportedException - if the clone fails.
public java.lang.Object clone(com.sas.DeepCloneSupport support,
boolean deeply)
throws java.lang.CloneNotSupportedException
DeepClonable
This object and all the objects it contains
are cloned, preserving the same structure.
clone in interface com.sas.DeepClonablesupport - a required object which keeps track
of cloned objects during the deep cloning.deeply - If true, clone recursively using the deep clone support.
if false, this is equivalent to a normal clone.
java.lang.CloneNotSupportedExceptionpublic java.lang.String toString()
toString in class java.lang.Object
public java.lang.String toString(char delimiter,
char separator,
boolean alwaysQuote)
delimiter - a delimiter for separating the items.separator - a separator which appears between the keys and the valuesalwaysQuote - if true, all items are quote. If false, only
quote items which require quotes (such as strings containing
the delimiter character, or the '\' character, etc.)
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||