planetj.database.filter
Class FilteredRowCollection

java.lang.Object
  |
  +--planetj.database.RowCollection
        |
        +--planetj.database.filter.FilteredRowCollection
All Implemented Interfaces:
Cloneable, Collection, IBatchProcessObject, IDistributedExecutableObject, IFDFObject, INavigationObject, IXMLObject, List, Serializable

public class FilteredRowCollection
extends RowCollection

A FilteredRowCollection is returned by the RowCollection.filter() method. It contains a subset of the rows which its parent contains. A FilteredRowCollection can be connected, in which case rows added to or removed from it will also be added to or removed from its parent, and rows added to or removed from its parent will be added to or removed from it (if they are naturally part of its subset). Neither of these actions will happen if a RowCollection is disconnected. Once disconnected, a RowCollection cannot be reconnected to its parent.

When a row is added to a FilteredRowCollection, the row is only added if it meets the filter's criteria (it may be added to the parent even if it didn't meet the criteria for this RowCollection). Currently, when a row in a FilteredRowCollection is altered, it is NOT rechecked to see if it still meets the criteria. (A Row altered in a FilteredRowCollection is also altered in its parent, since they are the same Row.)

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class planetj.database.RowCollection
RowCollection.LinkedRowCollection
 
Field Summary
 
Fields inherited from class planetj.database.RowCollection
className, FIRST_ROW, LAST_ROW
 
Constructor Summary
FilteredRowCollection()
           
 
Method Summary
 void addRow(int index, Row row)
          Inserts the specified row at the specified position in this list (optional operation).
 void disconnect()
          Disconnects this RowCollection from its parent.
 IFilter getFilter()
          Gets the filter used to create this FilteredRowCollection
 Object getKey()
          Gets the filter used to create this FilteredRowCollection
 RowCollection getParent()
          Gets the RowCollection from which this FilteredRowCollection was created
 Object getValue()
          Returns this same FilteredRowCollection
 boolean isConnected()
          Tests if this RowCollection is connected to its parent
 void refilter()
          Clears this RowCollection and then reruns the filter, adding rows from the parent as appropriate
 boolean removeRow(Row row)
          Removes the row from this RowCollection.
 void setFilter(IFilter newFilter)
          Sets the filter used to create this FilteredRowCollection.
 void setParent(RowCollection newParent)
          Sets the parent of this FilteredRowCollection.
 Row setRow(int index, Row row)
          Replaces the row at the specified position in this list with the specified row, if the Row meets the filter criteria.
 RowCollection sort(String[] pColumnNames, String pSortOrder)
          Sorts the Rows in this RowCollection.

If this RowCollection contains all rows from its database table, then we can do an internal sort.
 
Methods inherited from class planetj.database.RowCollection
add, add, addAll, addAll, addFDRows, addRow, addRowEventListener, addRows, addTable, batchProcess, clear, clearRows, clearTables, clone, cloneRowCollection, contains, contains, containsAll, containsRowWithFieldsEqualTo, copyToConnection, copyToConnection, copyToConnection, createFieldDescriptor, createRowCollection, delete, delete, delete, delete, doesFieldDescriptorExist, executeDistributedAction, filter, filter, filter, firstRow, get, getAttribute, getColumnCount, getColumnValues, getColumnValues, getColumnValuesByUsageId, getCompleteRowCollection, getCompleteRowCollection, getConfigProperty, getConnectedChildren, getContainedClass, getDistributedRequestorURL, getEstimatedSize, getExternalName, getExternalNames, getExternalNames, getFDFData, getFieldCount, getFieldDescriptor, getFieldDescriptorCollection, getFieldDescriptorCollection, getFieldDescriptors, getFieldDescriptorsWithUsage, getFieldDescriptorsWithUsageId, getFieldDescriptorWithUsageId, getFieldNames, getFieldNameSets, getFields, getFieldsToDisplay, getFieldsToDisplayStrict, getFieldsToDisplayStrict, getGraphableFieldNames, getJoinFieldNames, getLastUpdated, getLibraryName, getMetaDataSystemAlias, getNavigationKey, getNavigationListKey, getNextRowCollection, getNextRowCollection, getPreviousRowCollection, getPreviousRowCollection, getPropertyGroup, getPropertyGroups, getPropertyGroups, getResultSet, getRetrievedRowCount, getRow, getRowCount, getRows, getSortedColumnNames, getSortedColumnNamesAscending, getSQL, getSQLContext, getSum, getSystemAlias, getTable, getTableName, getTables, getTimestamp, getTitle, getValidationExceptions, getValueAsDouble, getValueAsDouble, getXMLData, getXMLData, getXMLHeaderData, getXMLHeaderData, handleDistributed, hasConnectedChildren, hasNextRowCollection, hasPreviousRowCollection, indexOf, indexOf, insert, insert, insert, insert, insertBatch, isARow, isARowCollection, isCloneNeeded, isCurrent, isEmpty, isFromCache, isFromGroupBy, isFromJoin, isGraphable, isHasColumnNames, isHasRowEventListners, isLocked, isOkToReturnMeFromCache, isRowCollectionContainEditableRow, isValidateRequired, iterator, lastIndexOf, listIterator, listIterator, newRow, newRow, prepareForDisplay, prepareForResults, prepareForReturnFromCache, prepareFromFieldNames, reconcile, reconcile, refresh, refreshIfNeeded, remove, remove, removeAll, removeAllRows, removeAttribute, removeNavigationKey, removeRow, removeRow, removeRowBasedOnKeyValues, removeRowEventListener, removeTable, replaceRow, retainAll, rollbackChanges, rowAltered, set, setAttribute, setColumnValues, setContainedClass, setDistributed, setDistributedRequestorURL, setDistributedSourceURL, setDistributedTargetURL, setLastUpdated, setNavigationKey, setPropertyGroups, setResultSet, setSortedColumnNames, setSql, setSystemAlias, setTable, setTables, setTables, size, sortInternal, subList, toArray, toArray, toCSV, toCSV, toDOC, toDOC, toFDF, toPDF, toString, toUpperCase, toXML, update, update, update, update, validate, validate, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

FilteredRowCollection

public FilteredRowCollection()
Method Detail

addRow

public void addRow(int index,
                   Row row)
Inserts the specified row at the specified position in this list (optional operation). Shifts the row currently at that position (if any) and any subsequent rows to the right (adds one to their indices). If there are any RowCollections connected to this one, then the Row is added to each of them as the *last* Row in the that RowCollection (if that RowCollection accepts it).

Overrides:
addRow in class RowCollection
Parameters:
index - index at which the specified row is to be inserted.
row - the row to be inserted.
Throws:
UnsupportedOperationException - if the add method is not supported by this list.
ClassCastException - if the class of the specified row prevents it from being added to this list.
IllegalArgumentException - if some aspect of the specified row prevents it from being added to this list.
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

disconnect

public void disconnect()
Disconnects this RowCollection from its parent. It cannot be reconnected.


getFilter

public IFilter getFilter()
Gets the filter used to create this FilteredRowCollection


getKey

public Object getKey()
Gets the filter used to create this FilteredRowCollection


getParent

public final RowCollection getParent()
Gets the RowCollection from which this FilteredRowCollection was created


getValue

public Object getValue()
Returns this same FilteredRowCollection


isConnected

public boolean isConnected()
Tests if this RowCollection is connected to its parent


refilter

public void refilter()
Clears this RowCollection and then reruns the filter, adding rows from the parent as appropriate


removeRow

public boolean removeRow(Row row)
Removes the row from this RowCollection. It is also removed from any connected RowCollections, but only if it originally existed in this RowCollection.

Overrides:
removeRow in class RowCollection
Parameters:
row - The row to remove.
Returns:
true if the Row was originally contained in this RowCollection, false otherwise

setFilter

public void setFilter(IFilter newFilter)
Sets the filter used to create this FilteredRowCollection. This method is an internal DataEngine method and should not be invoked by applications.


setParent

public void setParent(RowCollection newParent)
Sets the parent of this FilteredRowCollection. This method is an internal DataEngine method and should not be invoked by applications.


setRow

public Row setRow(int index,
                  Row row)

Replaces the row at the specified position in this list with the specified row, if the Row meets the filter criteria. This replacement is propigated to all connected RowCollections. If the Row doesen't meet the filter criteria, then the Row currently at the specified index is removed from this RowCollection; the removed Row will also be removed from all connected RowCollections and possibly replaced with the specified Row (depending on whether the connected RowCollections accept the specified Row).

Note that in the connected RowCollections, this replacement is keyed by the Row that was replaced, not the index of the replaced Row.

Overrides:
setRow in class RowCollection
Parameters:
index - index of row to replace.
row - the row to be stored at the specified position.
Returns:
the row previously at the specified position.
Throws:
UnsupportedOperationException - if the set method is not supported by this list.
ClassCastException - if the class of the specified row prevents it from being added to this list.
IllegalArgumentException - if some aspect of the specified row prevents it from being added to this list.
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

sort

public RowCollection sort(String[] pColumnNames,
                          String pSortOrder)
                   throws CMException
Sorts the Rows in this RowCollection.

If this RowCollection contains all rows from its database table, then we can do an internal sort. With an internal sort, there is no database communication. It's all done in memory.

If this RowCollection has (Next or Previous) more rows in the database to read, then this RowCollection's parent is sorted with its sort() method, and then that RowCollection is used to produce a new FilteredRowCollection to return (using this RowCollection's filter).

Overrides:
sort in class RowCollection
Parameters:
pColumnNames - String[] that represents the an array of column names in the order at which they should be sorted by (i.e. sort by pColumnName[0] then sort by pColumn[1] etc...)
pSortOrder - String constant either ASC or DESC for sorting in ascending or descending order
Returns:
This RowCollection after its rows have been sorted
CMException