Class SmilClock

java.lang.Object
com.adobe.epubcheck.overlay.SmilClock

public class SmilClock extends Object
A SmilClock object 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 Details

  • Constructor Details

    • SmilClock

      public SmilClock(String s) throws NumberFormatException
      Parameters:
      s - A string representation of the SMIL clock value in any accepted format
      Throws:
      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 Details

    • addTime

      public SmilClock addTime(SmilClock addTime)
    • subtractTime

      public SmilClock subtractTime(SmilClock subtractTime)
    • notSet

      public boolean notSet()
    • toString

      public String toString()
      Returns clock value in full clock value format (default)
      Overrides:
      toString in class Object
      Returns:
      String in full clock value format (HH:MM:SS.mmm)
    • toString

      public 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(Object otherObject)
      Overrides:
      equals in class Object
    • eqWithinTolerance

      public boolean eqWithinTolerance(SmilClock other, long msecTolerance)
    • compareTo

      public int compareTo(Object otherObject) throws ClassCastException
      Throws:
      ClassCastException
    • compareTo

      public int compareTo(Object otherObject, long msecTolerance) throws ClassCastException
      Throws:
      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