Package adams.core.base
Class BaseTimeMsec
- java.lang.Object
-
- adams.core.base.BaseObject
-
- adams.core.base.BaseTimeMsec
-
- All Implemented Interfaces:
CloneHandler<BaseObject>
,DateValueSupporter
,GrammarSupplier
,Serializable
,Comparable
public class BaseTimeMsec extends BaseObject implements GrammarSupplier, DateValueSupporter
Wrapper for a Time string to be editable in the GOE. Dates have to be of format "HH:mm:ss.SSS".parses expressions as follows: (<date>|NOW|-INF|+INF|START|END) [(+<int>|-<int>) (MILLISECOND|SECOND|MINUTE|HOUR)] Examples: 01:02:03.123 01:02:03.123 +1 MINUTE 01:02:03.123 +31 MILLISECOND NOW +INF NOW +1 HOUR NOW +14 MINNUTE Amounts can be chained as well: NOW -1 MINUTE +1 HOUR START and END can only be set programmatically; by default they equal to -INF and +INF.
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
setStart(Date)
,setEnd(Date)
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
END
the placeholder for "end".static String
FORMAT
the date format.static String
INF_FUTURE
the placeholder for "+INF" (infinity in the future).static String
INF_FUTURE_DATE
the "+INF" date.static String
INF_PAST
the placeholder for "-INF" (infinity in the past).static String
INF_PAST_DATE
the "-INF" date.protected Date
m_End
the end time to use.protected static DateFormat
m_Format
for formatting/parsing the dates.protected Date
m_Start
the start time to use.static String
NOW
the placeholder for "now".static String
START
the placeholder for "start".-
Fields inherited from class adams.core.base.BaseObject
m_Internal, m_Properties, SUFFIX_DISPLAY, SUFFIX_VALUE
-
-
Constructor Summary
Constructors Constructor Description BaseTimeMsec()
Initializes the date as NOW.BaseTimeMsec(String s)
Initializes the object with the date to parse.BaseTimeMsec(Date date)
Initializes the object with the specified date.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Date
dateValue()
Returns the Date value.String
formatDateValue(String format)
Returns the Date value formatted as a string.Date
getEnd()
Returns the optional end time.protected static DateFormat
getFormat()
Returns the formatter.String
getGrammar()
Returns a string representation of the grammar.Date
getStart()
Returns the optional start time.String
getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).String
getValue()
Returns the current string value.static BaseTimeMsec
infinityFuture()
Returns a new BaseTimeMsec object initialized with the INF_FUTURE placeholder.static BaseTimeMsec
infinityPast()
Returns a new BaseTimeMsec object initialized with the INF_PAST placeholder.protected void
initialize()
Initializes the internal object.boolean
isInfinity()
Checks whether the date/time is -INF or +INF.boolean
isInfinityFuture()
Checks whether the date/time is +INF.boolean
isInfinityPast()
Checks whether the date/time is -INF.boolean
isValid(String value)
Checks whether the string value is a valid presentation for this class.static BaseTimeMsec
now()
Returns a new BaseTimeMsec object initialized with the NOW placeholder.protected Date
parse(String s, boolean quiet)
Parses the given date string.void
setEnd(Date value)
Sets the optional end time.void
setStart(Date value)
Sets the optional start time.void
setValue(String value)
Sets the string value.String
stringValue()
Returns the actual Date as string.TimeMsec
timeMsecValue()
Returns the TimeMsec value.-
Methods inherited from class adams.core.base.BaseObject
compareTo, equals, getClone, getInternal, getTemplates, getUnicode, hasFavoritesSupport, hashCode, isValidUnicode, newInstance, setUnicode, toObjectArray, toObjectArray, toString, toStringArray, toStringList
-
-
-
-
Field Detail
-
INF_PAST
public static final String INF_PAST
the placeholder for "-INF" (infinity in the past).- See Also:
- Constant Field Values
-
INF_PAST_DATE
public static final String INF_PAST_DATE
the "-INF" date.- See Also:
- Constant Field Values
-
INF_FUTURE
public static final String INF_FUTURE
the placeholder for "+INF" (infinity in the future).- See Also:
- Constant Field Values
-
INF_FUTURE_DATE
public static final String INF_FUTURE_DATE
the "+INF" date.- See Also:
- Constant Field Values
-
NOW
public static final String NOW
the placeholder for "now".- See Also:
- Constant Field Values
-
START
public static final String START
the placeholder for "start".- See Also:
- Constant Field Values
-
END
public static final String END
the placeholder for "end".- See Also:
- Constant Field Values
-
FORMAT
public static final String FORMAT
the date format.- See Also:
- Constant Field Values
-
m_Format
protected static DateFormat m_Format
for formatting/parsing the dates.
-
m_Start
protected Date m_Start
the start time to use.
-
m_End
protected Date m_End
the end time to use.
-
-
Constructor Detail
-
BaseTimeMsec
public BaseTimeMsec()
Initializes the date as NOW.- See Also:
NOW
-
BaseTimeMsec
public BaseTimeMsec(String s)
Initializes the object with the date to parse.- Parameters:
s
- the date to parse
-
BaseTimeMsec
public BaseTimeMsec(Date date)
Initializes the object with the specified date.- Parameters:
date
- the date to use
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the internal object.- Overrides:
initialize
in classBaseObject
-
getFormat
protected static DateFormat getFormat()
Returns the formatter.- Returns:
- the formatter
-
setStart
public void setStart(Date value)
Sets the optional start time.- Parameters:
value
- the start time
-
getStart
public Date getStart()
Returns the optional start time.- Returns:
- the start time
-
setEnd
public void setEnd(Date value)
Sets the optional end time.- Parameters:
value
- the end time
-
getEnd
public Date getEnd()
Returns the optional end time.- Returns:
- the end time
-
parse
protected Date parse(String s, boolean quiet)
Parses the given date string.- Parameters:
s
- the date string to parsequiet
- whether to print exceptions or not- Returns:
- the parsed date, null in case of an error
-
isValid
public boolean isValid(String value)
Checks whether the string value is a valid presentation for this class.- Specified by:
isValid
in classBaseObject
- Parameters:
value
- the string value to check- Returns:
- true if the string can be parsed
-
setValue
public void setValue(String value)
Sets the string value.- Specified by:
setValue
in classBaseObject
- Parameters:
value
- the string value
-
getValue
public String getValue()
Returns the current string value.- Specified by:
getValue
in classBaseObject
- Returns:
- the string value
-
dateValue
public Date dateValue()
Returns the Date value.- Specified by:
dateValue
in interfaceDateValueSupporter
- Returns:
- the Date value
-
timeMsecValue
public TimeMsec timeMsecValue()
Returns the TimeMsec value.- Returns:
- the TimeMsec value
-
stringValue
public String stringValue()
Returns the actual Date as string.- Returns:
- the actual date as string
-
formatDateValue
public String formatDateValue(String format)
Returns the Date value formatted as a string.- Specified by:
formatDateValue
in interfaceDateValueSupporter
- Returns:
- the formatted string
-
getTipText
public String getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).- Specified by:
getTipText
in classBaseObject
- Returns:
- the tool tip
-
getGrammar
public String getGrammar()
Returns a string representation of the grammar.- Specified by:
getGrammar
in interfaceGrammarSupplier
- Returns:
- the grammar, null if not available
-
isInfinityFuture
public boolean isInfinityFuture()
Checks whether the date/time is +INF.- Returns:
- true if infinity future
-
isInfinityPast
public boolean isInfinityPast()
Checks whether the date/time is -INF.- Returns:
- true if infinity future
-
isInfinity
public boolean isInfinity()
Checks whether the date/time is -INF or +INF.- Returns:
- true if any infinity
-
now
public static BaseTimeMsec now()
Returns a new BaseTimeMsec object initialized with the NOW placeholder.- Returns:
- the BaseTimeMsec object
- See Also:
NOW
-
infinityFuture
public static BaseTimeMsec infinityFuture()
Returns a new BaseTimeMsec object initialized with the INF_FUTURE placeholder.- Returns:
- the BaseTimeMsec object
- See Also:
INF_FUTURE
-
infinityPast
public static BaseTimeMsec infinityPast()
Returns a new BaseTimeMsec object initialized with the INF_PAST placeholder.- Returns:
- the BaseTimeMsec object
- See Also:
INF_PAST
-
-