public class StreamsMetaObjectMapIterator extends AbstractStreamObjectIterator<MetaObjectMap>
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
StreamsMetaObjectMapIterator()
The empty constructor.
|
Modifier and Type | Method and Description |
---|---|
<T extends LocalAbstractObject> |
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.
|
void |
setConstructorParameterFromString(int index,
java.lang.String paramValue,
java.util.Map<java.lang.String,java.lang.Object> namedInstances)
Sets the value of this stream's object constructor argument from a string value.
|
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.
|
emptyIterator, getIterator, getMatchingObjects, getMatchingObjects, getMatchingObjects, getMatchingObjects, getObjectByAnyLocator, getObjectByData, getObjectByLocator, getObjectByLocator, getObjectByLocatorRegexp, getObjectByPosition, getRandomObject, getRandomObjects, provideObjects, singleton, skip
protected java.util.Map<java.lang.String,StreamGenericAbstractObjectIterator<?>> subObjectIterators
protected MetaObjectMap nextObject
protected MetaObjectMap currentObject
protected boolean readingStarted
public StreamsMetaObjectMapIterator()
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 iteratorjava.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 storedjava.lang.IllegalArgumentException
- if the provided class does not have a proper "stream" constructorjava.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 locatorjava.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 locatorjava.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
AbstractStreamObjectIterator
constructorArgs
.setConstructorParameter
in class AbstractStreamObjectIterator<MetaObjectMap>
index
- the parameter index to change (zero-based)paramValue
- the changed value to pass to the constructorjava.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 parameterpublic void setConstructorParameterFromString(int index, java.lang.String paramValue, java.util.Map<java.lang.String,java.lang.Object> namedInstances) throws java.lang.IndexOutOfBoundsException, java.lang.InstantiationException
AbstractStreamObjectIterator
constructorArgs
.setConstructorParameterFromString
in class AbstractStreamObjectIterator<MetaObjectMap>
index
- the parameter index to change (zero-based)paramValue
- the changed value to pass to the constructornamedInstances
- map of named instances for the Convert.stringToType(java.lang.String, java.lang.Class<E>, java.util.Map<java.lang.String, ? extends java.lang.Object>)
conversionjava.lang.IndexOutOfBoundsException
- if the index parameter is out of boundsjava.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