Class DataUnitFinder<Tunit extends PamDataUnit>
- Direct Known Subclasses:
DeletedDataUnitFinder
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 Summary
ConstructorDescriptionDataUnitFinder
(PamDataBlock<Tunit> pamDataBlock) Create a data unit finder that uses the default matcher.DataUnitFinder
(PamDataBlock<Tunit> pamDataBlock, DataUnitMatcher dataUnitMatcher) Create a data unit finder that uses a user created matcher -
Method Summary
Modifier and TypeMethodDescriptionfindDataUnit
(Object... criteria) Find a data unit which satisfies the criteria in criteria.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.void
setDataUnitMatcher
(DataUnitMatcher dataUnitMatcher)
-
Constructor Details
-
DataUnitFinder
Create a data unit finder that uses the default matcher.- Parameters:
pamDataBlock
- parent PamDataBLock
-
DataUnitFinder
Create a data unit finder that uses a user created matcher- Parameters:
pamDataBlock
- parent PamDataBlockdataUnitMatcher
- user created matcher
-
-
Method Details
-
findDataUnit
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
- Returns:
- the dataUnitMatcher
-
setDataUnitMatcher
- Parameters:
dataUnitMatcher
- the dataUnitMatcher to set
-
getPamDataBlock
- Returns:
- the pamDataBlock
-
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.
-