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.
Author:
Doug Gillespie
  • Constructor Details

    • PamDataUnitIterator

      public PamDataUnitIterator(PamDataBlock<E> pamDataBlock, int chanOrSeqMap, int whereFrom)
      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 data
      chanOrSeqMap - 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

      public abstract E getFirstUnit(int chanOrSeqMap)
      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

      public abstract E getLastUnit(int chanOrSeqMap)
      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

      public abstract E next()
      Return the next PamDataUnit, or null if there is no 'next' PamDataUnit
      Specified by:
      next in interface Iterator<E extends PamDataUnit>
      Specified by:
      next in interface ListIterator<E extends PamDataUnit>
    • previous

      public abstract E previous()
      Return the previous PamDataUnit, or null if there is no 'previous' PamDataUnit
      Specified by:
      previous in interface ListIterator<E extends PamDataUnit>
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<E extends PamDataUnit>
      Specified by:
      hasNext in interface ListIterator<E extends PamDataUnit>
    • hasPrevious

      public boolean hasPrevious()
      Specified by:
      hasPrevious in interface ListIterator<E extends PamDataUnit>
    • getPreceding

      public E getPreceding(long timeMilliseconds, boolean firstOk)
      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

      public E getFollowing(long timeMilliseconds, boolean lastOk)
      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

      public E getClosest(long timeMilliseconds, boolean firstOrlastOk)
      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:
      nextIndex in interface ListIterator<E extends PamDataUnit>
    • previousIndex

      public int previousIndex()
      Specified by:
      previousIndex in interface ListIterator<E extends PamDataUnit>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<E extends PamDataUnit>
      Specified by:
      remove in interface ListIterator<E extends PamDataUnit>
    • set

      public void set(E e)
      Specified by:
      set in interface ListIterator<E extends PamDataUnit>
    • add

      public void add(E e)
      Specified by:
      add in interface ListIterator<E extends PamDataUnit>
    • getChanOrSeqMap

      public int getChanOrSeqMap()
      Return the channel or sequence map specified during object instantiation
      Returns:
      the channel/sequence Map
    • getPamDataBlock

      public PamDataBlock<E> getPamDataBlock()
      Returns:
      the pamDataBlock
    • getSynchObject

      public Object getSynchObject()
      Returns:
      the synchObject
    • setSynchObject

      public void setSynchObject(Object synchObject)
      Parameters:
      synchObject - the synchObject to set