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 Link icon

    • PamDataUnitIterator Link icon

      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 Link icon

    • getFirstUnit Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

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

      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 Link icon

      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 Link icon

      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 Link icon

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

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

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

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

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

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

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

      public Object getSynchObject()
      Returns:
      the synchObject
    • setSynchObject Link icon

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