com.novell.service.nds
Class NdsTimestamp

java.lang.Object
  |
  +--com.novell.service.nds.NdsTimestamp

public class NdsTimestamp
extends java.lang.Object
implements NdsAttributeValue, , java.lang.Cloneable, java.io.Serializable

Provides access to attribute values of the Timestamp syntax. It is used for attributes whose values mark the time when a particular event occurred or will occur. A time stamp value has three components:

  1. The wholeSeconds field consists of the whole number of seconds, where zero equals 12:00 midnight, January 1, 1970, UTC.
  2. The replicaNum field identifies the server that minted the timestamp. A replica number is assigned whenever a replica is created on a server.
  3. The eventID field is an integer that orders events occurring within the same whole-second interval. The event number restarts at one for each new second.

The initial NULL value of a time stamp has seconds = 1 and event = 0. Values can be skipped, but must not be reused. An unknown event is coded as 0xFFFF.

Time stamps can be compared for equality and for ordering. Two Timestamp values are matched for equality by comparing the whole seconds fields and then the event fields. If the whole seconds fields are unequal, order is determined by that field alone. If the seconds fields are equal and the event fields are unequal, order is determined by the event fields. If both fields are equal, the time stamps are equal. For ordering comparisons, the Timestamp value is treated as a 64-bit unsigned integer, with seconds as most significant.

Matching Rules: Equality and Ordering

See Also:
NdsSyntaxId

Constructor Summary
NdsTimestamp(long wholeSeconds, int eventId, int replicaNumber)
          Constructs an NdsTimestamp object based on the specified wholeSeconds, eventId, and replicaNumber parameters.
 
Method Summary
 boolean approximate(java.lang.Object anObject)
          Compares two Objects using the approximate matching rule.
 java.lang.Object clone()
          Creates a new object of the same class as this object.
 int compareTo(java.lang.Object anObject)
          Compares two objects for ordering, or compares two strings lexicographically.
 int count()
          Returns the number of elements in this sequence.
 boolean equals(java.lang.Object anObject)
          Compares two Objects for equality.
 java.util.Date getDate()
          Returns the Date stored as a Date value in the object data member.
 int getEventId()
          Returns event ID stored as an int value in the object data member.
 java.util.GregorianCalendar getGregorianCalendar()
          Returns the GregorianCalendar value stored in the object data member.
 int getNdsSyntaxId()
          Returns the int that represents the NDS syntax ID.
 int getReplicaNumber()
          Returns the replica number stored as an int value in the object data member.
  getValue(java.lang.String compositeId)
          Returns a SchemaValue object based on the given passed-in string containing the element value.
 java.util.Enumeration getValueIds()
          Returns an Enumeration of composite IDs.
 java.util.Enumeration getValues()
          Returns an enumeration of the elements in this composite.
 long getWholeSeconds()
          Returns the whole seconds stored as a long value in the object data member.
 boolean supportsMatchingRules(int matchingRules)
          Checks to see if this object supports the specified matching rules.
 java.lang.String toString()
          Generates a string representation of the object.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NdsTimestamp

public NdsTimestamp(long wholeSeconds,
                    int eventId,
                    int replicaNumber)
Constructs an NdsTimestamp object based on the specified wholeSeconds, eventId, and replicaNumber parameters.
Parameters:
wholeSeconds - The whole number of seconds stored as a long value.
eventId - An integer that orders events occurring within the same whole-second interval stored as an int value.
replicaNumber - The replica number identifying the server that crated the timestamp stored as an int value.
Method Detail

compareTo

public int compareTo(java.lang.Object anObject)
              throws java.lang.Exception
Compares two objects for ordering, or compares two strings lexicographically. For the Timestamp syntax, the compareTo method compares this NDS Object with a reference NDS Object contained in the anObject parameter. The comparison is done according to the ordering matching rule for this syntax.
Parameters:
anObject - The reference NDS Object with which to compare.
Returns:
An int set to 0 if the reference Object is equal to this Object; an int <0 if the reference Object is less than this Object; an int >0 if the reference Object is greater than this Object.
Throws:
java.lang.IllegalArgumentException - The passed-in object is of a different type than this NDS Object.

equals

public boolean equals(java.lang.Object anObject)
Compares two Objects for equality. The equals method compares this object value with the value of the reference object in the anObject parameter.

The equals method implements the most discriminating possible equivalence relation on objects; that is, for any reference values X and Y, this method returns TRUE if and only if X and Y refer to the same object (X==Y has the value TRUE).

Parameters:
anObject - The reference object with which to compare.
Returns:
A boolean set to TRUE if and only if the argument is not NULL and is an NDS integer object that contains the same value as this object, otherwise set to FALSE.
Overrides:
equals in class java.lang.Object

count

public int count()
Returns the number of elements in this sequence.
Specified by:
count in interface
Returns:
The number of elements in this sequence as an int.

getValue

public  getValue(java.lang.String compositeId)
Returns a SchemaValue object based on the given passed-in string containing the element value. The SchemaValue object is a Java language data type.
Specified by:
getValue in interface
Parameters:
compositeId - The passed-in string containing the element value.
Returns:
The SchemaValue object containing the wholeSeconds, replicaNumber, and eventId, or NULL.

getValueIds

public java.util.Enumeration getValueIds()
Returns an Enumeration of composite IDs.
Specified by:
getValueIds in interface
Returns:
An Enumeration of composite IDs.

getValues

public java.util.Enumeration getValues()
Returns an enumeration of the elements in this composite.
Specified by:
getValues in interface
Returns:
An enumeration of the composite elements (wholeSeconds, replicaNumber and eventId).

approximate

public boolean approximate(java.lang.Object anObject)
                    throws java.lang.Exception
Compares two Objects using the approximate matching rule. The approximate method does not apply to the Timestamp syntax because this syntax does not support the approximate equals matching rule.
Specified by:
approximate in interface NdsAttributeValue

getNdsSyntaxId

public int getNdsSyntaxId()
Returns the int that represents the NDS syntax ID.
Specified by:
getNdsSyntaxId in interface NdsAttributeValue
Returns:
The syntax ID as an int.

supportsMatchingRules

public boolean supportsMatchingRules(int matchingRules)
Checks to see if this object supports the specified matching rules. The Timestamp syntax supports the equality and ordering matching rules.
Specified by:
supportsMatchingRules in interface NdsAttributeValue
Parameters:
matchingRules - The set of matching rules to check.
Returns:
A Boolean set to TRUE if the matching rules for this object are equal to the matchingRules parameter.

clone

public java.lang.Object clone()
Creates a new object of the same class as this object. It then initializes each of the new object's fields by assigning them the same value as the corresponding fields in this object. No constructor is called.
Returns:
A clone of this object instance containing the cloned syntax.

toString

public java.lang.String toString()
Generates a string representation of the object. It returns a string that textually represents the object. The result should be a concise but informative representation that is easy to read.
Returns:
The String representation of the object.
Overrides:
toString in class java.lang.Object

getWholeSeconds

public long getWholeSeconds()
Returns the whole seconds stored as a long value in the object data member.
Returns:
The whole seconds as a long value.

getReplicaNumber

public int getReplicaNumber()
Returns the replica number stored as an int value in the object data member.
Returns:
The replica number as an int value.

getEventId

public int getEventId()
Returns event ID stored as an int value in the object data member.
Returns:
The Event ID as an int value.

getDate

public java.util.Date getDate()
Returns the Date stored as a Date value in the object data member. It converts time from milliseconds to seconds.
Returns:
The date and time as a Date value.

getGregorianCalendar

public java.util.GregorianCalendar getGregorianCalendar()
Returns the GregorianCalendar value stored in the object data member. It converts the date from standard calendar to Gregorian calendar.
Returns:
The GregorianCalendar date value.