Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)
com.lapetus_ltd.api.db.xml.types
Class TLptsXmlRowSetType
java.lang.Object
com.lapetus_ltd._2009.xml.types.XLptsXmlRowSetType
com.lapetus_ltd.api.db.xml.types.TLptsXmlRowSetType
public class TLptsXmlRowSetType extends XLptsXmlRowSetType
Class Description : This class hold the rowset data, with hierarchy, so that it can be transported or stored.
This class is utilised by TLptsRowSetOutputListener
to store the rowset data in XML format.
The structure of the primary and dynamic data is kept in the structure of this class, which makes it ideal for processing and then
sending or storing the rowset data.
To be more specific, there are three levels of data, namely the table, the row and the objects. Each of these has a one to many
relationship to the other. Below is an example of how to use the three levels for creating the structure.
public void addMultipleRows()
{
TLptsXmlRowSetType rowSetXml = new TLptsXmlRowSetType();
// we declare the lists for the data infusion
List columnNames = new LinkedList();
columnNames.add("COLUMN_NAME_1");
columnNames.add("COLUMN_NAME_2");
List objectList1 = new LinkedList();
objectList1.add("My String for column 1 - Level 1");
objectList1.add(123);
List byteList1 = new LinkedList();
byteList1.add(TLptsBytesUtil.string2Bytes("My String for column 1 - Level 1"));
byteList1.add(TLptsBytesUtil.int2Bytes(123));
List objectList2 = new LinkedList();
objectList2.add("My String for column 1 - Level 2");
objectList2.add(456);
List byteList2 = new LinkedList();
byteList2.add(TLptsBytesUtil.string2Bytes("My String for column 1 - Level 2"));
byteList2.add(TLptsBytesUtil.int2Bytes(456));
List objectList3 = new LinkedList();
objectList3.add("My String for column 1 - Level 3");
objectList3.add(789);
List byteList3 = new LinkedList();
byteList3.add(TLptsBytesUtil.string2Bytes("My String for column 1 - Level 3"));
byteList3.add(TLptsBytesUtil.int2Bytes(789));
List sqlTypeList = new LinkedList();
sqlTypeList.add(java.sql.Types.VARCHAR);
sqlTypeList.add(java.sql.Types.INTEGER);
TLptsXmlRowSetTableType table1 = new TLptsXmlRowSetTableType("table1",columnNames);
TLptsXmlRowSetTableType table2 = new TLptsXmlRowSetTableType("table2",columnNames);
TLptsXmlRowSetTableType table3 = new TLptsXmlRowSetTableType("table3",columnNames);
TLptsXmlRowSetSingleRowType level1Row = new TLptsXmlRowSetSingleRowType(1,
objectList1,
sqlTypeList,
byteList1 );
table1.addRowListItem(level1Row);
TLptsXmlRowSetSingleRowType level2Row = new TLptsXmlRowSetSingleRowType(1,
objectList2,
sqlTypeList,
byteList2 );
table2.addRowListItem(level2Row);
table2.addRowListItem(new TLptsXmlRowSetSingleRowType(1,
objectList2,
sqlTypeList,
byteList2 ));
// add the sub row to the 2nd level row
table3.addRowListItem(new TLptsXmlRowSetSingleRowType(1,
objectList3,
sqlTypeList,
byteList3 ));
// add the sub row to the top level row
level1Row.addSubTableListItem(table2);
level2Row.addSubTableListItem(table3);
List list = new LinkedList();
list.add(level1Row);
printSingleRowSetList(list, 1);
}
public void printSingleRowSetList(java.util.List singleRowList, int level)
{
for (XLptsXmlRowSetSingleRowType rssrt : singleRowList)
{
String preamble = "";
for (int i = 1;i < level;i++)
preamble += " ";
preamble += "=> ";
System.out.print(preamble);
for (XLptsXmlRowSetRowObjectType rsro : rssrt.getRowObjectListItem())
System.out.print(rsro.getString() + " ");
System.out.println();
for (XLptsXmlRowSetTableType tableItem : rssrt.getSubTableListItem())
printSingleRowSetList(tableItem.getRowListItem(), level + 1);
}
}
### result :
=> My String for column 1 - Level 1 123
=> My String for column 1 - Level 2 456
=> My String for column 1 - Level 3 789
=> My String for column 1 - Level 2 456
$LastChangedRevision: 1165 $
$LastChangedDate:: 2010-11-03 10:37:03#$
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
TLptsXmlRowSetType
public TLptsXmlRowSetType ()
The constructor for the TLptsXmlRowSetType.
See the class description above for an example of how to use this and the other related classes.
Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)