Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)

com.lapetus_ltd.api.db.control
Class TLptsRowEvent

java.lang.Object
  extended by com.lapetus_ltd.api.db.control.TLptsRowEvent

public class TLptsRowEvent
extends java.lang.Object

Class Description : This class contains all the information required for a row event from the TLptsFactoryRowSet.

This object is sent with ILptsFactoryRowSetListener.rowEvent(TLptsRowEvent) and contains all information
required for the application to process a row event.


$LastChangedRevision: 1165 $
$LastChangedDate:: 2010-11-03 10:37:03#$


Nested Class Summary
static class TLptsRowEvent.EVENT_TYPE
           
 
Constructor Summary
TLptsRowEvent(java.util.List<java.lang.Object> rowObjectList, java.util.List<java.lang.String> columnNameList, java.util.List<java.lang.Integer> columnTypeList, java.util.List<byte[]> byteValueList, TLptsRowEvent.EVENT_TYPE eventType, TLptsStatement statement, java.lang.String primaryStatementId, java.lang.String rowSetId, int currentRowNo)
           Constructor for RowSet Events.
 
Method Summary
 java.util.List<byte[]> getByteValueList()
           Gets the raw byte data for the current row Objects.
 java.util.List<java.lang.String> getColumnNameList()
           Gets the column names from the current RowSet.
 java.util.List<java.lang.Integer> getColumnTypeList()
           Get SQL Types for columns from current RowSet.
 int getCurrentRowNo()
           Gets the current row number.
 TLptsRowEvent.EVENT_TYPE getEventType()
           Gets the Type of row Event.
 java.lang.String getId()
           Gets the RowEvent id.
 java.lang.String getPrimaryStatementId()
           Gets the id from primary Statement to this statement (the one that feeds data to this one).
 java.util.List<java.lang.Object> getRowObjectList()
           Gets the Object List from the current Row.
 java.lang.String getRowSetId()
           Gets the Id from the RowSet that generated this event.
 TLptsStatement getStatement()
           Gets a reference to the statement we executed to get our RowSet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TLptsRowEvent

public TLptsRowEvent(java.util.List<java.lang.Object> rowObjectList,
                     java.util.List<java.lang.String> columnNameList,
                     java.util.List<java.lang.Integer> columnTypeList,
                     java.util.List<byte[]> byteValueList,
                     TLptsRowEvent.EVENT_TYPE eventType,
                     TLptsStatement statement,
                     java.lang.String primaryStatementId,
                     java.lang.String rowSetId,
                     int currentRowNo)

Constructor for RowSet Events. This is used internally in the application by TLptsFactoryRowSet.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :


Parameters:
rowObjectList - the object list from the current row
columnNameList - the list of column names for this rowSet
columnTypeList - the sql types of the row objects
byteValueList - the byte data for the objects
eventType - the type of event
statement - the statement we executed to get our rowSet
primaryStatementId - the id of the Primary statement for dynamic substitution
rowSetId - is the id of the current rowSet
currentRowNo - is the number of the current row (or the number of already processed rows)
Method Detail

getByteValueList

public final java.util.List<byte[]> getByteValueList()

Gets the raw byte data for the current row Objects.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes :

Example : Refer to example for getRowObjectList().

Returns:
return a list from current row objects as bytes.

getColumnNameList

public final java.util.List<java.lang.String> getColumnNameList()

Gets the column names from the current RowSet.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes :

Example : Refer to example for getRowObjectList().

Returns:
list with column names for the current RowSet.

getColumnTypeList

public final java.util.List<java.lang.Integer> getColumnTypeList()

Get SQL Types for columns from current RowSet.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes :

Example : Refer to example for getRowObjectList().

Returns:
the sql types for each column in a list.

getCurrentRowNo

public final int getCurrentRowNo()

Gets the current row number.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes : This is also equals to the number of rows that have been processed.

Example : Refer to example for getRowObjectList().

Returns:
the row number of the current row or zero when an error occurs.

getEventType

public final TLptsRowEvent.EVENT_TYPE getEventType()

Gets the Type of row Event.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes : MOVED_TO_NEXT_PRIMARY_RECORD, MOVED_TO_NEXT_RECORD, EXECUTION_INTERRUPTED, PROCESSING_COMPLETE, ERROR_OCCURRED,

Example : Refer to example for getRowObjectList().

Returns:
the event type

getId

public final java.lang.String getId()

Gets the RowEvent id. Each row event has a unique id.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never

Notes :

Example : Refer to example for getRowObjectList().

Returns:
current RowEvent id

getPrimaryStatementId

public final java.lang.String getPrimaryStatementId()

Gets the id from primary Statement to this statement (the one that feeds data to this one).

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Yes, if statement is not dynamic this id will be null.

Notes :

Example : Refer to example for getRowObjectList().

Returns:
id from primary statement

getRowObjectList

public final java.util.List<java.lang.Object> getRowObjectList()

Gets the Object List from the current Row.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never, an empty list in the worst case.

Notes :

Example :


 // In this example we have implemented a row set factory listener, that adds row events to a tree with the correct
 // hierarchy, using the primary statement id. Each line of the tree holds all the data of a row or its columns(commented).
 ...
 private class RowSetListener implements ILptsFactoryRowSetListener
 {
   private Map rowSetMap = new LinkedHashMap();
   // this tree holds the row events
   private JTree rowSetTree = new JTree(new DefaultMutableTreeNode("Root"));

   private RowSetListener()
   {
     rowSetTree.setCellRenderer(new RowSetRenderer());
   }

   public boolean processNewRowSetRows(TLptsRowSetEvent rowSetEvent)
   {
     return true;  // we want TLptsFactoryRowSet to process the rows and send them to us as row events
   }

   public void rowEvent(TLptsRowEvent rowEvent)
   {
     DefaultMutableTreeNode treeNodeToAddTo = (DefaultMutableTreeNode)rowSetTree.getModel().getRoot();

     if (rowEvent.getEventType().equals(TLptsRowEvent.EVENT_TYPE.MOVED_TO_NEXT_PRIMARY_RECORD) ||
         rowEvent.getEventType().equals(TLptsRowEvent.EVENT_TYPE.MOVED_TO_NEXT_RECORD))
     {
       if (rowEvent.getStatement().hasPrimaryStatement())
         if (rowSetMap.get(rowEvent.getPrimaryStatementId()) != null)
           treeNodeToAddTo = rowSetMap.get(rowEvent.getPrimaryStatementId());
       DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode(rowEvent);
       treeNodeToAddTo.add(treeNode);
       if (rowEvent.getEventType().equals(TLptsRowEvent.EVENT_TYPE.MOVED_TO_NEXT_PRIMARY_RECORD))
         rowSetMap.put(rowEvent.getStatement().getId(), treeNode);
     }
   }

   private class RowSetRenderer implements TreeCellRenderer
   {
     public Component getTreeCellRendererComponent(JTree tree, Object value,
                                                   boolean selected, boolean expanded,
                                                   boolean leaf, int row, boolean hasFocus)
     {
       String rowString="";
       if (value instanceof String)
         rowString = (String)value;
       else
         if (value instanceof TLptsRowEvent)
         {
           rowString += ((TLptsRowEvent)value).getCurrentRowNo();
           for (Object obj : ((TLptsRowEvent)value).getRowObjectList())
             rowString += obj.toString() + " ";
           //for (String columnName: ((TLptsRowEvent)value).getColumnNameList())
           //  rowString += columnName + " ";
         }
         return new JLabel(rowString);
     }
   }
 }
 

Returns:
list with objects from current row

getRowSetId

public final java.lang.String getRowSetId()

Gets the Id from the RowSet that generated this event.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example : Refer to example for getRowObjectList().

Returns:
id from current RowSet.

getStatement

public final TLptsStatement getStatement()

Gets a reference to the statement we executed to get our RowSet.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Yes

Notes :

Example : Refer to example for getRowObjectList().

Returns:
the statement we executed to get RowSet


Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)