viper.api.time
Class Time

java.lang.Object
  extended byviper.api.time.Time
All Implemented Interfaces:
java.lang.Comparable, Incrementable, Instant, Numeric, java.io.Serializable

public class Time
extends java.lang.Object
implements Instant

Represents a unit time, usually a microsecond. Functionally equivalent to the Frame object, this type uses long integers internally to allow larger ranges of values. While it is unlikely a video will have more than 2^31 frames, it is possible that it will contain more than 2^31 nanoseconds, and this may be useful to track.

See Also:
Serialized Form

Field Summary
static Time ALPHA
          The first moment in time this object can represent.
static Time OMEGA
          The last moment in time this object can represent.
 
Constructor Summary
Time(long i)
          Construct a new Time with the given value.
 
Method Summary
 int compareTo(java.lang.Object o)
          
 double doubleValue()
          Gets the closest or most appropriate double value for this number.
 boolean equals(java.lang.Object o)
          
 float floatValue()
          Gets the closest or most appropriate float value for this number.
 long getTime()
          Gets the value of the time.
 Instant go(long diff)
          Returns an Instant diff away from this. For example, i.go(0) can return itself, and i.go(-1) is equivalent to i.previous().
 int hashCode()
          
 int intValue()
          Gets the closest or most appropriate int value for this number.
 boolean isGreater(Instant i)
          If i is a Time, tests to see that this is greater (later) than i.
 boolean isLess(Instant t)
          If i is a Time, tests to see that this is less (earlier) than i.
 long longValue()
          Gets the closest or most appropriate long value for this number.
 long minus(Instant i)
          Gets the difference between this and another instance.
 Incrementable next()
          Gets the item following this one. Should have true == a.next().prev().equals(a).
static Time parseTime(java.lang.String val)
          Parses a string in the form of an integer as a time.
 Incrementable previous()
          Gets the item before this one. Should have true == a.prev().next().equals(a).
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ALPHA

public static Time ALPHA
The first moment in time this object can represent.


OMEGA

public static Time OMEGA
The last moment in time this object can represent.

Constructor Detail

Time

public Time(long i)
Construct a new Time with the given value.

Parameters:
i - the time
Method Detail

parseTime

public static Time parseTime(java.lang.String val)
Parses a string in the form of an integer as a time.

Parameters:
val - an integer that represents an instant in time.
Returns:
new Time representation of the value stored in the String
Throws:
java.lang.IllegalArgumentException - if val isn't a valid int

getTime

public long getTime()
Gets the value of the time.

Returns:
the value of the time as a long

next

public Incrementable next()
Gets the item following this one. Should have true == a.next().prev().equals(a).

Specified by:
next in interface Incrementable
Returns:
Incrementable immediately following this one

previous

public Incrementable previous()
Gets the item before this one. Should have true == a.prev().next().equals(a).

Specified by:
previous in interface Incrementable
Returns:
Incrementable immediately prior to this one

minus

public long minus(Instant i)
Gets the difference between this and another instance.

Specified by:
minus in interface Instant
Parameters:
i - the amount to subtract
Returns:
this.value - i.value

compareTo

public int compareTo(java.lang.Object o)

Specified by:
compareTo in interface java.lang.Comparable

isGreater

public boolean isGreater(Instant i)
If i is a Time, tests to see that this is greater (later) than i.

Parameters:
i - the Time to test against.
Returns:
true iff this Time is later than i
Throws:
java.lang.ClassCastException - if i is not a Time

isLess

public boolean isLess(Instant t)
If i is a Time, tests to see that this is less (earlier) than i.

Parameters:
t - the Time to test against.
Returns:
true iff this Time is earlier than i
Throws:
java.lang.ClassCastException - if i is not a Time

equals

public boolean equals(java.lang.Object o)


toString

public java.lang.String toString()


hashCode

public int hashCode()


go

public Instant go(long diff)
Returns an Instant diff away from this. For example, i.go(0) can return itself, and i.go(-1) is equivalent to i.previous().

Specified by:
go in interface Instant
Parameters:
diff - the number of instants to move
Returns:
Instant a new instant diff from this one

longValue

public long longValue()
Gets the closest or most appropriate long value for this number.

Specified by:
longValue in interface Numeric
Returns:
the long approximation

intValue

public int intValue()
Gets the closest or most appropriate int value for this number.

Specified by:
intValue in interface Numeric
Returns:
the int approximation

doubleValue

public double doubleValue()
Gets the closest or most appropriate double value for this number.

Specified by:
doubleValue in interface Numeric
Returns:
the double approximation

floatValue

public float floatValue()
Gets the closest or most appropriate float value for this number.

Specified by:
floatValue in interface Numeric
Returns:
the float approximation