Package com.adobe.epubcheck.overlay
Class SmilClock
- java.lang.Object
-
- com.adobe.epubcheck.overlay.SmilClock
-
public class SmilClock extends java.lang.ObjectASmilClockobject is a wrapper for a SMIL clock value (time)Versions: 0.1.0 (09/02/2003) - Implemented string parsing - Implemented both toString() methods 0.1.1 (10/02/2003) - Added static method to get/set tolerance for equals() and compareTo() methods - Modified equals() and compareTo() to take tolerance value into account 0.2.0 (10/04/2003) - Added support for npt= formats - Fixed bug in SmilClock(double) constructor - Fixed nasty bug in SmilClock(String) constructor 1.0.1 (11/01/2004) - Fixed bug in milliseconds parsing in SmilClock(String s); now handles values with more/less than 3 digits - Fixed bug in toString(int format) that caused milliseconds to lose leading zeroes 1.0.2 (11/06/2005) Markus - Added optimization: patterns compiled and static 1.0.3 (21/06/2005) Markus - Added secondsValueRounded 1.0.4 (10/02/2006) Linus - Fixed locale bug in toString: now using DecimalFormat instead of NumberFormat 1.0.5 (20/06/2006 Laurie - Added HUMAN_READABLE static int toString(int) 1.1.0 (14/11/2006) Linus - Use BigDecimal instead of double to avoid rounding errors
-
-
Field Summary
Fields Modifier and Type Field Description static intFULLprivate static java.util.regex.PatternfullClockPatternstatic intHUMAN_READABLEprivate static longmsecToleranceprivate ClipTimemsecValuestatic intPARTIALprivate static java.util.regex.PatternpartialClockPatternstatic intRAW_TIMECOUNT_TRUNCATED_MSCstatic intTIMECOUNTstatic intTIMECOUNT_HRstatic intTIMECOUNT_MINstatic intTIMECOUNT_MSECstatic intTIMECOUNT_SECprivate static java.util.regex.PatterntimecountClockPattern
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SmilClockaddTime(SmilClock addTime)intcompareTo(java.lang.Object otherObject)intcompareTo(java.lang.Object otherObject, long msecTolerance)booleanequals(java.lang.Object otherObject)booleaneqWithinTolerance(SmilClock other, long msecTolerance)SmilClockfloorToMSPrecision()private ClipTimegetTimeWOPrecisionLoss()Returns clock value in millisecondsstatic longgetTolerance()Returns tolerance settinglongmillisecondsValue()Deprecated.longmillisecondsValueAsLong()booleannotSet()SmilClockroundToMSPrecision()doublesecondsValue()Returns clock value in secondslongsecondsValueRounded()Deprecated.doublesecondsValueRoundedDouble()Returns clock value in seconds, rounded to full secondsstatic voidsetTolerance(long msec)Sets tolerance for comparisons and equality testing.SmilClocksubtractTime(SmilClock subtractTime)java.lang.StringtoString()Returns clock value in full clock value format (default)java.lang.StringtoString(int format)Returns clock value in specified format
-
-
-
Field Detail
-
fullClockPattern
private static java.util.regex.Pattern fullClockPattern
-
partialClockPattern
private static java.util.regex.Pattern partialClockPattern
-
timecountClockPattern
private static java.util.regex.Pattern timecountClockPattern
-
FULL
public static final int FULL
- See Also:
- Constant Field Values
-
PARTIAL
public static final int PARTIAL
- See Also:
- Constant Field Values
-
TIMECOUNT
public static final int TIMECOUNT
- See Also:
- Constant Field Values
-
TIMECOUNT_MSEC
public static final int TIMECOUNT_MSEC
- See Also:
- Constant Field Values
-
TIMECOUNT_SEC
public static final int TIMECOUNT_SEC
- See Also:
- Constant Field Values
-
TIMECOUNT_MIN
public static final int TIMECOUNT_MIN
- See Also:
- Constant Field Values
-
TIMECOUNT_HR
public static final int TIMECOUNT_HR
- See Also:
- Constant Field Values
-
HUMAN_READABLE
public static final int HUMAN_READABLE
- See Also:
- Constant Field Values
-
RAW_TIMECOUNT_TRUNCATED_MSC
public static final int RAW_TIMECOUNT_TRUNCATED_MSC
- See Also:
- Constant Field Values
-
msecValue
private final ClipTime msecValue
-
msecTolerance
private static long msecTolerance
-
-
Constructor Detail
-
SmilClock
public SmilClock(java.lang.String s) throws java.lang.NumberFormatException- Parameters:
s- A string representation of the SMIL clock value in any accepted format- Throws:
java.lang.NumberFormatException- if the string is not a legal SMIL clock value format
-
SmilClock
public SmilClock()
-
SmilClock
private SmilClock(ClipTime clipTime)
- Parameters:
msec- Time value in milliseconds
-
SmilClock
public SmilClock(double sec)
- Parameters:
sec- Time value in seconds
-
SmilClock
@Deprecated public SmilClock(long msec)
Deprecated.Just for compability, broken by design really The SmilClock should only be initialized by values of "seconds", another basic type, implying another unit type, milliseconds is way to dangerous!- Parameters:
msec- Time value in milliseconds
-
-
Method Detail
-
notSet
public boolean notSet()
-
toString
public java.lang.String toString()
Returns clock value in full clock value format (default)- Overrides:
toStringin classjava.lang.Object- Returns:
- String in full clock value format (HH:MM:SS.mmm)
-
toString
public java.lang.String toString(int format)
Returns clock value in specified format- Parameters:
format- Format code (FULL, PARTIAL, TIMECOUNT)- Returns:
- String with value in named format
-
getTimeWOPrecisionLoss
private ClipTime getTimeWOPrecisionLoss()
Returns clock value in milliseconds
-
millisecondsValue
@Deprecated public long millisecondsValue()
Deprecated.Just for compability, broken by design really- Returns:
- clock value in milliseconds
-
millisecondsValueAsLong
public long millisecondsValueAsLong()
-
secondsValueRounded
@Deprecated public long secondsValueRounded()
Deprecated.Just for compability, broken by design really Enhance type system even further, get rid of log/double altogheter and use some class "Seconds" instead!- Returns:
-
secondsValue
public double secondsValue()
Returns clock value in seconds- Returns:
- clock value in seconds
-
secondsValueRoundedDouble
public double secondsValueRoundedDouble()
Returns clock value in seconds, rounded to full seconds- Returns:
- clock value in seconds, rounded to full seconds
-
roundToMSPrecision
public SmilClock roundToMSPrecision()
-
floorToMSPrecision
public SmilClock floorToMSPrecision()
-
equals
public boolean equals(java.lang.Object otherObject)
- Overrides:
equalsin classjava.lang.Object
-
eqWithinTolerance
public boolean eqWithinTolerance(SmilClock other, long msecTolerance)
-
compareTo
public int compareTo(java.lang.Object otherObject) throws java.lang.ClassCastException- Throws:
java.lang.ClassCastException
-
compareTo
public int compareTo(java.lang.Object otherObject, long msecTolerance) throws java.lang.ClassCastException- Throws:
java.lang.ClassCastException
-
setTolerance
public static void setTolerance(long msec)
Sets tolerance for comparisons and equality testing.When comparing two values, if they differ by less than the given tolerance, they will be evaluated as equal to one another.
- Parameters:
msec- Tolerance value in milliseconds
-
getTolerance
public static long getTolerance()
Returns tolerance setting- Returns:
- Current tolerance value in milliseconds
-
-