com.avaje.ebean.common
Class AbstractBeanCollection<E>

java.lang.Object
  extended by com.avaje.ebean.common.AbstractBeanCollection<E>
All Implemented Interfaces:
BeanCollection<E>, Serializable
Direct Known Subclasses:
BeanList, BeanMap, BeanSet

public abstract class AbstractBeanCollection<E>
extends Object
implements BeanCollection<E>

Base class for List Set and Map implementations of BeanCollection.

Author:
rbygrave
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.avaje.ebean.bean.BeanCollection
BeanCollection.ModifyListenMode
 
Field Summary
 
Fields inherited from interface com.avaje.ebean.bean.BeanCollection
DEFAULT, READONLY, SHARED
 
Constructor Summary
AbstractBeanCollection()
          Constructor not non-lazy loading collection.
AbstractBeanCollection(BeanCollectionLoader loader, Object ownerBean, String propertyName)
          Used to create deferred fetch proxy.
 
Method Summary
 void backgroundFetchWait()
          Wait for the fetch to complete.
 void backgroundFetchWait(long wait, TimeUnit timeUnit)
          Wait for the fetch to complete with a given timeout.
 ExpressionList<?> getFilterMany()
          Return the filter (if any) that was used in building this collection.
 int getLoaderIndex()
          Return the index position of this collection in the lazy/query loader.
 Set<E> getModifyAdditions()
          Return the list of objects added to the list set or map.
 Set<E> getModifyRemovals()
          Return the list of objects removed from the list set or map.
 Object getOwnerBean()
          Return the bean that owns this collection.
 String getPropertyName()
          Return the bean property name this collection represents.
 boolean hasMoreRows()
          Set to true if maxRows was hit and there are actually more rows available.
 boolean isFinishedFetch()
          Returns true if the fetch has finished.
 boolean isReadOnly()
          Return true if the collection should be treated as readOnly and no elements can be added or removed etc.
 boolean isSharedInstance()
          Return true if this collection is owned by a sharedInstance.
 void modifyAddition(E bean)
          Add an object to the additions list.
 void modifyRemoval(Object bean)
          Add an object to the deletions list.
 void modifyReset()
          Reset the set of additions and deletions.
 void setBackgroundFetch(Future<Integer> fetchFuture)
          Set when this collection is being loaded via a background thread.
 void setBeanCollectionTouched(BeanCollectionTouched notify)
          Set a listener to be notified when the BeanCollection is first touched.
 void setFilterMany(ExpressionList<?> filterMany)
          Set the filter that was used in building this collection.
 void setFinishedFetch(boolean finishedFetch)
          Set to true when a fetch has finished.
 void setHasMoreRows(boolean hasMoreRows)
          Set to true when maxRows is hit but there are actually more rows available.
 void setLoader(int beanLoaderIndex, BeanCollectionLoader loader)
          Set the loader that will be used to lazy/query load this collection.
 void setModifyListening(BeanCollection.ModifyListenMode mode)
          set modifyListening to be on or off.
 void setReadOnly(boolean readOnly)
          Set to true if you want the BeanCollection to be treated as read only.
 void setSharedInstance()
          Set when this collection is owned by a sharedInstance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.avaje.ebean.bean.BeanCollection
checkEmptyLazyLoad, getActualCollection, getActualDetails, internalAdd, isEmpty, isPopulated, size
 

Constructor Detail

AbstractBeanCollection

public AbstractBeanCollection()
Constructor not non-lazy loading collection.


AbstractBeanCollection

public AbstractBeanCollection(BeanCollectionLoader loader,
                              Object ownerBean,
                              String propertyName)
Used to create deferred fetch proxy.

Method Detail

getOwnerBean

public Object getOwnerBean()
Description copied from interface: BeanCollection
Return the bean that owns this collection.

Specified by:
getOwnerBean in interface BeanCollection<E>

getPropertyName

public String getPropertyName()
Description copied from interface: BeanCollection
Return the bean property name this collection represents.

Specified by:
getPropertyName in interface BeanCollection<E>

getLoaderIndex

public int getLoaderIndex()
Description copied from interface: BeanCollection
Return the index position of this collection in the lazy/query loader.

Used for batch loading of collections.

Specified by:
getLoaderIndex in interface BeanCollection<E>

getFilterMany

public ExpressionList<?> getFilterMany()
Description copied from interface: BeanCollection
Return the filter (if any) that was used in building this collection.

This is so that the filter can be applied on refresh.

Specified by:
getFilterMany in interface BeanCollection<E>

setFilterMany

public void setFilterMany(ExpressionList<?> filterMany)
Description copied from interface: BeanCollection
Set the filter that was used in building this collection.

Specified by:
setFilterMany in interface BeanCollection<E>

setBeanCollectionTouched

public void setBeanCollectionTouched(BeanCollectionTouched notify)
Description copied from interface: BeanCollection
Set a listener to be notified when the BeanCollection is first touched.

Specified by:
setBeanCollectionTouched in interface BeanCollection<E>

setLoader

public void setLoader(int beanLoaderIndex,
                      BeanCollectionLoader loader)
Description copied from interface: BeanCollection
Set the loader that will be used to lazy/query load this collection.

Specified by:
setLoader in interface BeanCollection<E>

isSharedInstance

public boolean isSharedInstance()
Description copied from interface: BeanCollection
Return true if this collection is owned by a sharedInstance.

That is, return true if it is a Many property of a bean in the cache.

Specified by:
isSharedInstance in interface BeanCollection<E>

setSharedInstance

public void setSharedInstance()
Description copied from interface: BeanCollection
Set when this collection is owned by a sharedInstance.

That is, it is a Many property on a bean in the cache.

Specified by:
setSharedInstance in interface BeanCollection<E>

isReadOnly

public boolean isReadOnly()
Description copied from interface: BeanCollection
Return true if the collection should be treated as readOnly and no elements can be added or removed etc.

Specified by:
isReadOnly in interface BeanCollection<E>

setReadOnly

public void setReadOnly(boolean readOnly)
Description copied from interface: BeanCollection
Set to true if you want the BeanCollection to be treated as read only. This means no elements can be added or removed etc.

Specified by:
setReadOnly in interface BeanCollection<E>

hasMoreRows

public boolean hasMoreRows()
Set to true if maxRows was hit and there are actually more rows available.

Can be used by client code that is paging through results using setFirstRow() setMaxRows(). If this returns true then the client can display a 'next' button etc.

Specified by:
hasMoreRows in interface BeanCollection<E>

setHasMoreRows

public void setHasMoreRows(boolean hasMoreRows)
Set to true when maxRows is hit but there are actually more rows available. This is set so that client code knows that there is more data available.

Specified by:
setHasMoreRows in interface BeanCollection<E>

isFinishedFetch

public boolean isFinishedFetch()
Returns true if the fetch has finished. False if the fetch is continuing in a background thread.

Specified by:
isFinishedFetch in interface BeanCollection<E>

setFinishedFetch

public void setFinishedFetch(boolean finishedFetch)
Set to true when a fetch has finished. Used when a fetch continues in the background.

Specified by:
setFinishedFetch in interface BeanCollection<E>

setBackgroundFetch

public void setBackgroundFetch(Future<Integer> fetchFuture)
Description copied from interface: BeanCollection
Set when this collection is being loaded via a background thread.

Refer to Query.setBackgroundFetchAfter(int)

Specified by:
setBackgroundFetch in interface BeanCollection<E>

backgroundFetchWait

public void backgroundFetchWait(long wait,
                                TimeUnit timeUnit)
Description copied from interface: BeanCollection
Wait for the fetch to complete with a given timeout.

Refer to Query.setBackgroundFetchAfter(int)

Specified by:
backgroundFetchWait in interface BeanCollection<E>

backgroundFetchWait

public void backgroundFetchWait()
Description copied from interface: BeanCollection
Wait for the fetch to complete.

Refer to Query.setBackgroundFetchAfter(int)

Specified by:
backgroundFetchWait in interface BeanCollection<E>

setModifyListening

public void setModifyListening(BeanCollection.ModifyListenMode mode)
set modifyListening to be on or off.

Specified by:
setModifyListening in interface BeanCollection<E>

modifyAddition

public void modifyAddition(E bean)
Description copied from interface: BeanCollection
Add an object to the additions list.

This will potentially end up as an insert into a intersection table for a ManyToMany.

Specified by:
modifyAddition in interface BeanCollection<E>

modifyRemoval

public void modifyRemoval(Object bean)
Description copied from interface: BeanCollection
Add an object to the deletions list.

This will potentially end up as an delete from an intersection table for a ManyToMany.

Specified by:
modifyRemoval in interface BeanCollection<E>

modifyReset

public void modifyReset()
Description copied from interface: BeanCollection
Reset the set of additions and deletions. This is called after the additions and removals have been processed.

Specified by:
modifyReset in interface BeanCollection<E>

getModifyAdditions

public Set<E> getModifyAdditions()
Description copied from interface: BeanCollection
Return the list of objects added to the list set or map. These will used to insert rows into the intersection table of a ManyToMany.

Specified by:
getModifyAdditions in interface BeanCollection<E>

getModifyRemovals

public Set<E> getModifyRemovals()
Description copied from interface: BeanCollection
Return the list of objects removed from the list set or map. These will used to delete rows from the intersection table of a ManyToMany.

Specified by:
getModifyRemovals in interface BeanCollection<E>


Copyright © 2010. All Rights Reserved.