FileDocCategorySizeDatePackage
Time.javaAPI DocphoneME MR2 API (J2ME)5368Wed May 02 18:00:36 BST 2007com.sun.perseus.model

Time

public final class Time extends Object
This simple class represents the concept of time in the context of SMIL timing.

A Time can be RESOLVED, UNRESOLVED or INDEFINITE. When times are sorted, times are compared according to their type and value. The predefined UNRESOLVED and INDEFINITE values are used to characterize the special values and sorting is done with the greaterThan method.

see
SMIL 2.0 Timing and Synchronization Module"
version
$Id: Time.java,v 1.2 2006/04/21 06:39:16 st125089 Exp $

Fields Summary
public static final Time
INDEFINITE
Un-mutable Time instance used to represent the 'indefinite' time.
public static final Time
UNRESOLVED
Un-mutable Time instance used to represent the 'unresolved' time.
long
value
This Time's value.
Constructors Summary
public Time(long value)
Creates a new RESOLVED time with the given value.

param
value the new time's value.


                        
        
        this.value = value;
    
Methods Summary
public booleangreaterThan(com.sun.perseus.model.Time cmp)
Compares the input time with this instance. The UNRESOLVED value is greater than any other Time value. The INDEFINITE value is greater than any resolved value. A resolved time is greater than another resolved time if its value is greater.

param
cmp the time to compare with this instance.
return
true if this Time instance is greater than cmp.
throws
NullPointerException if cmp is null.

        if (this == UNRESOLVED) {
            return true;
        } else if (this == INDEFINITE) {
            if (cmp == UNRESOLVED) {
                return false;
            } 
            return true;
        } else {
            if (cmp == UNRESOLVED 
                ||
                cmp == INDEFINITE) {
                return false;
            }
            return value >= cmp.value;
        }
    
public booleanisResolved()

return
true if this time is resolved, i.e., if it is neither equal to UNRESOLVED nor equal to INDEFINITE

        return this != INDEFINITE && this != UNRESOLVED;
    
public booleanisSameTime(com.sun.perseus.model.Time cmp)
Checks if the input time is the same as this one.

param
cmp the object to compare to.
return
true if cmp is the same object as this one or if cmp has the same value as tis object.

        if (cmp == null) {
            return false;
        }

        if (cmp == this) {
            return true;
        }

        if (cmp.value == value) {
            return true;
        }

        return false;
    
public java.lang.StringtoString()
Debug

return
a string describing this TimeInterval

        if (this == UNRESOLVED) {
            return "Time[UNRESOLVED]";
        } else if (this == INDEFINITE) {
            return "Time[INDEFINITE]";
        } else {
            return "Time[RESOLVED, " + value + "]";
        }
    
protected static java.lang.StringtoStringTrait(com.sun.perseus.model.Time t)
Converst a Time instance to a String trait value.

param
t the time instance to convert. If null, the value 'indefinite' is returned.
return
a string trait value.

        if (t == null || Time.INDEFINITE == t) {
            return SVGConstants.SVG_INDEFINITE_VALUE;
        }

        // This should never happen because Times converted to traits
        // are times specified on timed element attributes and should
        // never be unresolved times.
        if (Time.UNRESOLVED.isSameTime(t)) {
            throw new IllegalArgumentException();
        }

        // At this point, we know we are dealing with a resolved time.
        // Returns the value in seconds.
        return (t.value / 1000f) + "s";