ch.ethz.iks.r_osgi.types
Class Timestamp

java.lang.Object
  extended by ch.ethz.iks.r_osgi.types.Timestamp
All Implemented Interfaces:
java.lang.Comparable

public final class Timestamp
extends java.lang.Object
implements java.lang.Comparable

Encapsulates a timestamp that can be used as attribute for a service or as part of a RemoteEvent. Timestamps consist of a physical clock timestamp and a logical time to avoid ambiguity. (Especially, if more than one event is generated within a physical tick, which is typically 50 ms on desktop computers but may be larger on small devices)

Timestamps are automatically transformed into local time whenever a RemoteEvent is received by a peer or a proxy bundle with a Timestamp attribute is generated.

Since:
0.3
Author:
Jan S. Rellermeyer, ETH Zürich.

Constructor Summary
Timestamp()
          creates an new Timestamp object with the current time.
 
Method Summary
 int compareTo(java.lang.Object o)
          compares this instance with an Object.
 boolean equals(java.lang.Object o)
          Checks, if this instance equals another Timestamp.
static Timestamp from(long timestamp)
          Get a Timestamp object from long.
static Timestamp fromString(java.lang.String timestamp)
          Get a Timestamp object from String.
 long getValue()
          Get the long value of the Timestamp instance.
 int hashCode()
          Get the hash code of the timestamp.
 java.lang.String toString()
          get a String representation of the instance.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Timestamp

public Timestamp()
creates an new Timestamp object with the current time.

Method Detail

compareTo

public int compareTo(java.lang.Object o)
compares this instance with an Object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the Object to be compared.
Returns:
an int describing the relation.
See Also:
Comparable.compareTo(Object)

toString

public java.lang.String toString()
get a String representation of the instance.

Overrides:
toString in class java.lang.Object
Returns:
the String representation.

fromString

public static Timestamp fromString(java.lang.String timestamp)
Get a Timestamp object from String.

Parameters:
timestamp - the String representation of a timestamp.
Returns:
a Timestamp instance.

from

public static Timestamp from(long timestamp)
Get a Timestamp object from long.

Parameters:
timestamp - the long representing a timestamp.
Returns:
a Timestamp instance.

getValue

public long getValue()
Get the long value of the Timestamp instance.

Returns:
the long value.

equals

public boolean equals(java.lang.Object o)
Checks, if this instance equals another Timestamp.

Overrides:
equals in class java.lang.Object
Parameters:
o - an Object. If not instance of Timestamp, false is returned.>
Returns:
true in case of equality.

hashCode

public int hashCode()
Get the hash code of the timestamp.

Overrides:
hashCode in class java.lang.Object
Returns:
the int value that represents the hash code.


Copyright © 2009 IKS, ETH Zurich. All Rights Reserved.