|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.plumtree.uiinfrastructure.utils.PTListMap
public class PTListMap
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");
}
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 |
---|
public PTListMap()
Method Detail |
---|
public int GetSize()
public int AddNewElement()
public void AddElementToIndex(int nIndex, java.lang.String strKey, java.lang.Object Value)
nIndex
- Row indexstrKey
- Value
- public java.lang.Object GetElement(int nIndex, java.lang.String strKey)
nIndex
- strKey
-
public int GetElementAsInt(int nIndex, java.lang.String strKey)
nIndex
- strKey
-
public java.lang.String GetElementAsString(int nIndex, java.lang.String strKey)
nIndex
- strKey
-
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |