| java.lang.Object org.apache.turbine.util.TimeSelector
TimeSelector | public class TimeSelector (Code) | | TimeSelector is a utility class to handle the creation of a set of
time drop-down menus. The code is broken into a set of static methods
for quick and easy access to the individual select objects:
ElementContainer ec timeSelect = new ElementContainer();
String myName = "mytime";
ec.addElement(TimeSelector.getHourSelector(myName));
ec.addElement(TimeSelector.getMinuteSelector(myName));
ec.addElement(TimeSelector.getAMPMSelector(myName));
There are also methods which will use attributes to build a
complete time selector in the default 12hr format (eg HH:MM am/pm):
TimeSelector ts = new TimeSelector(myName);
timeSelect = ts.ecsOutput();
Minutes/Seconds are by default rounded to the nearest 5 units
although this can be easily changed.
24hr TimeSelectors can also be produced. The following example
creates a full precision TimeSelector (eg HH:MM:SS):
TimeSelector ts = new TimeSelector(myName);
ts.setTimeFormat(TimeSelector.TWENTY_FOUR_HOUR);
ts.setMinuteInterval(1);
ts.setSecondInterval(1);
ts.setShowSeconds(true);
timeSelect = ts.toString();
author: Jeffrey D. Brekke author: Rich Aston version: $Id: TimeSelector.java 534527 2007-05-02 16:10:59Z tv $ |
Method Summary | |
public ElementContainer | ecsOutput() Return an ECS container with the select objects inside. | public static Select | getAMPMSelector(String name) Return an am/pm selector.
Parameters: name - The name to use for the selected am/pm. | public static Select | getAMPMSelector(String name, Calendar now) Return an am/pm selector.
Parameters: name - The name to use for the selected am/pm. Parameters: now - Calendar to start with. | public static Select | getHourSelector(String name) Return an 12 hour selector.
Parameters: name - The name to use for the selected hour. | public static Select | getHourSelector(String name, Calendar now) Return an 12 hour selector.
Parameters: name - The name to use for the selected hour. Parameters: now - Calendar to start with. | public static Select | getHourSelector(String name, Calendar now, int format) Return an hour selector (either 12hr or 24hr depending on
format .
Parameters: name - The name to use for the selected hour. Parameters: now - Calendar to start with. Parameters: format - Time format. | public static Select | getMinuteSelector(String name) Return a minute selector.
Parameters: name - The name to use for the selected minute. | public static Select | getMinuteSelector(String name, Calendar now) Return a minute selector.
Parameters: name - The name to use for the selected minute. | public static Select | getMinuteSelector(String name, Calendar now, int interval) Return a minute selector.
Parameters: name - The name to use for the selected minute. Parameters: now - Calendar to start with. Parameters: interval - Interval between options. | public static Select | getSecondSelector(String name) Return a second selector.
Parameters: name - The name to use for the selected second. | public static Select | getSecondSelector(String name, Calendar now) Return a second selector.
Parameters: name - The name to use for the selected second. Parameters: now - Calendar to start with. | public static Select | getSecondSelector(String name, Calendar now, int interval) Return a second selector.
Parameters: name - The name to use for the selected second. Parameters: now - Calendar to start with. Parameters: interval - Interval between options. | public String | getSelName() Get the selector name prefix. | public String | output() Used to build the popupmenu in HTML. | public TimeSelector | setMinuteInterval(int minutes) Set the interval between options in the minute select box.
Individual getHour, getMinute, getSecond, getAMPM static methods
will not use this setting.
Parameters: minutes - Interval in minutes. | public TimeSelector | setOnChange(String onChange) Adds the onChange to all of <SELECT> tags.
This is limited to one function for all three popups and is only
used when the output() methods are used. | public TimeSelector | setSecondInterval(int seconds) Set the interval between options in the second select box.
Individual getHour, getMinute, getSecond, getAMPM static methods
will not use this setting.
Parameters: seconds - Interval in seconds. | public TimeSelector | setSeconds(int seconds) Select the second to be selected if the showSeconds(false) behavior
is used. | public void | setSelName(String selName) Set the selector name prefix. | public TimeSelector | setShowSeconds(boolean show) Whether or not to show the seconds as a popup menu. | public TimeSelector | setTimeFormat(int format) Set the time format to 12 or 24 hour. | public String | toString() Used to build the popupmenu in HTML. |
AMPM_SUFFIX | final public static String AMPM_SUFFIX(Code) | | Suffix for am/pm parameter.
|
DEFAULT_PREFIX | final public static String DEFAULT_PREFIX(Code) | | Prefix for time names.
|
HOUR_SUFFIX | final public static String HOUR_SUFFIX(Code) | | Suffix for hour parameter.
|
MINUTE_SUFFIX | final public static String MINUTE_SUFFIX(Code) | | Suffix for minute parameter.
|
SECOND_SUFFIX | final public static String SECOND_SUFFIX(Code) | | Suffix for second parameter.
|
TWELVE_HOUR | final public static int TWELVE_HOUR(Code) | | Constant for 12hr format
|
TWENTY_FOUR_HOUR | final public static int TWENTY_FOUR_HOUR(Code) | | Constant for 24hr format
|
TimeSelector | public TimeSelector()(Code) | | Constructor defaults to current date/time and uses the default
prefix: TimeSelector.DEFAULT
|
TimeSelector | public TimeSelector(String selName, Calendar useDate)(Code) | | Constructor, uses the date/time set in the calendar
passed in (with the date/time set correctly).
Parameters: selName - A String with the selector name. Parameters: useDate - A Calendar with a date/time. |
TimeSelector | public TimeSelector(String selName)(Code) | | Constructor defaults to current date/time.
Parameters: selName - A String with the selector name. |
ecsOutput | public ElementContainer ecsOutput()(Code) | | Return an ECS container with the select objects inside.
An ECS container. |
getAMPMSelector | public static Select getAMPMSelector(String name)(Code) | | Return an am/pm selector.
Parameters: name - The name to use for the selected am/pm. A select object with am/pm |
getAMPMSelector | public static Select getAMPMSelector(String name, Calendar now)(Code) | | Return an am/pm selector.
Parameters: name - The name to use for the selected am/pm. Parameters: now - Calendar to start with. A select object with am/pm. |
getHourSelector | public static Select getHourSelector(String name)(Code) | | Return an 12 hour selector.
Parameters: name - The name to use for the selected hour. A select object with all the hours. |
getHourSelector | public static Select getHourSelector(String name, Calendar now)(Code) | | Return an 12 hour selector.
Parameters: name - The name to use for the selected hour. Parameters: now - Calendar to start with. A select object with all the hours. |
getHourSelector | public static Select getHourSelector(String name, Calendar now, int format)(Code) | | Return an hour selector (either 12hr or 24hr depending on
format .
Parameters: name - The name to use for the selected hour. Parameters: now - Calendar to start with. Parameters: format - Time format. A select object with all the hours. |
getMinuteSelector | public static Select getMinuteSelector(String name)(Code) | | Return a minute selector.
Parameters: name - The name to use for the selected minute. A select object with minute options. |
getMinuteSelector | public static Select getMinuteSelector(String name, Calendar now)(Code) | | Return a minute selector.
Parameters: name - The name to use for the selected minute. A select object with minute options. |
getMinuteSelector | public static Select getMinuteSelector(String name, Calendar now, int interval)(Code) | | Return a minute selector.
Parameters: name - The name to use for the selected minute. Parameters: now - Calendar to start with. Parameters: interval - Interval between options. A select object with minute options. |
getSecondSelector | public static Select getSecondSelector(String name)(Code) | | Return a second selector.
Parameters: name - The name to use for the selected second. A select object with second options. |
getSecondSelector | public static Select getSecondSelector(String name, Calendar now)(Code) | | Return a second selector.
Parameters: name - The name to use for the selected second. Parameters: now - Calendar to start with. A select object with second options. |
getSecondSelector | public static Select getSecondSelector(String name, Calendar now, int interval)(Code) | | Return a second selector.
Parameters: name - The name to use for the selected second. Parameters: now - Calendar to start with. Parameters: interval - Interval between options. A select object with second options. |
getSelName | public String getSelName()(Code) | | Get the selector name prefix.
A String with the select name prefix. |
output | public String output()(Code) | | Used to build the popupmenu in HTML. The properties set in the
object are used to generate the correct HTML. The selName
attribute is used to seed the names of the select lists. The
names will be generated as follows:
- selName + "_hour"
- selName + "_minute"
- selName + "_ampm"
If onChange was set it is also used in the generation of the
output. The output HTML will list the select lists in the
following order: hour minute ampm.
If setShowSeconds(true) is used then an addition second select box
is produced after the minute select box.
If setTimeFormat(TimeSelector.TWENTY_FOUR_HOUR) is used then
the ampm select box is omitted.
A String with the correct HTML for the date selector. |
setMinuteInterval | public TimeSelector setMinuteInterval(int minutes)(Code) | | Set the interval between options in the minute select box.
Individual getHour, getMinute, getSecond, getAMPM static methods
will not use this setting.
Parameters: minutes - Interval in minutes. A TimeSelector (self). |
setOnChange | public TimeSelector setOnChange(String onChange)(Code) | | Adds the onChange to all of <SELECT> tags.
This is limited to one function for all three popups and is only
used when the output() methods are used. Individual getHour,
getMinute, getSecond, getAMPM static methods will not use this
setting.
Parameters: onChange - A String to use for onChange attribute. If null,then nothing will be set. A TimeSelector (self). |
setSecondInterval | public TimeSelector setSecondInterval(int seconds)(Code) | | Set the interval between options in the second select box.
Individual getHour, getMinute, getSecond, getAMPM static methods
will not use this setting.
Parameters: seconds - Interval in seconds. A TimeSelector (self). |
setSeconds | public TimeSelector setSeconds(int seconds)(Code) | | Select the second to be selected if the showSeconds(false) behavior
is used. Individual getHour, getMinute, getSecond, getAMPM
static methods will not use this setting.
Parameters: seconds - The second. A TimeSelector (self). |
setSelName | public void setSelName(String selName)(Code) | | Set the selector name prefix. Individual getHour, getMinute,
getSeconds, getAMPM static methods will not use this setting.
Parameters: selname - A String with the select name prefix. |
setShowSeconds | public TimeSelector setShowSeconds(boolean show)(Code) | | Whether or not to show the seconds as a popup menu. The seconds will
be a hidden parameter and the value set with setSeconds is used.
Individual getHour, getMinute, getSecond, getAMPM static methods
will not use this setting.
Parameters: show - True if the second should be shown. A TimeSelector (self). |
setTimeFormat | public TimeSelector setTimeFormat(int format)(Code) | | Set the time format to 12 or 24 hour. Individual getHour,
getMinute, getSecond, getAMPM static methods
will not use this setting.
Parameters: format - Time format. A TimeSelector (self). |
toString | public String toString()(Code) | | Used to build the popupmenu in HTML. The properties set in the
object are used to generate the correct HTML. The selName
attribute is used to seed the names of the select lists. The
names will be generated as follows:
- selName + "_hour"
- selName + "_minute"
- selName + "_ampm"
If onChange was set it is also used in the generation of the
output. The output HTML will list the select lists in the
following order: hour minute ampm.
If setShowSeconds(true) is used then an addition second select box
is produced after the minute select box.
If setTimeFormat(TimeSelector.TWENTY_FOUR_HOUR) is used then
the ampm select box is omitted.
A String with the correct HTML for the date selector. |
|
|