ariba.util.core
Class Gridtable

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

public class Gridtable
extends java.lang.Object

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


Field Summary
static java.lang.String ClassName
           
 
Constructor Summary
Gridtable()
           
 
Method Summary
 void clear()
          Clear all elements from this table.
 boolean containsPrimaryKey(java.lang.Object key1)
          Returns whether the grid table contains the primary key key1.
 java.lang.Object[] elementsArray()
          Returns all unique objects in the Gridtable as an array.
 java.util.List elementsList()
          Returns all unique objects in the Gridtable as an array.
 java.lang.Object get(java.lang.Object key1, java.lang.Object key2)
          Return the element indexed by .
static java.lang.Object lookupKey(java.util.List keys, java.lang.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.
 java.util.Iterator primaryKeys()
          Returns the primary keys.
 java.lang.Object put(java.lang.Object key1, java.lang.Object key2, java.lang.Object element)
          Store the specified element indexed by .
 java.util.Map remove(java.lang.Object key1)
          Remove a key from the first dimension of the grid.
 java.lang.Object remove(java.lang.Object key1, java.lang.Object key2)
          Remove a key from the specified cell of the grid.
 java.util.List secondaryElementsList(java.lang.Object primaryKey)
          Returns unique objects in the gridtable as a list given a primary key.
 java.util.Iterator secondaryKeys(java.lang.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()
           
 java.util.Iterator sortedPrimaryKeys()
          Returns the primary keys, in sorted order.
 java.util.Iterator sortedPrimaryKeys(Compare c)
          Returns the primary keys, in sorted order.
 java.util.List sortedPrimaryKeysList()
           
 java.util.List sortedPrimaryKeysList(Compare c)
           
 java.util.Iterator sortedSecondaryKeys(java.lang.Object key1)
          Returns an array containing the secondary keys, given a primary key.
 java.util.Iterator sortedSecondaryKeys(java.lang.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 java.lang.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 java.lang.Object put(java.lang.Object key1,
                            java.lang.Object key2,
                            java.lang.Object element)
Store the specified element indexed by .

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

get

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

Throws:
java.lang.NullPointerException - if key1 or key2 are null

remove

public java.util.Map remove(java.lang.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:
java.lang.NullPointerException - if key1 is null

remove

public java.lang.Object remove(java.lang.Object key1,
                               java.lang.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:
java.lang.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 java.util.Iterator primaryKeys()
Returns the primary keys.


containsPrimaryKey

public boolean containsPrimaryKey(java.lang.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 java.util.Iterator sortedPrimaryKeys()
Returns the primary keys, in sorted order.


sortedPrimaryKeys

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


sortedPrimaryKeysList

public java.util.List sortedPrimaryKeysList()

sortedPrimaryKeysList

public java.util.List sortedPrimaryKeysList(Compare c)

lookupKey

public static java.lang.Object lookupKey(java.util.List keys,
                                         java.lang.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 java.util.Iterator secondaryKeys(java.lang.Object key1)
Returns a vector containing the secondary keys, given a primary key.


sortedSecondaryKeys

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


sortedSecondaryKeys

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


elementsArray

public java.lang.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 java.util.List secondaryElementsList(java.lang.Object primaryKey)
Returns unique objects in the gridtable as a list given a primary key. If the primaryKey is null, throws NullPointerException.


elementsList

public java.util.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-2014 Ariba, Inc. All Rights Reserved.