com.j256.ormlite.dao
Class BaseForeignCollection<T,ID>

java.lang.Object
  extended by com.j256.ormlite.dao.BaseForeignCollection<T,ID>
All Implemented Interfaces:
ForeignCollection<T>, Iterable<T>, Collection<T>
Direct Known Subclasses:
EagerForeignCollection, LazyForeignCollection

public abstract class BaseForeignCollection<T,ID>
extends Object
implements ForeignCollection<T>

Base collection that is set on a field that as been marked with the ForeignCollectionField annotation when an object is refreshed or queried (i.e. not created).

WARNING: Most likely for(;;) loops should not be used here since we need to be careful about closing the iterator.

Author:
graywatson

Field Summary
protected  Dao<T,ID> dao
           
protected  PreparedQuery<T> preparedQuery
           
 
Constructor Summary
BaseForeignCollection(Dao<T,ID> dao, String fieldName, Object fieldValue)
           
 
Method Summary
 boolean add(T data)
           
 boolean addAll(Collection<? extends T> collection)
           
 void clear()
          Uses the iterator to run through the dao and delete all of the items.
 boolean remove(Object data)
           
 boolean removeAll(Collection<?> collection)
           
 boolean retainAll(Collection<?> collection)
          Uses the iterator to run through the dao and retain only the items that are in the passed in collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.j256.ormlite.dao.ForeignCollection
iterator, iteratorThrow
 
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, size, toArray, toArray
 

Field Detail

dao

protected final Dao<T,ID> dao

preparedQuery

protected PreparedQuery<T> preparedQuery
Constructor Detail

BaseForeignCollection

public BaseForeignCollection(Dao<T,ID> dao,
                             String fieldName,
                             Object fieldValue)
                      throws SQLException
Throws:
SQLException
Method Detail

add

public boolean add(T data)
Specified by:
add in interface Collection<T>

addAll

public boolean addAll(Collection<? extends T> collection)
Specified by:
addAll in interface Collection<T>

remove

public boolean remove(Object data)
Specified by:
remove in interface Collection<T>

removeAll

public boolean removeAll(Collection<?> collection)
Specified by:
removeAll in interface Collection<T>

retainAll

public boolean retainAll(Collection<?> collection)
Uses the iterator to run through the dao and retain only the items that are in the passed in collection.

Specified by:
retainAll in interface Collection<T>

clear

public void clear()
Uses the iterator to run through the dao and delete all of the items. This is different from removing all of the elements in the table since this iterator is across just one item's foreign objects.

Specified by:
clear in interface Collection<T>


Copyright © 2011. All Rights Reserved.