ucar.unidata.util
Class DateSelection

java.lang.Object
  extended by ucar.unidata.util.DateSelection

public class DateSelection
extends java.lang.Object

Holds state for constructing time based queries.


Field Summary
 boolean debug
          debug flag
static java.lang.String[] ENDMODELABELS
          Mode for constructing set
static int MAX_COUNT
          maximum count
static java.lang.String[] STARTMODELABELS
          Mode for constructing set
static int TIMEMODE_CURRENT
          The mode for when we use the current time
static int TIMEMODE_DATA
          Mode for using the first or last time in the data set.
static int TIMEMODE_FIXED
          The mode for when we have an absolute time as a range bounds
static int TIMEMODE_RELATIVE
          When one of the ranges is relative to another
static int[] TIMEMODES
          Mode for constructing set
 
Constructor Summary
DateSelection()
          ctor
DateSelection(boolean doAll)
          ctor
DateSelection(boolean doLatest, int count)
          ctor
DateSelection(java.util.Date startTime, java.util.Date endTime)
          ctor
DateSelection(DateSelection that)
          copy ctor
DateSelection(int startMode, double startOffset, int endMode, double endOffset)
          Construct a DateSelection
 
Method Summary
 java.util.List apply(java.util.List datedThings)
          Apply this date selection query to the list of DatedThing-s
 boolean equals(java.lang.Object o)
          equals method
 int getCount()
          Get the Count property.
 boolean getDoAll()
          Get the DoAll property.
 boolean getDoLatest()
          Get the DoLatest property.
 java.util.Date getEndFixedDate()
          get the property
 long getEndFixedTime()
          Get the EndFixedTime property.
 int getEndMode()
          Get the EndMode property.
 double getEndOffset()
          Get the EndOffset property.
 double getInterval()
          Get the Interval property.
 double[] getIntervalTicks()
          Generate an array of times for the interval
 java.util.Date getNowTime()
          Get the NowTime property.
 int getNumTimesInRange()
          Get the NumTimesInRange property.
 double getPostRange()
          Get the PostRange property.
 double getPostRangeToUse()
          Get the post interval range to use.
 double getPreRange()
          Get the PreRange property.
 double getPreRangeToUse()
          Get the pre interval range to use.
 java.util.Date[] getRange()
          Construct and return the start and end time range
 double getRoundTo()
          Get the RoundTo property.
 int getSkip()
          Get the Skip property.
 java.util.Date getStartFixedDate()
          get the property
 long getStartFixedTime()
          Get the StartFixedTime property.
 int getStartMode()
          Get the StartMode property.
 double getStartOffset()
          Get the StartOffset property.
 java.util.List getTimes()
          Get the Times property.
 boolean hasCount()
          Does this date selection have a valid count
 int hashCode()
          Get the hashcode for this object
 boolean hasInterval()
          Do we have an interval defined
 boolean hasPostRange()
          Do we have a post range defined
 boolean hasPreRange()
          Do we have a pre range defined
 boolean isAll()
          Select all things
 boolean isLatest()
          Select the most recent thing
static void main(java.lang.String[] args)
          test main
static double roundTo(double roundTo, double milliSeconds)
          Utility to round the given seconds
 void setCount(int value)
          Set the Count property.
 void setDoAll(boolean value)
          Set the DoAll property.
 void setDoLatest(boolean value)
          Set the DoLatest property.
 void setEndFixedTime(java.util.Date d)
          set property
 void setEndFixedTime(long value)
          Set the EndFixedTime property.
 void setEndMode(int value)
          Set the EndMode property.
 void setEndOffset(double value)
          Set the EndOffset property.
 void setInterval(double value)
          Set the Interval property.
 void setIntervalRange(double value)
          A utility method to set the pre and post range symmetrically.
 void setNowTime(java.util.Date value)
          Set the NowTime property.
 void setNumTimesInRange(int value)
          Set the NumTimesInRange property.
 void setPostRange(double value)
          Set the PostRange property.
 void setPreRange(double value)
          Set the PreRange property.
 void setRoundTo(double value)
          Set the RoundTo property.
 void setSkip(int value)
          Set the Skip property.
 void setStartFixedTime(java.util.Date d)
          set property
 void setStartFixedTime(long value)
          Set the StartFixedTime property.
 void setStartMode(int value)
          Set the StartMode property.
 void setStartOffset(double value)
          Set the StartOffset property.
 void setTimes(java.util.List value)
          Set the Times property.
 java.lang.String toString()
          tostring
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public boolean debug
debug flag


TIMEMODE_FIXED

public static final int TIMEMODE_FIXED
The mode for when we have an absolute time as a range bounds

See Also:
Constant Field Values

TIMEMODE_CURRENT

public static final int TIMEMODE_CURRENT
The mode for when we use the current time

See Also:
Constant Field Values

TIMEMODE_RELATIVE

public static final int TIMEMODE_RELATIVE
When one of the ranges is relative to another

See Also:
Constant Field Values

TIMEMODE_DATA

public static final int TIMEMODE_DATA
Mode for using the first or last time in the data set. Not sure if this will be useful here

See Also:
Constant Field Values

TIMEMODES

public static int[] TIMEMODES
Mode for constructing set


STARTMODELABELS

public static java.lang.String[] STARTMODELABELS
Mode for constructing set


ENDMODELABELS

public static java.lang.String[] ENDMODELABELS
Mode for constructing set


MAX_COUNT

public static final int MAX_COUNT
maximum count

See Also:
Constant Field Values
Constructor Detail

DateSelection

public DateSelection()
ctor


DateSelection

public DateSelection(boolean doLatest,
                     int count)
ctor

Parameters:
doLatest - Do the count latest ones
count - the count

DateSelection

public DateSelection(boolean doAll)
ctor

Parameters:
doAll - Get all available.

DateSelection

public DateSelection(int startMode,
                     double startOffset,
                     int endMode,
                     double endOffset)
Construct a DateSelection

Parameters:
startMode - starting time mode
startOffset - offset from start time
endMode - end time mode
endOffset - offset from end time

DateSelection

public DateSelection(java.util.Date startTime,
                     java.util.Date endTime)
ctor

Parameters:
startTime - start time
endTime - end time

DateSelection

public DateSelection(DateSelection that)
copy ctor

Parameters:
that - object to copy from
Method Detail

getIntervalTicks

public double[] getIntervalTicks()
Generate an array of times for the interval

Returns:
intervals

apply

public java.util.List apply(java.util.List datedThings)
Apply this date selection query to the list of DatedThing-s

Parameters:
datedThings - input list of DatedThing-s
Returns:
The filtered list

getRange

public java.util.Date[] getRange()
Construct and return the start and end time range

Returns:
time range. If in doLatest or doAll mode this returns null

roundTo

public static double roundTo(double roundTo,
                             double milliSeconds)
Utility to round the given seconds

Parameters:
roundTo - round to
milliSeconds - time to round
Returns:
Rounded value

setStartMode

public void setStartMode(int value)
Set the StartMode property.

Parameters:
value - The new value for StartMode

getStartMode

public int getStartMode()
Get the StartMode property.

Returns:
The StartMode

setEndMode

public void setEndMode(int value)
Set the EndMode property.

Parameters:
value - The new value for EndMode

getEndMode

public int getEndMode()
Get the EndMode property.

Returns:
The EndMode

hasInterval

public boolean hasInterval()
Do we have an interval defined

Returns:
Have interval defined

hasPreRange

public boolean hasPreRange()
Do we have a pre range defined

Returns:
Is pre-range defined

hasPostRange

public boolean hasPostRange()
Do we have a post range defined

Returns:
Is post-range defined

setInterval

public void setInterval(double value)
Set the Interval property.

Parameters:
value - The new value for Interval

getInterval

public double getInterval()
Get the Interval property.

Returns:
The Interval

setStartOffset

public void setStartOffset(double value)
Set the StartOffset property.

Parameters:
value - The new value for StartOffset

getStartOffset

public double getStartOffset()
Get the StartOffset property.

Returns:
The StartOffset

setEndOffset

public void setEndOffset(double value)
Set the EndOffset property.

Parameters:
value - The new value for EndOffset

getEndOffset

public double getEndOffset()
Get the EndOffset property.

Returns:
The EndOffset

setRoundTo

public void setRoundTo(double value)
Set the RoundTo property.

Parameters:
value - The new value for RoundTo

getRoundTo

public double getRoundTo()
Get the RoundTo property.

Returns:
The RoundTo

setStartFixedTime

public void setStartFixedTime(long value)
Set the StartFixedTime property.

Parameters:
value - The new value for StartFixedTime

setStartFixedTime

public void setStartFixedTime(java.util.Date d)
set property

Parameters:
d - property

setEndFixedTime

public void setEndFixedTime(java.util.Date d)
set property

Parameters:
d - property

getStartFixedDate

public java.util.Date getStartFixedDate()
get the property

Returns:
property

getEndFixedDate

public java.util.Date getEndFixedDate()
get the property

Returns:
property

getStartFixedTime

public long getStartFixedTime()
Get the StartFixedTime property.

Returns:
The StartFixedTime

setEndFixedTime

public void setEndFixedTime(long value)
Set the EndFixedTime property.

Parameters:
value - The new value for EndFixedTime

getEndFixedTime

public long getEndFixedTime()
Get the EndFixedTime property.

Returns:
The EndFixedTime

setIntervalRange

public void setIntervalRange(double value)
A utility method to set the pre and post range symmetrically. Each are set with half of the given value

Parameters:
value - interval range

setPreRange

public void setPreRange(double value)
Set the PreRange property.

Parameters:
value - The new value for PreRange

getPreRangeToUse

public double getPreRangeToUse()
Get the pre interval range to use. If we have a preRange then return that, else, return half of the interval.

Returns:
The pre range to use

getPostRangeToUse

public double getPostRangeToUse()
Get the post interval range to use. If we have a postRange then return that, else, return half of the interval.

Returns:
The post range to use

getPreRange

public double getPreRange()
Get the PreRange property.

Returns:
The PreRange

setPostRange

public void setPostRange(double value)
Set the PostRange property.

Parameters:
value - The new value for PostRange

getPostRange

public double getPostRange()
Get the PostRange property.

Returns:
The PostRange

setCount

public void setCount(int value)
Set the Count property.

Parameters:
value - The new value for Count

hasCount

public boolean hasCount()
Does this date selection have a valid count

Returns:
has a count

getCount

public int getCount()
Get the Count property.

Returns:
The Count

setNumTimesInRange

public void setNumTimesInRange(int value)
Set the NumTimesInRange property.

Parameters:
value - The new value for NumTimesInRange

getNumTimesInRange

public int getNumTimesInRange()
Get the NumTimesInRange property.

Returns:
The NumTimesInRange

setTimes

public void setTimes(java.util.List value)
Set the Times property.

Parameters:
value - The new value for Times

getTimes

public java.util.List getTimes()
Get the Times property.

Returns:
The Times

hashCode

public int hashCode()
Get the hashcode for this object

Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode

equals

public boolean equals(java.lang.Object o)
equals method

Overrides:
equals in class java.lang.Object
Parameters:
o - object to check
Returns:
equals

setSkip

public void setSkip(int value)
Set the Skip property.

Parameters:
value - The new value for Skip

getSkip

public int getSkip()
Get the Skip property.

Returns:
The Skip

setDoLatest

public void setDoLatest(boolean value)
Set the DoLatest property.

Parameters:
value - The new value for DoLatest

isLatest

public boolean isLatest()
Select the most recent thing

Returns:
select the most recent thing

getDoLatest

public boolean getDoLatest()
Get the DoLatest property.

Returns:
The DoLatest

setDoAll

public void setDoAll(boolean value)
Set the DoAll property.

Parameters:
value - The new value for DoAll

isAll

public boolean isAll()
Select all things

Returns:
select all things

getDoAll

public boolean getDoAll()
Get the DoAll property.

Returns:
The DoAll

setNowTime

public void setNowTime(java.util.Date value)
Set the NowTime property.

Parameters:
value - The new value for NowTime

getNowTime

public java.util.Date getNowTime()
Get the NowTime property.

Returns:
The NowTime

main

public static void main(java.lang.String[] args)
test main

Parameters:
args - cmd line args

toString

public java.lang.String toString()
tostring

Overrides:
toString in class java.lang.Object
Returns:
tostring