Package ucar.unidata.util
Class DateSelection
java.lang.Object
ucar.unidata.util.DateSelection
Holds state for constructing time based queries.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesstatic final Stringurl argument namesbooleandebug flagstatic String[]Mode for constructing setstatic final intmaximum countstatic String[]Mode for constructing setstatic final intThe mode for when we use the current timestatic final intMode for using the first or last time in the data set.static final intThe mode for when we have an absolute time as a range boundsstatic final intWhen one of the ranges is relative to anotherstatic int[]Mode for constructing setstatic String[]string ids for time modes -
Constructor Summary
ConstructorsConstructorDescriptionctorDateSelection(boolean doAll) ctorDateSelection(boolean doLatest, int count) ctorDateSelection(int startMode, double startOffset, int endMode, double endOffset) Construct a DateSelectionDateSelection(Date startTime, Date endTime) ctorDateSelection(Hashtable<String, String> args) ctor for instantiating a DateSelection object from a set of url argument originally created from toUrlStringDateSelection(DateSelection that) copy ctor -
Method Summary
Modifier and TypeMethodDescriptionApply this date selection query to the list of DatedThing-sbooleanequals methodintgetCount()Get the Count property.booleangetDoAll()Get the DoAll property.booleanGet the DoLatest property.get the propertylongGet the EndFixedTime property.intGet the EndMode property.doubleGet the EndOffset property.doubleGet the Interval property.double[]Generate an array of times for the intervalGet the NowTime property.intGet the NumTimesInRange property.doubleGet the PostRange property.doubleGet the post interval range to use.doubleGet the PreRange property.doubleGet the pre interval range to use.Date[]getRange()Construct and return the start and end time rangeDate[]getRange(List<DatedThing> dataTimes) _more_doubleGet the RoundTo property.intgetSkip()Get the Skip property.get the propertylongGet the StartFixedTime property.intGet the StartMode property.doubleGet the StartOffset property.getTimes()Get the Times property.voidgetUrlArgs(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 stringbooleanhasCount()Does this date selection have a valid countinthashCode()Get the hashcode for this objectbooleanDo we have an interval definedbooleanDo we have a post range definedbooleanDo we have a pre range definedbooleanisAll()Select all thingsbooleanisLatest()Select the most recent thingstatic voidtest mainprotected ObjectCreate the time setstatic doubleroundTo(double roundTo, double milliSeconds) Utility to round the given secondsvoidsetCount(int value) Set the Count property.voidsetDoAll(boolean value) Set the DoAll property.voidsetDoLatest(boolean value) Set the DoLatest property.voidsetEndFixedTime(long value) Set the EndFixedTime property.voidset propertyvoidsetEndMode(int value) Set the EndMode property.voidsetEndOffset(double value) Set the EndOffset property.voidsetInterval(double value) Set the Interval property.voidsetIntervalRange(double value) A utility method to set the pre and post range symmetrically.voidsetNowTime(Date value) Set the NowTime property.voidsetNumTimesInRange(int value) Set the NumTimesInRange property.voidsetPostRange(double value) Set the PostRange property.voidsetPreRange(double value) Set the PreRange property.voidsetRoundTo(double value) Set the RoundTo property.voidsetSkip(int value) Set the Skip property.voidsetStartFixedTime(long value) Set the StartFixedTime property.voidset propertyvoidsetStartMode(int value) Set the StartMode property.voidsetStartOffset(double value) Set the StartOffset property.voidSet the Times property.toString()tostringCreate a url string to encode this object
-
Field Details
-
ARG_STARTMODE
url argument names- See Also:
-
ARG_ENDMODE
url argument names- See Also:
-
ARG_STARTFIXEDTIME
url argument names- See Also:
-
ARG_ENDFIXEDTIME
url argument names- See Also:
-
ARG_STARTOFFSET
url argument names- See Also:
-
ARG_ENDOFFSET
url argument names- See Also:
-
ARG_POSTRANGE
url argument names- See Also:
-
ARG_PRERANGE
url argument names- See Also:
-
ARG_INTERVAL
url argument names- See Also:
-
ARG_ROUNDTO
url argument names- See Also:
-
ARG_COUNT
url argument names- See Also:
-
ARG_SKIP
url argument names- See Also:
-
debug
public boolean debugdebug flag -
TIMEMODE_FIXED
public static final int TIMEMODE_FIXEDThe mode for when we have an absolute time as a range bounds- See Also:
-
TIMEMODE_CURRENT
public static final int TIMEMODE_CURRENTThe mode for when we use the current time- See Also:
-
TIMEMODE_RELATIVE
public static final int TIMEMODE_RELATIVEWhen one of the ranges is relative to another- See Also:
-
TIMEMODE_DATA
public static final int TIMEMODE_DATAMode for using the first or last time in the data set. Not sure if this will be useful here- See Also:
-
TIMEMODESTRINGS
string ids for time modes -
TIMEMODES
public static int[] TIMEMODESMode for constructing set -
STARTMODELABELS
Mode for constructing set -
ENDMODELABELS
Mode for constructing set -
MAX_COUNT
public static final int MAX_COUNTmaximum count- See Also:
-
-
Constructor Details
-
DateSelection
public DateSelection()ctor -
DateSelection
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 onescount- 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 modestartOffset- offset from start timeendMode- end time modeendOffset- offset from end time
-
DateSelection
ctor- Parameters:
startTime- start timeendTime- end time
-
DateSelection
copy ctor- Parameters:
that- object to copy from
-
-
Method Details
-
getIntervalTicks
public double[] getIntervalTicks()Generate an array of times for the interval- Returns:
- intervals
-
apply
Apply this date selection query to the list of DatedThing-s- Parameters:
times- input list of DatedThing-s- Returns:
- The filtered list
-
getRange
Construct and return the start and end time range- Returns:
- time range. If in doLatest or doAll mode this returns null
-
getRange
_more_- Parameters:
dataTimes- _more_- Returns:
- _more_
-
roundTo
public static double roundTo(double roundTo, double milliSeconds) Utility to round the given seconds- Parameters:
roundTo- round tomilliSeconds- time to round- Returns:
- Rounded value
-
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
set property- Parameters:
d- property
-
setEndFixedTime
set property- Parameters:
d- property
-
getStartFixedDate
get the property- Returns:
- property
-
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
Set the Times property.- Parameters:
value- The new value for Times
-
getTimes
Get the Times property.- Returns:
- The Times
-
hashCode
public int hashCode()Get the hashcode for this object -
equals
equals method -
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
Set the NowTime property.- Parameters:
value- The new value for NowTime
-
getNowTime
Get the NowTime property.- Returns:
- The NowTime
-
main
test main- Parameters:
cmdLineArgs- cmd line args- Throws:
Exception- on badness
-
toString
tostring -
getUrlArgs
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
Create a url string to encode this object- Returns:
- the url string
-