HiRISE

HiRISE.HiReport.form
Class TimeRangeForm

java.lang.Object
  extended by org.apache.struts.action.ActionForm
      extended by HiRISE.HiReport.form.PageSortForm
          extended by HiRISE.HiReport.form.TimeRangeForm
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
OrbitCycleForm, PipelineForm, RsdsVenueForm, RsdsVenueForm

public class TimeRangeForm
extends PageSortForm

Class that handles input for a time range.

See Also:
Serialized Form

Field Summary
static String ID
          CVS ID
protected  String maxDate
          end of range
protected  String minDate
          beginning of range
protected  int plus
          current range (in current unit)
static String[] TIME_FORMATS
          Formats available for input
 DateFormat[] timeFormatters
          Parser for dates
protected static Map<String,Integer> timeUnits
          Maps range choices to Calendar unit fields
protected  String unit
          current unit
 
Fields inherited from class HiRISE.HiReport.form.PageSortForm
EXPORT_MAX_ROWS
 
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
 
Constructor Summary
TimeRangeForm()
          Create a new instance, minDate will be 12AM today, plus will be 1 day.
 
Method Summary
 String getMaxDate()
          Get the max date, or null if no max date has been input
 String getMinDate()
          Get the start date, or null if no min date has been input
 int getPlus()
          Get the extent of time, in the units chosen.
 TimeRange getTimeRange()
          Get the time range for the inputs.
 String getTimeUnit()
          Get the currently selected unit.
 String[] getTimeUnits()
          Return the time unit choices.
 Date parseDate(String time)
          Try to parse a time string from the user.
 void setMaxDate(String maxDate)
          Set the end date for the query
 void setMinDate(String minDate)
          Accept the input minimum date
 void setPlus(int plus)
          Set the extent of time, in the units chosen.
 void setTimeRange(TimeRange timeRange)
          Reset the range to a specified time range
 void setTimeUnit(String unit)
          Set the unit to be used in range calculation.
 org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest req)
          Validate the form input.
 
Methods inherited from class HiRISE.HiReport.form.PageSortForm
getDir, getPage, getSize, getSort, isAscending, reset, setDir, setPage, setSize, setSort
 
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, reset, setMultipartRequestHandler, setServlet, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
CVS ID

See Also:
Constant Field Values

TIME_FORMATS

public static final String[] TIME_FORMATS
Formats available for input


timeFormatters

public final DateFormat[] timeFormatters
Parser for dates


timeUnits

protected static Map<String,Integer> timeUnits
Maps range choices to Calendar unit fields


minDate

protected String minDate
beginning of range


maxDate

protected String maxDate
end of range


unit

protected String unit
current unit


plus

protected int plus
current range (in current unit)

Constructor Detail

TimeRangeForm

public TimeRangeForm()
Create a new instance, minDate will be 12AM today, plus will be 1 day.

Method Detail

getTimeUnits

public String[] getTimeUnits()
Return the time unit choices.

Returns:
The time unit choices

setMinDate

public void setMinDate(String minDate)
Accept the input minimum date

Parameters:
minDate - start date for query

getMinDate

public String getMinDate()
Get the start date, or null if no min date has been input

Returns:
start date as string, or null

getMaxDate

public String getMaxDate()
Get the max date, or null if no max date has been input

Returns:
end date as string, or null

setMaxDate

public void setMaxDate(String maxDate)
Set the end date for the query

Parameters:
maxDate - end date for query

setPlus

public void setPlus(int plus)
Set the extent of time, in the units chosen.

Parameters:
plus - the value for the range of time

getPlus

public int getPlus()
Get the extent of time, in the units chosen.

Returns:
range of time

getTimeUnit

public String getTimeUnit()
Get the currently selected unit.

Returns:
the unit name

setTimeUnit

public void setTimeUnit(String unit)
Set the unit to be used in range calculation.

Parameters:
unit - One of the values from getUnits

getTimeRange

public TimeRange getTimeRange()
                       throws ParseException
Get the time range for the inputs. Returns null if no time range was input.

Returns:
the time range object
Throws:
ParseException - Values could not be parsed

setTimeRange

public void setTimeRange(TimeRange timeRange)
Reset the range to a specified time range

Parameters:
timeRange - the new range

validate

public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping,
                                                      javax.servlet.http.HttpServletRequest req)
Validate the form input.

Overrides:
validate in class PageSortForm

parseDate

public Date parseDate(String time)
Try to parse a time string from the user. Each time format will be tried in order. If none are able to parse it, a null Date is returned.

Parameters:
time - string
Returns:
parsed time or null

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona