|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.objects.util.AbstractObjectIterator<E>
messif.objects.util.AbstractStreamObjectIterator<MetaObjectMap>
messif.objects.util.StreamsMetaObjectMapIterator
public class StreamsMetaObjectMapIterator
This class is to contruct MetaObjects from several simultaneously opened files (subObjectIterators). The iterator expects the files to store corresponding objects always in the same order alowing gaps - locators are always checked for actually "first" objects in the opened subObjectIterators. If more than one locator is at the top of the subObjectIterators, the majority of them is expected to be the right locator to be created at the moment and the other are not created.
Field Summary | |
---|---|
protected MetaObjectMap |
currentObject
Instance of the current object |
protected MetaObjectMap |
nextObject
Instance of a next object. |
protected boolean |
readingStarted
Flag saying whether we have already started reading from the files or not yet. |
protected java.util.Map<java.lang.String,StreamGenericAbstractObjectIterator> |
subObjectIterators
Particular iterators |
Constructor Summary | |
---|---|
StreamsMetaObjectMapIterator()
The empty constructor. |
Method Summary | ||
---|---|---|
|
addObjectStream(java.lang.String name,
java.lang.Class<? extends T> objClass,
java.lang.String fileName)
Add new object iterator given a name to be generated for this object in the MetaObjectMap. |
|
void |
addObjectStream(java.lang.String name,
StreamGenericAbstractObjectIterator<? extends LocalAbstractObject> iterator)
Add new object iterator given a name to be generated for this object in the MetaObjectMap. |
|
void |
close()
|
|
MetaObjectMap |
getCurrentObject()
Returns an object returned by the last call to Iterator.next() . |
|
boolean |
hasNext()
|
|
MetaObjectMap |
next()
|
|
void |
remove()
|
|
void |
reset()
Reset the associated stream and restarts the iteration from beginning. |
|
void |
setConstructorParameter(int index,
java.lang.Object paramValue)
Sets the value of this stream's object constructor argument. |
|
protected void |
setNextObject()
Internal method to read objects from the strems and construct new metaobject and set the new object to nextObject . |
|
void |
startReadingObjects()
This method is internaly used to mark that the reading from the subObjectIterators started. |
Methods inherited from class messif.objects.util.AbstractObjectIterator |
---|
getCurrentObjectID, getMatchingObjects, getMatchingObjects, getMatchingObjects, getMatchingObjects, getObjectByAnyLocator, getObjectByData, getObjectByID, getObjectByLocator, getObjectByPosition, getRandomObject, getRandomObjects, nextObjectID, provideObjects |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Map<java.lang.String,StreamGenericAbstractObjectIterator> subObjectIterators
protected MetaObjectMap nextObject
protected MetaObjectMap currentObject
protected boolean readingStarted
Constructor Detail |
---|
public StreamsMetaObjectMapIterator()
Method Detail |
---|
public void addObjectStream(java.lang.String name, StreamGenericAbstractObjectIterator<? extends LocalAbstractObject> iterator) throws java.lang.IllegalStateException
name
- name to be generated for this object in the MetaObjectMapiterator
- object iterator
java.lang.IllegalStateException
- when trying to add a stream and reading from the other subObjectIterators already startedpublic <T extends LocalAbstractObject> void addObjectStream(java.lang.String name, java.lang.Class<? extends T> objClass, java.lang.String fileName) throws java.lang.IllegalArgumentException, java.io.IOException
T
- the type of the objects that are created from the filename
- name to be generated for this object in the MetaObjectMapobjClass
- the type of the objects that are created from the filefileName
- file where the objects are stored
java.lang.IllegalArgumentException
- if the provided class does not have a proper "stream" constructor
java.io.IOException
- if there was an error opening the filepublic MetaObjectMap getCurrentObject() throws java.util.NoSuchElementException
AbstractObjectIterator
Iterator.next()
.
getCurrentObject
in class AbstractObjectIterator<MetaObjectMap>
Iterator.next()
java.util.NoSuchElementException
- if Iterator.next()
has not been called yetpublic boolean hasNext()
public MetaObjectMap next()
public void remove()
public void close() throws java.io.IOException
java.io.IOException
public void startReadingObjects() throws java.lang.IllegalStateException, java.io.IOException
java.lang.IllegalStateException
- if there is a gap in the files and there are two candidates for the next locator
java.io.IOException
- error while closing stream iterator that reached its endprotected void setNextObject() throws java.lang.IllegalStateException, java.io.IOException
nextObject
.
java.lang.IllegalStateException
- if there is a gap in the files and there are two candidates for the next locator
java.io.IOException
- error while closing stream iterator that reached its endpublic void setConstructorParameter(int index, java.lang.Object paramValue) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalArgumentException, java.lang.InstantiationException
AbstractStreamObjectIterator
constructorArgs
.
setConstructorParameter
in class AbstractStreamObjectIterator<MetaObjectMap>
index
- the parameter index to change (zero-based)paramValue
- the changed value to pass to the constructor
java.lang.IndexOutOfBoundsException
- if the index parameter is out of bounds (zero parameter cannot be changed)
java.lang.IllegalArgumentException
- when the passed object is incompatible with the constructor's parameter
java.lang.InstantiationException
- if the value passed is string that is not convertible to the constructor classpublic void reset() throws java.io.IOException
AbstractStreamObjectIterator
reset
in class AbstractStreamObjectIterator<MetaObjectMap>
java.io.IOException
- if there was an I/O error re-opening the file
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |