Package PamguardMVC

Class DataUnitFinder<Tunit extends PamDataUnit>

java.lang.Object
PamguardMVC.DataUnitFinder<Tunit>
Direct Known Subclasses:
DeletedDataUnitFinder

public class DataUnitFinder<Tunit extends PamDataUnit> extends Object
Class for finding data units in a reasonably controlled and organised way.

It sets up a list iterator at the start of the data block and then searches for each requested data unit from the unit after the last unit requested. This will generally be an efficient way of matching two almost ordered lists of units.

If the iterator gets to the end of the list without finding a match it restarts at the beginning, only returning null (nothing found) when it has been right through the list exactly once.

The finder can work with a default mather of time and channel or with user created matchers which can use any criteria the user wants

Author:
Doug Gillespie
See Also:
  • Constructor Details

    • DataUnitFinder

      public DataUnitFinder(PamDataBlock<Tunit> pamDataBlock)
      Create a data unit finder that uses the default matcher.
      Parameters:
      pamDataBlock - parent PamDataBLock
    • DataUnitFinder

      public DataUnitFinder(PamDataBlock<Tunit> pamDataBlock, DataUnitMatcher dataUnitMatcher)
      Create a data unit finder that uses a user created matcher
      Parameters:
      pamDataBlock - parent PamDataBlock
      dataUnitMatcher - user created matcher
  • Method Details

    • findDataUnit

      public Tunit findDataUnit(Object... criteria)
      Find a data unit which satisfies the criteria in criteria.

      For the default search, the criteria are either just the time in milliseconds OR both the time AND the channel bitmap.

      For user defined matchers, the criteria will have to match whatever the matcher expects.

      Parameters:
      criteria - variable number of matching criteria.
      Returns:
      the next data unit in the data block that matches those criteria.
    • getDataUnitMatcher

      public DataUnitMatcher getDataUnitMatcher()
      Returns:
      the dataUnitMatcher
    • setDataUnitMatcher

      public void setDataUnitMatcher(DataUnitMatcher dataUnitMatcher)
      Parameters:
      dataUnitMatcher - the dataUnitMatcher to set
    • getPamDataBlock

      public PamDataBlock<Tunit> getPamDataBlock()
      Returns:
      the pamDataBlock
    • getLastUnit

      public Tunit getLastUnit()
      Returns:
      the lastUnit
    • inUTCRange

      public boolean inUTCRange(long childUTC)
      Any chance at all that the data unit at this time might exist ? The data in the block should be sorted by time, so all that's needed is a quick compare with the times of the first and last units.
      Parameters:
      childUTC - milisecond time of interest.
      Returns:
      true if it's within the range of the first and last units.