com.sibvisions.rad.model.mem
Class MemDataPage

java.lang.Object
  extended by com.sibvisions.rad.model.mem.MemDataPage
All Implemented Interfaces:
IDataPage
Direct Known Subclasses:
RemoteDataPage

public class MemDataPage
extends Object
implements IDataPage

A MemDataPage is the memory implementation for a data page of an IDataBook.
A master IDataBook has one IDataPage for itself. If the IDataBook is (also) a detail IDataBook it stores all IDataPage's for each loaded master row (parent master).

See Also:
IDataBook, IDataPage, IChangeableDataRow

Constructor Summary
MemDataPage(IDataBook pDataBook, IDataRow pMasterDataRow)
          Construct a new MemDataPage for the specified IDataBook and the corresponding master row.
 
Method Summary
protected  void addChange(int iRowIndex)
          Adds a new change in the internal list of changes.
 void addFetchedRow(IDataRow pDataRow)
          It adds an new IDataRow to the DataPage in the object[] storage.
protected  void clear()
          It clears the mem filter and sort in the MemDataPage.
 int countRows()
          Returns -1.
protected  void delete(int pDataRowIndex)
          Deletes the specified row with the given index in the MemDataPage.
 void fetchAll()
          It fetches all IDataRow's from the storage.
 void fetchToRow(int pRowIndex)
          Will/should be overridden in the derived Classes to fetch data from the storage.
 int[] getChangedDataRows()
          Returns an int array with all changed rows.
 IDataBook getDataBook()
          Returns the IDataBook of the IDataPage.
 IChangeableDataRow getDataRow(int pDataRowIndex)
          Returns a copy of the IDataRow of the specified index.
protected  Object[] getDataRowInternal(int pDataRowIndex)
          Returns the internal storage for the specified DataRow Object[].
 IDataRow getMasterDataRow()
          Returns the corresponding master row to this IDataPage in the master DataBook.
 int getRowCount()
          Returns the size.
protected  int getRowCountInternal()
          Returns the row count of this MemDataPage.
protected  void insert(int pDataRowIndex, Object[] pStorage)
          It inserts a new IChangeableDataRow in the MemDataPage at the specified index.
 boolean isAllFetched()
          Returns true if all rows are loaded.
protected  void removeChange(int iRowIndex)
          Remove an existing change by row index.
protected  void setAllFetched(boolean pAllFetched)
          Sets that the MemDataPage has all fetched.
protected  void setDataRowInternal(int pDataRowIndex, Object[] pStorage)
          Sets the internal storage for the specified DataRow Object[].
protected  void setMasterDataRow(IDataRow pMasterDataRow)
          Sets a new Master DataRow, if it changes.
protected  void shiftIndicies(int[] pIntArray, int pRowIndex, int pShift)
          It shifts all items (row indices) by pShift (-1/+1).
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemDataPage

public MemDataPage(IDataBook pDataBook,
                   IDataRow pMasterDataRow)
Construct a new MemDataPage for the specified IDataBook and the corresponding master row.

Parameters:
pDataBook - the IDataBook which uses this MemDataPage
pMasterDataRow - the corresponding master row of the master IDataBook of the above specified IDataBook
Method Detail

getDataBook

public IDataBook getDataBook()
Returns the IDataBook of the IDataPage.

Specified by:
getDataBook in interface IDataPage
Returns:
the IDataBook of the IDataPage.

getMasterDataRow

public IDataRow getMasterDataRow()
Returns the corresponding master row to this IDataPage in the master DataBook.

Specified by:
getMasterDataRow in interface IDataPage
Returns:
the corresponding master row to this IDataPage in the master DataBook.

getDataRow

public IChangeableDataRow getDataRow(int pDataRowIndex)
                              throws ModelException
Returns a copy of the IDataRow of the specified index.
If the requested row not in memory it will be fetched from the storage. If the row is also not existing on the storage, it returns null.

Specified by:
getDataRow in interface IDataPage
Parameters:
pDataRowIndex - the index of the requested row
Returns:
a copy of the IDataRow of the specified index.
Throws:
ModelException - if a exception occur during the fetch.

fetchAll

public void fetchAll()
              throws ModelException
It fetches all IDataRow's from the storage.

Specified by:
fetchAll in interface IDataPage
Throws:
ModelException - if an DataSourceException happens during get all rows

isAllFetched

public boolean isAllFetched()
                     throws ModelException
Returns true if all rows are loaded.

Specified by:
isAllFetched in interface IDataPage
Returns:
true if all rows are loaded.
Throws:
ModelException - if the DataBook isn't open

getRowCount

public int getRowCount()
                throws ModelException
Returns the size.

Specified by:
getRowCount in interface IDataPage
Returns:
the size.
Throws:
ModelException - if a exception occurs during synchronize.

getChangedDataRows

public int[] getChangedDataRows()
Returns an int array with all changed rows.

Specified by:
getChangedDataRows in interface IDataPage
Returns:
an int array with all changed rows.

toString

public String toString()

Overrides:
toString in class Object

setAllFetched

protected void setAllFetched(boolean pAllFetched)
Sets that the MemDataPage has all fetched. Should only used from derived classes.

Parameters:
pAllFetched - the boolean with the fetch state.

addFetchedRow

public void addFetchedRow(IDataRow pDataRow)
                   throws ModelException
It adds an new IDataRow to the DataPage in the object[] storage.

Parameters:
pDataRow - the IDataRow to add.
Throws:
ModelException - if the IDataRow couldn't add to the storage.

insert

protected void insert(int pDataRowIndex,
                      Object[] pStorage)
It inserts a new IChangeableDataRow in the MemDataPage at the specified index.

Parameters:
pDataRowIndex - the row index to use.
pStorage - the storage of the new IChangeableDataRow to insert

delete

protected void delete(int pDataRowIndex)
Deletes the specified row with the given index in the MemDataPage.

Parameters:
pDataRowIndex - the row index to use.

addChange

protected void addChange(int iRowIndex)
Adds a new change in the internal list of changes.

Parameters:
iRowIndex - the row index where the change was made.

removeChange

protected void removeChange(int iRowIndex)
Remove an existing change by row index.

Parameters:
iRowIndex - the row index to use.

getDataRowInternal

protected Object[] getDataRowInternal(int pDataRowIndex)
                               throws ModelException
Returns the internal storage for the specified DataRow Object[].

Parameters:
pDataRowIndex - the row index.
Returns:
the internal storage for the specified DataRow Object[].
Throws:
ModelException - if the mem sort and/or filter fails.

setDataRowInternal

protected void setDataRowInternal(int pDataRowIndex,
                                  Object[] pStorage)
                           throws ModelException
Sets the internal storage for the specified DataRow Object[].

Parameters:
pDataRowIndex - the row index.
pStorage - the new Object[].
Throws:
ModelException - if the mem sort and/or filter fails.

shiftIndicies

protected void shiftIndicies(int[] pIntArray,
                             int pRowIndex,
                             int pShift)
It shifts all items (row indices) by pShift (-1/+1).

Parameters:
pIntArray - the int[] to shift.
pRowIndex - all items with >= pRowIndex will be shifted.
pShift - the value to add/shift

setMasterDataRow

protected void setMasterDataRow(IDataRow pMasterDataRow)
                         throws ModelException
Sets a new Master DataRow, if it changes. Internal function!

Parameters:
pMasterDataRow - the new master DataRow
Throws:
ModelException - if the column value couldn't converted

countRows

public int countRows()
              throws ModelException
Returns -1. Will/should be overridden in the derived Classes.

Returns:
-1.
Throws:
ModelException - see derived classes.

fetchToRow

public void fetchToRow(int pRowIndex)
                throws ModelException
Will/should be overridden in the derived Classes to fetch data from the storage.

Parameters:
pRowIndex - the row index to use.
Throws:
ModelException - see derived classes.

getRowCountInternal

protected int getRowCountInternal()
Returns the row count of this MemDataPage. Internal use only.

Returns:
the row count of this MemDataPage. Internal use only.

clear

protected void clear()
It clears the mem filter and sort in the MemDataPage.



Copyright © 2009 SIB Visions GmbH. All Rights Reserved.