com.bowstreet.builders.webapp.methods
Class BeanCollectionDataRetriever

java.lang.Object
  extended by com.bowstreet.builders.webapp.methods.BeanCollectionDataRetriever
All Implemented Interfaces:
CollectionDataRetriever, DataRetriever, WebAppAccessConsumer

public class BeanCollectionDataRetriever
extends java.lang.Object
implements CollectionDataRetriever, WebAppAccessConsumer

Helper class providing an implementation of the CollectionDataRetriever interface. Instances of this class can be used with the Paging Assistant builder to provide paged access to Collection-based data sources.


Constructor Summary
BeanCollectionDataRetriever(Method m)
          Create an instance of the class where the Collection is derived from the return value of a webApp method.
BeanCollectionDataRetriever(Variable v)
          Create an instance of the class where the Collection is derived from the content of a webApp Variable.
BeanCollectionDataRetriever(Variable ljo, java.lang.reflect.Method m)
          Create an instance of the class where the Collection is derived from the return value of method on an LJO.
 
Method Summary
 java.util.Collection getCollection(int startRow)
          Return a subset of the Collection managed by the class.
 Variable getCollectionVar()
           
 IXml getData(int startRow)
          Return rows starting at specified position.
 int getFetchSize()
          Indicate preferred chunk size for data retrieval.
 java.lang.Object getObj(int hashcode)
          Get an object from the Collection based upon its hash code.
static BeanCollectionDataRetriever getRetriever(WebAppAccess webAppAccess, java.lang.String reference)
          Utility Factory method method for the Beancrud Xmodel to instantiate a copy of this class by passing in an indirect reference that indicates where to obtain the Collection to be managed.
 int getRowCount()
          Return total number of rows in this data set.
 java.util.Collection getRowSubset(int start, int n)
          Return a subset of the Collection managed by the class.
 java.util.Collection getUpdatedCollection()
          Get an updated copy of the Collection managed by the class.
 void setWebAppAccess(WebAppAccess wa)
          Associate or disassociate a specific WebAppAccess instance with the object implementing this interface.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanCollectionDataRetriever

public BeanCollectionDataRetriever(Method m)
Create an instance of the class where the Collection is derived from the return value of a webApp method.

Parameters:
m - The webApp method to be invoked to obtain the Collection.

BeanCollectionDataRetriever

public BeanCollectionDataRetriever(Variable v)
Create an instance of the class where the Collection is derived from the content of a webApp Variable.

Parameters:
v - An instance of a webApp Variable that will contain a Collection at runtime.

BeanCollectionDataRetriever

public BeanCollectionDataRetriever(Variable ljo,
                                   java.lang.reflect.Method m)
Create an instance of the class where the Collection is derived from the return value of method on an LJO.

Parameters:
ljo - The webApp Variable that contains the LJO implementing the method that will return a Collection.
m - The reflective method instance to be invoked to obtain the Collection.
Method Detail

getCollection

public java.util.Collection getCollection(int startRow)
Return a subset of the Collection managed by the class.

Parameters:
startRow - The starting index of the Collection from which the subset is to be extracted. The index is zero-based and the subset contains all remaining rows in the Collection.
Returns:
A subset of the Collection or an empty non-null Collection if startRow is less than zero or startRow is greater than or equal to the number of items in the Collection.

getCollectionVar

public Variable getCollectionVar()

getData

public IXml getData(int startRow)
Description copied from interface: DataRetriever
Return rows starting at specified position. Number of rows should be equal to what getFetchSize would return.

Specified by:
getData in interface DataRetriever

getFetchSize

public int getFetchSize()
Description copied from interface: DataRetriever
Indicate preferred chunk size for data retrieval.

Specified by:
getFetchSize in interface DataRetriever

getObj

public java.lang.Object getObj(int hashcode)
Get an object from the Collection based upon its hash code.

Parameters:
hashcode - The hash code of the desired object.
Returns:
The first object in the Collection that matches the hash code or null if no object in the collection has the given hash code.

getRetriever

public static BeanCollectionDataRetriever getRetriever(WebAppAccess webAppAccess,
                                                       java.lang.String reference)
Utility Factory method method for the Beancrud Xmodel to instantiate a copy of this class by passing in an indirect reference that indicates where to obtain the Collection to be managed. This method only handles "${Variables/...}" and "${MethodCall/...}" indirect references.

Parameters:
webAppAccess - The webApp access instance for the current model.
reference - An indirect reference that indicates where to obtain the Collection to be managed.
Returns:
An instance of this class configured to obtain a Collection from either a webApp Variable, webApp method, or a method from an LJO.

getRowCount

public int getRowCount()
Description copied from interface: DataRetriever
Return total number of rows in this data set.

Specified by:
getRowCount in interface DataRetriever

getRowSubset

public java.util.Collection getRowSubset(int start,
                                         int n)
Description copied from interface: CollectionDataRetriever
Return a subset of the Collection managed by the class.

Specified by:
getRowSubset in interface CollectionDataRetriever
Parameters:
start - The starting index of the Collection from which the subset is to be extracted. The index is zero-based.
n - The number of consecutive items from the collection to be included in the subset.
Returns:
A subset of the Collection or an empty non-null Collection if start is less than zero, n is less than zero, or start is greater than or equal to the number of items in the Collection.

getUpdatedCollection

public java.util.Collection getUpdatedCollection()
Get an updated copy of the Collection managed by the class. The Collection will reflect any changes made to the content since the last time this method was called.

Returns:
A Collection with the latest content.

setWebAppAccess

public void setWebAppAccess(WebAppAccess wa)
Description copied from interface: WebAppAccessConsumer
Associate or disassociate a specific WebAppAccess instance with the object implementing this interface. This WebAppAccess instance is only valid until the client calls this method again with a null WebAppAccess value.

Specified by:
setWebAppAccess in interface WebAppAccessConsumer
Parameters:
wa - The WebAppAccess instance to be used by other methods in the class implementing this interface.


Copyright © 2009 IBM. All Rights Reserved.