com.plumtree.uiinfrastructure.utils
Class PTListMap

java.lang.Object
  extended by com.plumtree.uiinfrastructure.utils.PTListMap

public class PTListMap
extends java.lang.Object

A data structure that is equivalent to a list of hashtables or a 2D staggered array but simpler interface and with convenience methods to retrieve String and integers. Logical image of the data structure: [0][key][key2][key3]...[keyn] [1][key][key2][key3]...[keyn] [2][key][key2][key3]...[keym] Uses one hashtable internally for efficiency. Example: Setting data * PTListMap foo = new PTListMap(); int nIndex = foo.AddNewElement(); foo.AddElementToIndex(nIndex, "fooKey1", "fooValue"); foo.AddElementToIndex(nIndex, "fooKey2", new Integer(100) ); foo.AddElementToIndex(nIndex, "fooKey3", new FooClass() ); nIndex = foo.AddNewElement(); foo.AddElementToIndex(nIndex, "fooKey1", "fooValue"); foo.AddElementToIndex(nIndex, "fooKey2", new Integer(100) ); foo.AddElementToIndex(nIndex, "fooKey3", new FooClass() ); Getting data for ( int i = 0; i < foo.GetSize(); i++ ) { String strVal = foo.GetElementAsString(i, "fooKey1"); int nVal = foo.GetElementAsInt(i, "fooKey2"); Object oVal = int nVal = foo.GetElementAs(i, "fooKey3"); }

Author:
robertz

Constructor Summary
PTListMap()
          Creates an empty PTListMap
 
Method Summary
 void AddElementToIndex(int nIndex, java.lang.String strKey, java.lang.Object Value)
          Adds a key/value pair to an existing row.
 int AddNewElement()
          Gets the index of the next row
 java.lang.Object GetElement(int nIndex, java.lang.String strKey)
          Get an entry as Object
 int GetElementAsInt(int nIndex, java.lang.String strKey)
          Get an entry as Int
 java.lang.String GetElementAsString(int nIndex, java.lang.String strKey)
          Get an entry as String
 int GetSize()
          Get the number of rows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PTListMap

public PTListMap()
Creates an empty PTListMap

Method Detail

GetSize

public int GetSize()
Get the number of rows.

Returns:

AddNewElement

public int AddNewElement()
Gets the index of the next row

Returns:
The index of the new row

AddElementToIndex

public void AddElementToIndex(int nIndex,
                              java.lang.String strKey,
                              java.lang.Object Value)
Adds a key/value pair to an existing row.

Parameters:
nIndex - Row index
strKey -
Value -

GetElement

public java.lang.Object GetElement(int nIndex,
                                   java.lang.String strKey)
Get an entry as Object

Parameters:
nIndex -
strKey -
Returns:

GetElementAsInt

public int GetElementAsInt(int nIndex,
                           java.lang.String strKey)
Get an entry as Int

Parameters:
nIndex -
strKey -
Returns:

GetElementAsString

public java.lang.String GetElementAsString(int nIndex,
                                           java.lang.String strKey)
Get an entry as String

Parameters:
nIndex -
strKey -
Returns:



Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.