All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.collection
Interface AssociationListInterface

All Superinterfaces:
  java.lang.Cloneable, CollectionInterface, com.sas.collection.ContentsChangedSource, com.sas.util.Countable, DictionaryInterface, com.sas.util.Enumerable, IndexedGetInterface, IndexedSetInterface, OrderedCollectionInterface, com.sas.beans.PropertyChangeSource, com.sas.PublicClonable, Sortable, StaticCollectionInterface, StaticDictionaryInterface, StaticOrderedCollectionInterface

All Known Implementing Classes:
  AssociationList, ColorNameList, RGBList

    public interface AssociationListInterface

extends OrderedCollectionInterface, DictionaryInterface

AssociationListInterface combines the OrderedCollection interface and the DictionaryInterface interface, yielding a collection whose items may be accessed by either an index or a key. Items may be added in order or by an object key, or both. Items added by just key and not index are added to the end of the list. The items and keys Enumerations return items in the implicit order. Since this interface implements the collection interface, key/value pairs may be added multiple times. There is an ordered collection bias to this object; it's treated as an ordered collection that supports keys, rather than a dictionary that supports ordering.

Method Summary
`abstract void` | `add(int index, java.lang.Object key, java.lang.Object item)` Add an item into this association list at the specified index.
`abstract void` | `applyToPairs(com.sas.util.ApplyInterface action)` Applies an action to all key/value pairs in the association list.
`abstract java.lang.Object` | `clone()` Clone the object.
`abstract java.lang.Object` | `get(java.lang.Object key, int index)` Fetch the item corresponding to a key, starting at a specific location.
`abstract java.lang.Object` | `getKey(int index)` Get the key corresponding to a position.
`abstract java.lang.Object` | `getKey(java.lang.Object item, int start)` Get the key corresponding to an item.
`abstract java.util.Enumeration` | `getPairs()` Returns an enumeration of all the key/value pairs from an association list.
`abstract java.util.Enumeration` | `getPairs(int start, int end)` Returns an enumeration of the key/value item pairs from an association list.
`abstract void` | `removeAllAt(java.lang.Object key)` Remove all items with the specified key.
`abstract void` | `set(int index, java.lang.Object key, java.lang.Object item)` Put an item into this association list, replacing a previous item that was there by the same index/key (although such behavior is defined by the implementation).
`abstract void` | `setKey(int index, java.lang.Object key)` Set the key corresponding to a position.

Methods inherited from interface com.sas.collection.OrderedCollectionInterface
`add, addItems, removeAt, set, setSize`

Methods inherited from interface com.sas.collection.StaticOrderedCollectionInterface
`equals, getIndex, getItems, getLastIndex`

Methods inherited from interface com.sas.util.IndexedGetInterface
`get`

Methods inherited from interface com.sas.collection.Sortable
`sort, sort`

Methods inherited from interface com.sas.collection.DictionaryInterface
`remove, removeAt, set`

Methods inherited from interface com.sas.collection.StaticDictionaryInterface
`containsKey, get, getKey, getKeys, getKeys`

Methods inherited from interface com.sas.collection.CollectionInterface
`add, addItems, removeAll, removeAll`

Methods inherited from interface com.sas.collection.StaticCollectionInterface
`apply, contains`

Methods inherited from interface com.sas.collection.ContentsChangedSource
`addContentsChangedListener, removeContentsChangedListener`

Methods inherited from interface com.sas.beans.PropertyChangeSource
`addPropertyChangeListener, removePropertyChangeListener`

Methods inherited from interface com.sas.util.Countable
`count`

Methods inherited from interface com.sas.util.Enumerable
`getItems`

Method Detail

### getPairs

    java.util.Enumeration getPairs()

  Returns an enumeration of all the key/value pairs from an association list.

  Returns:
    an enumeration of Pair objects. This is a convenience for `getPairs(0, count())` In each returned Pair, `pair.getFirst()` is the key; `pair.getSecond()` is the value

### getPairs

    java.util.Enumeration getPairs(int start,
                                   int end)

  Returns an enumeration of the key/value item pairs from an association list.

  Parameters:
    `start` - the index of the first item, zero based.
    `end` - one past the index of the last item to include in the enumeration, zero based.
  Returns:
    an enumeration of Pair objects of the requested elements. In each returned Pair, `pair.getFirst()` is the key; `pair.getSecond()` is the value
  Throws:
    `java.lang.IndexOutOfBoundsException` - if start is not in the range [0, count()-1], or start >last or end is not in the range [0, count()]
  See Also:
    `Pair`

### applyToPairs

    void applyToPairs(com.sas.util.ApplyInterface action)

  Applies an action to all key/value pairs in the association list.

  Parameters:
    `action` - An object that provides a function which takes an object as an argument and then does something to it. `action.apply(pair)` is excecuted on successive key/value pairs until all pairs in the this association list have been operated on, or until the method returns `ApplyInterface.ABORT`
  See Also:
    `Pair`

### set

    void set(int index,
             java.lang.Object key,
             java.lang.Object item)

  Put an item into this association list, replacing a previous item that was there by the same index/key (although such behavior is defined by the implementation).

  Parameters:
    `index` - where in the implicit order to store the item.
    `key` - the key by which the item may be retrieved later.
    `item` - the value to put into this association list

### add

    void add(int index,
             java.lang.Object key,
             java.lang.Object item)

  Add an item into this association list at the specified index. The item and key will be available via `get(index)` and `getKey(index)`

  Parameters:
    `index` - where in the implicit order to insert the item.
    `key` - the key by which the item may be retrieved later.
    `item` - the value to put into this association list

### getKey

    java.lang.Object getKey(java.lang.Object item,
                            int start)

  Get the key corresponding to an item. Note that an association list may contain the same item via multiple keys. If so, this method returns one, but the interface does not specify which one (i.e. it does not have to be the first one entered in this association list, or the first one as found in the getItems() enumeration).

  Parameters:
    `item` - the item whose key you wish to find.
    `start` - the index of where to start searching
  Returns:
    the key for the item, or null if the item is not found.

### getKey

    java.lang.Object getKey(int index)

  Get the key corresponding to a position.

  Parameters:
    `index` - return the key corresponding to this index
  Returns:
    the key found at the specified index
  Throws:
    `java.lang.IndexOutOfBoundsException` - if index is not in the range [0, count()-1]

### setKey

    void setKey(int index,
                java.lang.Object key)

  Set the key corresponding to a position.

  Parameters:
    `index` - replace the key at this index
    `key` - the new key
  Throws:
    `java.lang.IndexOutOfBoundsException` - if index is not in the range [0, count()-1]

### get

    java.lang.Object get(java.lang.Object key,
                         int index)

  Fetch the item corresponding to a key, starting at a specific location.

  Parameters:
    `key` - the Object key with which the item was added to this association list
    `index` - start searching for the key at this index
  Returns:
    the item in this association list which corresponds to the given key. There may be only one item per key.
  Throws:
    `NoSuchElementException` - when there is no entry for the specified key. (Note that `null` is a valid value for a key.)
    `java.lang.IndexOutOfBoundsException` - if if the index is invalid
  See Also:
    `StaticDictionaryInterface.get(java.lang.Object)`, `IndexedGetInterface.get(int)`

### removeAllAt

    void removeAllAt(java.lang.Object key)

  Remove all items with the specified key.

  Parameters:
    `key` - remove all items with this key.

### clone

    java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Clone the object.

  Specified by:
    `clone` in interface `CollectionInterface`
  Specified by:
    `clone` in interface `DictionaryInterface`
  Specified by:
    `clone` in interface `OrderedCollectionInterface`
  Specified by:
    `clone` in interface `com.sas.PublicClonable`
  Specified by:
    `clone` in interface `StaticCollectionInterface`
  Specified by:
    `clone` in interface `StaticDictionaryInterface`
  Specified by:
    `clone` in interface `StaticOrderedCollectionInterface`
  Returns:
    a clone of this association list.
  Throws:
    `java.lang.CloneNotSupportedException` - if the object could not be cloned.

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.