ariba.util.core
Class Gridtable

java.lang.Object
  extended by ariba.util.core.Gridtable
Direct Known Subclasses:
OptimizingGridtable

public class Gridtable
extends Object

A two-dimensional map. That is, a collection of non-null objects indexed by 2 keys.


Field Summary
static String ClassName
           
 
Constructor Summary
Gridtable()
           
 
Method Summary
 void clear()
          Clear all elements from this table.
 boolean containsPrimaryKey(Object key1)
          Returns whether the grid table contains the primary key key1.
 Object[] elementsArray()
          Returns all unique objects in the Gridtable as an array.
 List elementsList()
          Returns all unique objects in the Gridtable as an array.
 Object get(Object key1, Object key2)
          Return the element indexed by .
static Object lookupKey(List keys, Object key, Compare compare)
          Looks at the given list of keys to find one that matches the specified key, using the given compare function.
 Gridtable pivot()
          Returns a new Gridtable, with the primary and secondary keys swapped.
 Iterator primaryKeys()
          Returns the primary keys.
 Object put(Object key1, Object key2, Object element)
          Store the specified element indexed by .
 Map remove(Object key1)
          Remove a key from the first dimension of the grid.
 Object remove(Object key1, Object key2)
          Remove a key from the specified cell of the grid.
 List secondaryElementsList(Object primaryKey)
          Returns unique objects in the gridtable as a list given a primary key.
 Iterator secondaryKeys(Object key1)
          Returns a vector containing the secondary keys, given a primary key.
 void setPrimaryKeyCompare(Compare c)
          Squirrel away a default compare object for sorting the primary keys.
 void setSecondaryKeyCompare(Compare c)
          Squirrel away a default compare object for sorting the secondary keys.
 int size()
           
 Iterator sortedPrimaryKeys()
          Returns the primary keys, in sorted order.
 Iterator sortedPrimaryKeys(Compare c)
          Returns the primary keys, in sorted order.
 List sortedPrimaryKeysList()
           
 List sortedPrimaryKeysList(Compare c)
           
 Iterator sortedSecondaryKeys(Object key1)
          Returns an array containing the secondary keys, given a primary key.
 Iterator sortedSecondaryKeys(Object key1, Compare c)
          Returns an array containing the secondary keys, given a primary key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ClassName

public static final String ClassName
See Also:
Constant Field Values
Constructor Detail

Gridtable

public Gridtable()
Method Detail

setPrimaryKeyCompare

public void setPrimaryKeyCompare(Compare c)
Squirrel away a default compare object for sorting the primary keys.


setSecondaryKeyCompare

public void setSecondaryKeyCompare(Compare c)
Squirrel away a default compare object for sorting the secondary keys.


put

public Object put(Object key1,
                  Object key2,
                  Object element)
Store the specified element indexed by .

Returns:
the element previously associated with the keys if any, null otherwise.
Throws:
NullPointerException - if element or key1 or key2 are null

get

public Object get(Object key1,
                  Object key2)
Return the element indexed by .

Throws:
NullPointerException - if key1 or key2 are null

remove

public Map remove(Object key1)
Remove a key from the first dimension of the grid. Index of

Parameters:
key1 - The key to remove
Returns:
The removed section of the grid
Throws:
NullPointerException - if key1 is null

remove

public Object remove(Object key1,
                     Object key2)
Remove a key from the specified cell of the grid. Index of

Parameters:
key1 - The first dimension of the grid
key2 - The second dimension of the grid
Returns:
The removed cell of the grid
Throws:
NullPointerException - if key1 or key2 are null

clear

public void clear()
Clear all elements from this table. Analogous to Map.clear().


size

public int size()
Returns:
the number of elements in this gridtable.

primaryKeys

public Iterator primaryKeys()
Returns the primary keys.


containsPrimaryKey

public boolean containsPrimaryKey(Object key1)
Returns whether the grid table contains the primary key key1.

Parameters:
key1 - the primary key to check against
Returns:
whether the grid table contains the primary key key1

sortedPrimaryKeys

public Iterator sortedPrimaryKeys()
Returns the primary keys, in sorted order.


sortedPrimaryKeys

public Iterator sortedPrimaryKeys(Compare c)
Returns the primary keys, in sorted order.


sortedPrimaryKeysList

public List sortedPrimaryKeysList()

sortedPrimaryKeysList

public List sortedPrimaryKeysList(Compare c)

lookupKey

public static Object lookupKey(List keys,
                               Object key,
                               Compare compare)
Looks at the given list of keys to find one that matches the specified key, using the given compare function. Returns null if there are no matches. If the compare function is null, uses the "equals" method.


secondaryKeys

public Iterator secondaryKeys(Object key1)
Returns a vector containing the secondary keys, given a primary key.


sortedSecondaryKeys

public Iterator sortedSecondaryKeys(Object key1)
Returns an array containing the secondary keys, given a primary key.


sortedSecondaryKeys

public Iterator sortedSecondaryKeys(Object key1,
                                    Compare c)
Returns an array containing the secondary keys, given a primary key.


elementsArray

public Object[] elementsArray()
Returns all unique objects in the Gridtable as an array. Note that the test for uniqueness is on the object itself, not the keys, and uses the comparison used by java.util.Map.put(key, object) on key.


secondaryElementsList

public List secondaryElementsList(Object primaryKey)
Returns unique objects in the gridtable as a list given a primary key. If the primaryKey is null, throws NullPointerException.


elementsList

public List elementsList()
Returns all unique objects in the Gridtable as an array. Note that the test for uniqueness is on the object itself, not the keys, and uses the comparison used by java.util.Map.put(key, object) on key.


pivot

public Gridtable pivot()
Returns a new Gridtable, with the primary and secondary keys swapped.



AribaWeb User Interface Development Framework
Copyright © 2000-2009 Ariba, Inc. All Rights Reserved.