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 java.lang.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

Field Summary
protected  IDataRow drMasterDataRow
          The master row from the corresponding master DataBook.
protected  IRowDefinition rdRowDefinition
          The IRowDefinition that uses this MemDataPage.
protected  IDataBook rootDataBook
          The root IDataBook.
 
Constructor Summary
MemDataPage(MemDataBook pDataBook, IDataRow pMasterDataRow)
          Construct a new MemDataPage for the specified IDataBook and the corresponding master row.
 
Method Summary
protected  void addFetchedRow(java.lang.Object[] pValues)
          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.
 void fetchAll()
          Fetches all IDataRows from the storage.
 void fetchToRow(int pRowIndex)
          Will/should be overridden in the derived Classes to fetch data from the storage.
 int[] getChangedDataRows()
          Deprecated. 
 int[] getChangedRows()
          Gets an int array containing the indexes of all changed IDataRow s.
 IDataBook getDataBook()
          Gets the parent IDataBook.
 IChangeableDataRow getDataRow(int pDataRowIndex)
          Gets a copy of the IChangeableDataRow at the specified index.
protected  java.lang.Object[] getDataRowStorage(int pDataRowIndex)
          Returns the internal storage for the specified DataRow Object[].
 int getEstimatedRowCount()
          Returns -1.
 IDataRow getMasterDataRow()
          Gets the corresponding master row.
 int getRowCount()
          Gets the number of rows which are currently held.
protected  int getRowCountInternal()
          Returns the row count of this MemDataPage.
 boolean hasChanges()
          Returns true, if there are changes.
 boolean isAllFetched()
          Gets if all IDataRows have been fetched from the storage, and there is nothing more to fetch.
 int searchNext(ICondition pCondition)
          Searches for the first occurrence of an IDataRow which matches the given ICondition and returns its index.
 int searchNext(ICondition pCondition, int pStartIndex)
          Searches for the next occurrence of an IDataRow which matches the given ICondition and returns its index.
 int searchPrevious(ICondition pCondition)
          Searches for the last occurrence of an IDataRow which matches the given ICondition and returns its index.
 int searchPrevious(ICondition pCondition, int pStartIndex)
          Searches for the previous occurrence of an IDataRow which matches the given ICondition and returns its index.
protected  void setAllFetched(boolean pAllFetched)
          Sets that the MemDataPage has all fetched.
protected  void setDataRow(int pDataRowIndex, ChangeableDataRow pRow)
          Sets the internal storage for the specified DataRow Object[].
protected  void setMasterDataRow(IDataRow pMasterDataRow)
          Sets a new Master DataRow, if it changes.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rootDataBook

protected IDataBook rootDataBook
The root IDataBook.


rdRowDefinition

protected IRowDefinition rdRowDefinition
The IRowDefinition that uses this MemDataPage.


drMasterDataRow

protected IDataRow drMasterDataRow
The master row from the corresponding master DataBook.

Constructor Detail

MemDataPage

public MemDataPage(MemDataBook 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()
Gets the parent IDataBook.

Specified by:
getDataBook in interface IDataPage
Returns:
Gets the parent IDataBook.

getMasterDataRow

public IDataRow getMasterDataRow()
Gets the corresponding master row.

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

getDataRow

public IChangeableDataRow getDataRow(int pDataRowIndex)
                              throws ModelException
Gets a copy of the IChangeableDataRow at the specified index. Returns null if there is no row at the specified index.

If the row is currently not in memory, it will be fetched from the underlying storage.

Specified by:
getDataRow in interface IDataPage
Parameters:
pDataRowIndex - the index of the IChangeableDataRow to get.
Returns:
a copy of the IChangeableDataRow at the specified index, null if there is no row at the specified index.
Throws:
ModelException - if the IChangeableDataRow at the specified index can no be got.

fetchAll

public void fetchAll()
              throws ModelException
Fetches all IDataRows from the storage.

Specified by:
fetchAll in interface IDataPage
Throws:
ModelException - if there is a problem while fetching the rows.

isAllFetched

public boolean isAllFetched()
                     throws ModelException
Gets if all IDataRows have been fetched from the storage, and there is nothing more to fetch.

Specified by:
isAllFetched in interface IDataPage
Returns:
true if all IDataRows have been fetched.
Throws:
ModelException - if determining if all IDataRows have been fetched failed.

getRowCount

public int getRowCount()
                throws ModelException
Gets the number of rows which are currently held.

Specified by:
getRowCount in interface IDataPage
Returns:
the number of rows which are currently held.
Throws:
ModelException - if the number of rows could not be determined.

getChangedDataRows

@Deprecated
public int[] getChangedDataRows()
Deprecated. 

Gets an int array containing the indexes of all changed IDataRow s. Returns an empty array if there are no changed IDataRows.

Specified by:
getChangedDataRows in interface IDataPage
Returns:
an int array containing the indexes of all changed IDataRows. An empty array if there are no changes.

getChangedRows

public int[] getChangedRows()
Gets an int array containing the indexes of all changed IDataRow s. Returns an empty array if there are no changed IDataRows.

Specified by:
getChangedRows in interface IDataPage
Returns:
an int array containing the indexes of all changed IDataRows. An empty array if there are no changes.

searchNext

public int searchNext(ICondition pCondition)
               throws ModelException
Searches for the first occurrence of an IDataRow which matches the given ICondition and returns its index. -1 is returned if there is no IDataRow that matches.

This method might fetch more rows from the storage as needed.

Specified by:
searchNext in interface IDataPage
Parameters:
pCondition - the ICondition.
Returns:
the index of the first matching IDataRow, -1 if there is none.
Throws:
ModelException - if searching through and/or fetching the IDataRows failed.

searchNext

public int searchNext(ICondition pCondition,
                      int pStartIndex)
               throws ModelException
Searches for the next occurrence of an IDataRow which matches the given ICondition and returns its index. The search is started at the given index. -1 is returned if there is no IDataRow that matches.

This method might fetch more rows from the storage as needed.

Specified by:
searchNext in interface IDataPage
Parameters:
pCondition - the ICondition.
pStartIndex - the index at which to start, inclusive.
Returns:
the index of the next matching IDataRow, -1 if there is none.
Throws:
ModelException - if searching through and/or fetching the IDataRows failed.

searchPrevious

public int searchPrevious(ICondition pCondition)
                   throws ModelException
Searches for the last occurrence of an IDataRow which matches the given ICondition and returns its index. -1 is returned if there is no IDataRow that matches.

This method might fetch more rows from the storage as needed.

Specified by:
searchPrevious in interface IDataPage
Parameters:
pCondition - the ICondition.
Returns:
the index of the last matching IDataRow, -1 if there is none.
Throws:
ModelException - if searching through and/or fetching the IDataRows failed.

searchPrevious

public int searchPrevious(ICondition pCondition,
                          int pStartIndex)
                   throws ModelException
Searches for the previous occurrence of an IDataRow which matches the given ICondition and returns its index. The search is started at the given index. -1 is returned if there is no IDataRow that matches.

This method might fetch more rows from the storage as needed.

Specified by:
searchPrevious in interface IDataPage
Parameters:
pCondition - the ICondition.
pStartIndex - the index at which to start, exclusive.
Returns:
the index of the previous matching IDataRow, -1 if there is none.
Throws:
ModelException - if searching through and/or fetching the IDataRows failed.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

hasChanges

public boolean hasChanges()
Returns true, if there are changes.

Returns:
true, if there are changes

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

protected void addFetchedRow(java.lang.Object[] pValues)
                      throws ModelException
It adds an new IDataRow to the DataPage in the object[] storage.

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

getDataRowStorage

protected java.lang.Object[] getDataRowStorage(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.

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

getEstimatedRowCount

public int getEstimatedRowCount()
                         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.

setDataRow

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

Parameters:
pDataRowIndex - the row index.
pRow - the ChangeableDataRow to use.
Throws:
ModelException - if the mem sort and/or filter fails.

clear

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



Copyright © 2009 SIB Visions GmbH. All Rights Reserved.