Package org.intermine.objectstore.proxy
Class ProxyCollection<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- org.intermine.objectstore.proxy.ProxyCollection<E>
-
- Type Parameters:
E
- The element type
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Set<E>
,Lazy
,LazyCollection<E>
public class ProxyCollection<E> extends java.util.AbstractSet<E> implements LazyCollection<E>
Class which holds a reference to a collection in the database- Author:
- Matthew Wakeling
-
-
Constructor Summary
Constructors Constructor Description ProxyCollection(ObjectStore os, InterMineObject o, java.lang.String fieldName, java.lang.Class<? extends E> clazz)
Construct a ProxyCollection object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<E>
asList()
Return this Collection as a List.ResultsInfo
getInfo()
Returns Returns the current best estimate of the characteristics of the LazyCollectionjava.util.Collection<E>
getMaterialisedCollection()
Gets the collection if it is a real materialised collection.ObjectStore
getObjectStore()
Returns the ObjectStore that this proxy will useQuery
getQuery()
Returns the Query used by this LazyCollectionjava.util.Iterator<E>
iterator()
void
setBatchSize(int size)
Sets the number of rows requested from the ObjectStore whenever an execute call is madevoid
setMaterialisedCollection(java.util.Collection<E> coll)
Sets the collection with a new materialised collection.void
setNoExplain()
Sets this LazyCollection to bypass the explain check in ObjectStore.execute().void
setNoOptimise()
Sets this LazyCollection to bypass the optimiserint
size()
Gets the number of elements in this collectionjava.lang.String
toString()
We override this here in order to prevent possible infinite recursion.-
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray
-
-
-
-
Constructor Detail
-
ProxyCollection
public ProxyCollection(ObjectStore os, InterMineObject o, java.lang.String fieldName, java.lang.Class<? extends E> clazz)
Construct a ProxyCollection object.- Parameters:
os
- the ObjectStore from which to retrieve the collectiono
- the object containing the collectionfieldName
- the name of the collectionclazz
- the Class of the objects in the collection
-
-
Method Detail
-
getObjectStore
public ObjectStore getObjectStore()
Returns the ObjectStore that this proxy will use- Specified by:
getObjectStore
in interfaceLazy
- Returns:
- an ObjectStore
-
size
public int size()
Gets the number of elements in this collection
-
iterator
public java.util.Iterator<E> iterator()
-
getQuery
public Query getQuery()
Returns the Query used by this LazyCollection- Specified by:
getQuery
in interfaceLazyCollection<E>
- Returns:
- a Query
-
getInfo
public ResultsInfo getInfo() throws ObjectStoreException
Returns Returns the current best estimate of the characteristics of the LazyCollection- Specified by:
getInfo
in interfaceLazyCollection<E>
- Returns:
- a ResultsInfo object
- Throws:
ObjectStoreException
- if an error occurs in the underlying ObjectStore
-
setNoOptimise
public void setNoOptimise()
Sets this LazyCollection to bypass the optimiser- Specified by:
setNoOptimise
in interfaceLazyCollection<E>
-
setNoExplain
public void setNoExplain()
Sets this LazyCollection to bypass the explain check in ObjectStore.execute().- Specified by:
setNoExplain
in interfaceLazyCollection<E>
-
setBatchSize
public void setBatchSize(int size)
Sets the number of rows requested from the ObjectStore whenever an execute call is made- Specified by:
setBatchSize
in interfaceLazyCollection<E>
- Parameters:
size
- the number of rows
-
asList
public java.util.List<E> asList()
Return this Collection as a List. This may create a new ArrayList if necessary so the returned List is not guaranteed to be consistent if the LazyCollection changes.- Specified by:
asList
in interfaceLazyCollection<E>
- Returns:
- a List
-
getMaterialisedCollection
public java.util.Collection<E> getMaterialisedCollection()
Gets the collection if it is a real materialised collection.- Returns:
- a Collection
-
setMaterialisedCollection
public void setMaterialisedCollection(java.util.Collection<E> coll)
Sets the collection with a new materialised collection.- Parameters:
coll
- the new Collection
-
toString
public java.lang.String toString()
We override this here in order to prevent possible infinite recursion.- Overrides:
toString
in classjava.util.AbstractCollection<E>
-
-