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 StringENDthe placeholder for "end".static StringFORMATthe date format.static StringINF_FUTUREthe placeholder for "+INF" (infinity in the future).static StringINF_FUTURE_DATEthe "+INF" date.static StringINF_PASTthe placeholder for "-INF" (infinity in the past).static StringINF_PAST_DATEthe "-INF" date.protected Datem_Endthe end time to use.protected static DateFormatm_Formatfor formatting/parsing the dates.protected Datem_Startthe start time to use.static StringNOWthe placeholder for "now".static StringSTARTthe 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 DatedateValue()Returns the Date value.StringformatDateValue(String format)Returns the Date value formatted as a string.DategetEnd()Returns the optional end time.protected static DateFormatgetFormat()Returns the formatter.StringgetGrammar()Returns a string representation of the grammar.DategetStart()Returns the optional start time.StringgetTipText()Returns a tool tip for the GUI editor (ignored if null is returned).StringgetValue()Returns the current string value.static BaseTimeMsecinfinityFuture()Returns a new BaseTimeMsec object initialized with the INF_FUTURE placeholder.static BaseTimeMsecinfinityPast()Returns a new BaseTimeMsec object initialized with the INF_PAST placeholder.protected voidinitialize()Initializes the internal object.booleanisInfinity()Checks whether the date/time is -INF or +INF.booleanisInfinityFuture()Checks whether the date/time is +INF.booleanisInfinityPast()Checks whether the date/time is -INF.booleanisValid(String value)Checks whether the string value is a valid presentation for this class.static BaseTimeMsecnow()Returns a new BaseTimeMsec object initialized with the NOW placeholder.protected Dateparse(String s, boolean quiet)Parses the given date string.voidsetEnd(Date value)Sets the optional end time.voidsetStart(Date value)Sets the optional start time.voidsetValue(String value)Sets the string value.StringstringValue()Returns the actual Date as string.TimeMsectimeMsecValue()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:
initializein 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:
isValidin 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:
setValuein classBaseObject- Parameters:
value- the string value
-
getValue
public String getValue()
Returns the current string value.- Specified by:
getValuein classBaseObject- Returns:
- the string value
-
dateValue
public Date dateValue()
Returns the Date value.- Specified by:
dateValuein 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:
formatDateValuein interfaceDateValueSupporter- Returns:
- the formatted string
-
getTipText
public String getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).- Specified by:
getTipTextin classBaseObject- Returns:
- the tool tip
-
getGrammar
public String getGrammar()
Returns a string representation of the grammar.- Specified by:
getGrammarin 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
-
-