Package PamguardMVC
Class PamDataUnitIterator<E extends PamDataUnit>
java.lang.Object
PamguardMVC.PamDataUnitIterator<E>
- Type Parameters:
 E-
- All Implemented Interfaces:
 Iterator<E>,ListIterator<E>
- Direct Known Subclasses:
 ChannelIterator,SequenceIterator
public abstract class PamDataUnitIterator<E extends PamDataUnit>
extends Object
implements ListIterator<E>
An iterator that has a bit more functionality than a basic iterator. 
It's main enhancement is to use a channel map match to PamDataUnits, so that it only returns data units that have an overlap in channels with the given channel map (which could be 0xFFFFFFFF).
It also has a couple of extra searches to getPreceeding() and getFollowing() data units.
It's main enhancement is to use a channel map match to PamDataUnits, so that it only returns data units that have an overlap in channels with the given channel map (which could be 0xFFFFFFFF).
It also has a couple of extra searches to getPreceeding() and getFollowing() data units.
- Author:
 - Doug Gillespie
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected longprotected longprotected longprotected ListIterator<E> protected PamDataBlock<E> protected Object - 
Constructor Summary
ConstructorsConstructorDescriptionPamDataUnitIterator(PamDataBlock<E> pamDataBlock, int chanOrSeqMap, int whereFrom) An iterator that has a bit more functionality than a basic iterator. - 
Method Summary
Modifier and TypeMethodDescriptionvoidintReturn the channel or sequence map specified during object instantiationgetClosest(long timeMilliseconds, boolean firstOrlastOk) Get the unit closest to the given time.abstract EgetFirstUnit(int chanOrSeqMap) Get the first unit for a specific channel or sequence map (any match of channels allowed).getFollowing(long timeMilliseconds, boolean lastOk) Get the unit immediately following or at the given time.abstract EgetLastUnit(int chanOrSeqMap) Get the last unit for a specific channel or sequence map (any match of channels allowed).getPreceding(long timeMilliseconds, boolean firstOk) Get the unit immediately before or at the given time.booleanhasNext()booleanabstract Enext()Return the next PamDataUnit, or null if there is no 'next' PamDataUnitintabstract Eprevious()Return the previous PamDataUnit, or null if there is no 'previous' PamDataUnitintvoidremove()voidvoidsetSynchObject(Object synchObject) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining 
- 
Field Details
- 
pamDataBlock
 - 
chanOrSeqMap
protected int chanOrSeqMap - 
firstUnitTime
protected long firstUnitTime - 
lastUnitTime
protected long lastUnitTime - 
currentUnitTime
protected long currentUnitTime - 
listIterator
 - 
synchObject
 
 - 
 - 
Constructor Details
- 
PamDataUnitIterator
An iterator that has a bit more functionality than a basic iterator.
It's main enhancement is to use a channel map match to PamDataUnits, so that it only returns data units that have an overlap in channels with the given channel map (which could be 0xFFFFFFFF).
It also has a couple of extra searches to getPreceeding() and getFollowing() data units.- Parameters:
 pamDataBlock- Datablock containing the datachanOrSeqMap- channel map (requires overlap, ot exact match)whereFrom- start at beginning or end. 0 = beginning; -1 (or PamDatablock.ITERATOR_END) for the end
 
 - 
 - 
Method Details
- 
getFirstUnit
Get the first unit for a specific channel or sequence map (any match of channels allowed).- Parameters:
 chanOrSeqMap- channel/sequence map- Returns:
 - first data unit with at least one channel matching, or null.
 
 - 
getLastUnit
Get the last unit for a specific channel or sequence map (any match of channels allowed).- Parameters:
 chanOrSeqMap- channel/sequence map- Returns:
 - last data unit with at least one channel matching, or null.
 
 - 
next
Return the next PamDataUnit, or null if there is no 'next' PamDataUnit- Specified by:
 nextin interfaceIterator<E extends PamDataUnit>- Specified by:
 nextin interfaceListIterator<E extends PamDataUnit>
 - 
previous
Return the previous PamDataUnit, or null if there is no 'previous' PamDataUnit- Specified by:
 previousin interfaceListIterator<E extends PamDataUnit>
 - 
hasNext
public boolean hasNext()- Specified by:
 hasNextin interfaceIterator<E extends PamDataUnit>- Specified by:
 hasNextin interfaceListIterator<E extends PamDataUnit>
 - 
hasPrevious
public boolean hasPrevious()- Specified by:
 hasPreviousin interfaceListIterator<E extends PamDataUnit>
 - 
getPreceding
Get the unit immediately before or at the given time.- Parameters:
 timeMilliseconds- time in milliseconds.firstOk- if this is true and no unit precedes the given time, it will return the first unit, otherwise it will return null- Returns:
 - a data unit, or null.
 
 - 
getFollowing
Get the unit immediately following or at the given time.- Parameters:
 timeMilliseconds- time in milliseconds.lastOk- if this is true and no unit precedes the given time, it will return the last unit, otherwise it will return null- Returns:
 - a data unit, or null.
 
 - 
getClosest
Get the unit closest to the given time.- Parameters:
 timeMilliseconds- time in milliseconds.firstOrlastOk- if this is true and no unit precedes the given time, it will return the last unit, otherwise it will return null- Returns:
 - a data unit, or null.
 
 - 
nextIndex
public int nextIndex()- Specified by:
 nextIndexin interfaceListIterator<E extends PamDataUnit>
 - 
previousIndex
public int previousIndex()- Specified by:
 previousIndexin interfaceListIterator<E extends PamDataUnit>
 - 
remove
public void remove()- Specified by:
 removein interfaceIterator<E extends PamDataUnit>- Specified by:
 removein interfaceListIterator<E extends PamDataUnit>
 - 
set
- Specified by:
 setin interfaceListIterator<E extends PamDataUnit>
 - 
add
- Specified by:
 addin interfaceListIterator<E extends PamDataUnit>
 - 
getChanOrSeqMap
public int getChanOrSeqMap()Return the channel or sequence map specified during object instantiation- Returns:
 - the channel/sequence Map
 
 - 
getPamDataBlock
- Returns:
 - the pamDataBlock
 
 - 
getSynchObject
- Returns:
 - the synchObject
 
 - 
setSynchObject
- Parameters:
 synchObject- the synchObject to set
 
 -