ucar.unidata.util
Class DateSelection

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

public class DateSelection
extends Object

Holds state for constructing time based queries.


Field Summary
static String ARG_COUNT
          url argument names
static String ARG_ENDFIXEDTIME
          url argument names
static String ARG_ENDMODE
          url argument names
static String ARG_ENDOFFSET
          url argument names
static String ARG_INTERVAL
          url argument names
static String ARG_POSTRANGE
          url argument names
static String ARG_PRERANGE
          url argument names
static String ARG_ROUNDTO
          url argument names
static String ARG_SKIP
          url argument names
static String ARG_STARTFIXEDTIME
          url argument names
static String ARG_STARTMODE
          url argument names
static String ARG_STARTOFFSET
          url argument names
 boolean debug
          debug flag
static String[] ENDMODELABELS
          Mode for constructing set
static int MAX_COUNT
          maximum count
static 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
static String[] TIMEMODESTRINGS
          string ids for time modes
 
Constructor Summary
DateSelection()
          ctor
DateSelection(boolean doAll)
          ctor
DateSelection(boolean doLatest, int count)
          ctor
DateSelection(Date startTime, Date endTime)
          ctor
DateSelection(DateSelection that)
          copy ctor
DateSelection(Hashtable<String,String> args)
          ctor for instantiating a DateSelection object from a set of url argument originally created from toUrlString
DateSelection(int startMode, double startOffset, int endMode, double endOffset)
          Construct a DateSelection
 
Method Summary
 List apply(List times)
          Apply this date selection query to the list of DatedThing-s
 boolean equals(Object o)
          equals method
 int getCount()
          Get the Count property.
 boolean getDoAll()
          Get the DoAll property.
 boolean getDoLatest()
          Get the DoLatest property.
 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
 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.
 Date[] getRange()
          Construct and return the start and end time range
 Date[] getRange(List<DatedThing> dataTimes)
          _more_
 double getRoundTo()
          Get the RoundTo property.
 int getSkip()
          Get the Skip property.
 Date getStartFixedDate()
          get the property
 long getStartFixedTime()
          Get the StartFixedTime property.
 int getStartMode()
          Get the StartMode property.
 double getStartOffset()
          Get the StartOffset property.
 List getTimes()
          Get the Times property.
 void getUrlArgs(Hashtable<String,String> args)
          This adds to the hashtable the set of name/value pairs that allow us to create a new DateSelection from a url argument string
 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(String[] cmdLineArgs)
          test main
protected  Object makeTimeSet()
          Create the time set
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(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(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(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(List value)
          Set the Times property.
 String toString()
          tostring
 String toUrlString()
          Create a url string to encode this object
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ARG_STARTMODE

public static final String ARG_STARTMODE
url argument names

See Also:
Constant Field Values

ARG_ENDMODE

public static final String ARG_ENDMODE
url argument names

See Also:
Constant Field Values

ARG_STARTFIXEDTIME

public static final String ARG_STARTFIXEDTIME
url argument names

See Also:
Constant Field Values

ARG_ENDFIXEDTIME

public static final String ARG_ENDFIXEDTIME
url argument names

See Also:
Constant Field Values

ARG_STARTOFFSET

public static final String ARG_STARTOFFSET
url argument names

See Also:
Constant Field Values

ARG_ENDOFFSET

public static final String ARG_ENDOFFSET
url argument names

See Also:
Constant Field Values

ARG_POSTRANGE

public static final String ARG_POSTRANGE
url argument names

See Also:
Constant Field Values

ARG_PRERANGE

public static final String ARG_PRERANGE
url argument names

See Also:
Constant Field Values

ARG_INTERVAL

public static final String ARG_INTERVAL
url argument names

See Also:
Constant Field Values

ARG_ROUNDTO

public static final String ARG_ROUNDTO
url argument names

See Also:
Constant Field Values

ARG_COUNT

public static final String ARG_COUNT
url argument names

See Also:
Constant Field Values

ARG_SKIP

public static final String ARG_SKIP
url argument names

See Also:
Constant Field Values

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

TIMEMODESTRINGS

public static String[] TIMEMODESTRINGS
string ids for time modes


TIMEMODES

public static int[] TIMEMODES
Mode for constructing set


STARTMODELABELS

public static String[] STARTMODELABELS
Mode for constructing set


ENDMODELABELS

public static 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(Hashtable<String,String> args)
ctor for instantiating a DateSelection object from a set of url argument originally created from toUrlString

Parameters:
args - set of name value pairs as created by getUrlArgs

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(Date startTime,
                     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 List apply(List times)
Apply this date selection query to the list of DatedThing-s

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

getRange

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

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

getRange

public Date[] getRange(List<DatedThing> dataTimes)
_more_

Parameters:
dataTimes - _more_
Returns:
_more_

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

makeTimeSet

protected Object makeTimeSet()
Create the time set

Returns:
The time set

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(Date d)
set property

Parameters:
d - property

setEndFixedTime

public void setEndFixedTime(Date d)
set property

Parameters:
d - property

getStartFixedDate

public Date getStartFixedDate()
get the property

Returns:
property

getEndFixedDate

public 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(List value)
Set the Times property.

Parameters:
value - The new value for Times

getTimes

public List getTimes()
Get the Times property.

Returns:
The Times

hashCode

public int hashCode()
Get the hashcode for this object

Overrides:
hashCode in class Object
Returns:
the hashcode

equals

public boolean equals(Object o)
equals method

Overrides:
equals in class 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(Date value)
Set the NowTime property.

Parameters:
value - The new value for NowTime

getNowTime

public Date getNowTime()
Get the NowTime property.

Returns:
The NowTime

main

public static void main(String[] cmdLineArgs)
                 throws Exception
test main

Parameters:
cmdLineArgs - cmd line args
Throws:
Exception - on badness

toString

public String toString()
tostring

Overrides:
toString in class Object
Returns:
tostring

getUrlArgs

public void getUrlArgs(Hashtable<String,String> args)
This adds to the hashtable the set of name/value pairs that allow us to create a new DateSelection from a url argument string

Parameters:
args - put the name value pairs in here

toUrlString

public String toUrlString()
Create a url string to encode this object

Returns:
the url string


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.