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

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

public class EagerForeignCollection<T,ID>
extends BaseForeignCollection<T,ID>
implements ForeignCollection<T>

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).

Author:
graywatson

Field Summary
 
Fields inherited from class com.j256.ormlite.dao.BaseForeignCollection
dao, preparedQuery
 
Constructor Summary
EagerForeignCollection(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 contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 boolean equals(Object other)
           
 int hashCode()
           
 boolean isEmpty()
           
 CloseableIterator<T> iterator()
          Like Collection.iterator() but returns a closeable iterator instead.
 CloseableIterator<T> iteratorThrow()
          Like Collection.iterator() but returns a closeable iterator instead and can throw a SQLException.
 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.
 int size()
           
 Object[] toArray()
           
<E> E[]
toArray(E[] array)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EagerForeignCollection

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

iterator

public CloseableIterator<T> iterator()
Description copied from interface: ForeignCollection
Like Collection.iterator() but returns a closeable iterator instead. This may throw RuntimeException if there is any SQL exceptions unfortunately.

Specified by:
iterator in interface ForeignCollection<T>
Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Collection<T>

iteratorThrow

public CloseableIterator<T> iteratorThrow()
Description copied from interface: ForeignCollection
Like Collection.iterator() but returns a closeable iterator instead and can throw a SQLException.

Specified by:
iteratorThrow in interface ForeignCollection<T>

size

public int size()
Specified by:
size in interface Collection<T>

isEmpty

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

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<T>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<T>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<T>

toArray

public <E> E[] toArray(E[] array)
Specified by:
toArray in interface Collection<T>

add

public boolean add(T data)
Specified by:
add in interface Collection<T>
Overrides:
add in class BaseForeignCollection<T,ID>

addAll

public boolean addAll(Collection<? extends T> collection)
Specified by:
addAll in interface Collection<T>
Overrides:
addAll in class BaseForeignCollection<T,ID>

remove

public boolean remove(Object data)
Specified by:
remove in interface Collection<T>
Overrides:
remove in class BaseForeignCollection<T,ID>

removeAll

public boolean removeAll(Collection<?> collection)
Specified by:
removeAll in interface Collection<T>
Overrides:
removeAll in class BaseForeignCollection<T,ID>

retainAll

public boolean retainAll(Collection<?> collection)
Description copied from class: BaseForeignCollection
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>
Overrides:
retainAll in class BaseForeignCollection<T,ID>

clear

public void clear()
Description copied from class: BaseForeignCollection
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>
Overrides:
clear in class BaseForeignCollection<T,ID>

equals

public boolean equals(Object other)
Specified by:
equals in interface Collection<T>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<T>
Overrides:
hashCode in class Object


Copyright © 2011. All Rights Reserved.