net.sourceforge.floggy.persistence
Interface ObjectSet

All Known Subinterfaces:
PolymorphicObjectSet, SingleObjectSet

public interface ObjectSet

An interface representing a search result. The ObjectSet logically maintains a sequence of the object's IDs. It is possible to iterate over all objects (or a subset, if an optional object filter has been supplied) using the get(int index) method.

PersistableManager manager = PersistableManager.getInstance();
ObjectSet os = manager.find(Customer.class, null, null);
for(int i = 0; i < os.size(); i++) {
  Customer customer = (Customer) os.get(i);
  ...
}


By using an optional Filter, only the objects that matches the provided filter will be avaiable in this set.

By using an optional Comparator, the order of the objects in this set will be determined by the comparator.

Since:
1.0
See Also:
PersistableManager.find(Class, Filter, Comparator), Filter, Comparator

Method Summary
 Persistable get(int index)
          Load the object at the specified index.
 Persistable getSharedInstance(int index)
          Returns the object at the specified index.
 boolean isLazy()
          Gets the lazy property.
 void setLazy(boolean lazy)
          Sets the lazy property.
 int size()
          Returns the number of objects in this set.
 

Method Detail

get

Persistable get(int index)
                throws FloggyException
Load the object at the specified index. A new instance will be created to each invocation of this method.

Parameters:
index - Index of the object to be loaded.
Returns:
The object at the specified position in the set.
Throws:
FloggyException - Exception thrown if a persistence error occurs.

getSharedInstance

Persistable getSharedInstance(int index)
                              throws FloggyException
Returns the object at the specified index. The object returned is a instance shared by the ObjectSet. Use it with caution because the reference of the object don't change across multiple invocation of the getSharedInstance method only the value of the fields change.

Parameters:
index - Index of the object to return.
Returns:
The shared object at the specified position in the set.
Throws:
FloggyException - Exception thrown if a persistence error occurs.
Since:
1.4.0

isLazy

boolean isLazy()
Gets the lazy property.

Returns:
The flag indicating the the type of fetch made by the PersistableManager.load method.

setLazy

void setLazy(boolean lazy)
Sets the lazy property.

Parameters:
lazy - DOCUMENT ME!

size

int size()
Returns the number of objects in this set.

Returns:
The number of objects in this set.


Copyright © 2006-2011 Floggy Open Source Group. All Rights Reserved.