Class DateSelection

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

public class DateSelection extends Object
Holds state for constructing time based queries.
  • Field Details

    • ARG_STARTMODE

      public static final String ARG_STARTMODE
      url argument names
      See Also:
    • ARG_ENDMODE

      public static final String ARG_ENDMODE
      url argument names
      See Also:
    • ARG_STARTFIXEDTIME

      public static final String ARG_STARTFIXEDTIME
      url argument names
      See Also:
    • ARG_ENDFIXEDTIME

      public static final String ARG_ENDFIXEDTIME
      url argument names
      See Also:
    • ARG_STARTOFFSET

      public static final String ARG_STARTOFFSET
      url argument names
      See Also:
    • ARG_ENDOFFSET

      public static final String ARG_ENDOFFSET
      url argument names
      See Also:
    • ARG_POSTRANGE

      public static final String ARG_POSTRANGE
      url argument names
      See Also:
    • ARG_PRERANGE

      public static final String ARG_PRERANGE
      url argument names
      See Also:
    • ARG_INTERVAL

      public static final String ARG_INTERVAL
      url argument names
      See Also:
    • ARG_ROUNDTO

      public static final String ARG_ROUNDTO
      url argument names
      See Also:
    • ARG_COUNT

      public static final String ARG_COUNT
      url argument names
      See Also:
    • ARG_SKIP

      public static final String ARG_SKIP
      url argument names
      See Also:
    • 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:
    • TIMEMODE_CURRENT

      public static final int TIMEMODE_CURRENT
      The mode for when we use the current time
      See Also:
    • TIMEMODE_RELATIVE

      public static final int TIMEMODE_RELATIVE
      When one of the ranges is relative to another
      See Also:
    • 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:
    • 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:
  • Constructor Details

    • 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 Details

    • 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