|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.objects.util.AbstractObjectIterator<E>
E
- the class of the iterated objectspublic abstract class AbstractObjectIterator<E extends AbstractObject>
Implementation of an iterator over a collection of abstract objects
.
It provides methods for getting objects by their position, ID, data-equality, locator or
ObjectMatcher
.
All methods are implemented in a "stream" fashion, i.e.
only the Iterator.next()
method is used to accomplish all the getting methods.
Note that iterator cannot go back, so for example the get-by-id
method will only find the object if it has not been skipped in the iterator before.
Constructor Summary | |
---|---|
AbstractObjectIterator()
|
Method Summary | |
---|---|
abstract E |
getCurrentObject()
Returns an object returned by the last call to Iterator.next() . |
UniqueID |
getCurrentObjectID()
Returns an ID of the object returned by the last call to Iterator.next() . |
GenericMatchingObjectList<E> |
getMatchingObjects(ObjectMatcher<? super E> matcher)
Returns matching objects. |
GenericMatchingObjectList<E> |
getMatchingObjects(ObjectMatcher<? super E> matcher,
boolean removeMatching)
Returns matching objects. |
GenericMatchingObjectList<E> |
getMatchingObjects(ObjectMatcher<? super E> matcher,
boolean removeMatching,
int whoStays)
Returns matching objects. |
GenericMatchingObjectList<E> |
getMatchingObjects(ObjectMatcher<? super E> matcher,
boolean removeMatching,
int[] whoStays)
Get matching objects Method returns all objects that satisfy the matching contraints specified by matcher and deletes matching objects from the bucket when required. |
E |
getObjectByAnyLocator(java.util.Set<java.lang.String> locatorURIs,
boolean removeFound)
Returns the first instance of object, that has one of the specified locators. |
E |
getObjectByData(LocalAbstractObject object)
Returns the first instance of object, that has data equal to the provided object. |
E |
getObjectByID(UniqueID objectID)
Returns the first instance of object, that has the specified ID. |
E |
getObjectByLocator(java.lang.String locatorURI)
Returns the first instance of object, that has the specified locator. |
E |
getObjectByPosition(int position)
Returns an instance of object on the position of position from the current object. |
E |
getRandomObject()
Returns a randomly choosen object from the objects remaining in this iterator. |
AbstractObjectList<E> |
getRandomObjects(int count,
boolean unique)
Returns a list containing randomly choosen objects from the objects remaining in this iterator. |
UniqueID |
nextObjectID()
Returns an ID of the object returned by a call to Iterator.next() . |
AbstractObjectIterator<E> |
provideObjects()
Returns an iterator over the provided objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Iterator |
---|
hasNext, next, remove |
Constructor Detail |
---|
public AbstractObjectIterator()
Method Detail |
---|
public abstract E getCurrentObject() throws java.util.NoSuchElementException
Iterator.next()
.
Iterator.next()
java.util.NoSuchElementException
- if Iterator.next()
has not been called yetpublic UniqueID getCurrentObjectID() throws java.util.NoSuchElementException
Iterator.next()
.
Iterator.next()
.
java.util.NoSuchElementException
- if next() has not been called yet.public UniqueID nextObjectID()
Iterator.next()
.
That is, the next object is obtained from the iterator via Iterator.next()
and its ID
is returned.
Iterator.next()
public E getObjectByPosition(int position) throws java.util.NoSuchElementException
position
from the current object.
Specifically, next() is called position
times and then the current object is returned.
That is, position 0 means current object, 1 means the next object, etc.
position
- the position from the current object
position
from the current object
java.util.NoSuchElementException
- if such an object cannot be found.public E getObjectByID(UniqueID objectID) throws java.util.NoSuchElementException
objectID
- ID of the object that we are searching for
java.util.NoSuchElementException
- if such an object cannot be found.public E getObjectByData(LocalAbstractObject object) throws java.util.NoSuchElementException
object
- the object to match the data against
java.util.NoSuchElementException
- if such an object cannot be found.public final E getObjectByLocator(java.lang.String locatorURI) throws java.util.NoSuchElementException
locatorURI
- the locator of the object that we are searching for
java.util.NoSuchElementException
- if there is no object with the specified locatorpublic E getObjectByAnyLocator(java.util.Set<java.lang.String> locatorURIs, boolean removeFound) throws java.util.NoSuchElementException
locatorURIs
- the set of locators that we are searching forremoveFound
- if true the locators which were found are removed from the locatorURIs set, otherwise, locatorURIs is not touched
java.util.NoSuchElementException
- if there is no object with any of the specified locatorspublic E getRandomObject() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if this iterator has no objects leftpublic AbstractObjectList<E> getRandomObjects(int count, boolean unique)
count
- the number of objects to returnunique
- flag if the returned list contains each object only once
AbstractObjectList.randomList(int, boolean, java.util.List, java.util.Iterator)
public AbstractObjectIterator<E> provideObjects()
provided
objects.
This implementation of the ObjectProvider
interface returns itself as an iterator.
provideObjects
in interface ObjectProvider<E extends AbstractObject>
provided
objectspublic GenericMatchingObjectList<E> getMatchingObjects(ObjectMatcher<? super E> matcher) throws java.util.NoSuchElementException, OccupationLowException, FilterRejectException
ObjectMatcher.match(T)
method in the matcher returns non-zero when applied on them.
matcher
- The matching condition implemented in the ObjectMatcher interface.
java.util.NoSuchElementException
- if deletion reported it or if this method is called after next was called.
FilterRejectException
- if delettion of a matching object was rejected by a filter (in case this is an iterator of LocalFilteredBucket).
OccupationLowException
- if deletion of matching objects caused too low an occupation of bucket than allowed.public GenericMatchingObjectList<E> getMatchingObjects(ObjectMatcher<? super E> matcher, boolean removeMatching) throws java.util.NoSuchElementException, OccupationLowException, FilterRejectException
ObjectMatcher.match(T)
method in the matcher returns non-zero when applied on them)
and deletes matching objects from the bucket when required.
matcher
- The matching condition implemented in the ObjectMatcher interface.removeMatching
- Matching objects are also deleted from the bucket.
java.util.NoSuchElementException
- if deletion reported it or if this method is called after next was called.
FilterRejectException
- if delettion of a matching object was rejected by a filter (in case this is an iterator of LocalFilteredBucket).
OccupationLowException
- if deletion of matching objects caused too low an occupation of bucket than allowed.public GenericMatchingObjectList<E> getMatchingObjects(ObjectMatcher<? super E> matcher, boolean removeMatching, int whoStays) throws java.util.NoSuchElementException, OccupationLowException, FilterRejectException
ObjectMatcher.match(T)
returns value different from whoStays.
matcher
- The matching condition implemented in the ObjectMatcher interface.removeMatching
- Matching objects are also deleted from the bucket.whoStays
- Identification of a partition whose objects stay in this bucket.
ObjectMatcher.match(T)
is not equal
to whoStays
when applied on them)
java.util.NoSuchElementException
- if deletion reported it or if this method is called after next was called.
FilterRejectException
- if delettion of a matching object was rejected by a filter (in case this is an iterator of LocalFilteredBucket).
OccupationLowException
- if deletion of matching objects caused too low an occupation of bucket than allowed.public GenericMatchingObjectList<E> getMatchingObjects(ObjectMatcher<? super E> matcher, boolean removeMatching, int[] whoStays) throws java.util.NoSuchElementException, OccupationLowException, FilterRejectException
matcher
- The matching condition implemented in the ObjectMatcher interface.removeMatching
- Matching objects are also deleted from the bucket.whoStays
- An array of identifications of partitions whose objects stay in this bucket.
java.util.NoSuchElementException
- if deletion reported it or if this method is called after next was called.
FilterRejectException
- if delettion of a matching object was rejected by a filter (in case this is an iterator of LocalFilteredBucket).
OccupationLowException
- if deletion of matching objects caused too low an occupation of bucket than allowed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |