org.jboss.cache.optimistic
Class DefaultDataVersion

java.lang.Object
  extended by org.jboss.cache.optimistic.DefaultDataVersion
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, DataVersion

public class DefaultDataVersion
extends java.lang.Object
implements DataVersion, java.io.Externalizable

The default implementation of a DataVersion, uses a long to compare versions. This class is immutable. Also note that this is meant to control implicit, internal versioning. Do not attempt to instantiate or use instances of this class explicitly, via the Option.setDataVersion(DataVersion) API, as it WILL break things.

Author:
Manik Surtani (manik@jboss.org)
See Also:
Serialized Form

Field Summary
static DataVersion ZERO
          Version zero.
 
Constructor Summary
DefaultDataVersion()
          Constructs with version 0.
DefaultDataVersion(long version)
          Constructs with a version number.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 long getRawVersion()
           
 int hashCode()
           
 DataVersion increment()
          Returns a new DataVersion with a newer version number.
 boolean newerThan(DataVersion other)
          Returns true if this is a newer version than other.
 void readExternal(java.io.ObjectInput objectInput)
           
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput objectOutput)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final DataVersion ZERO
Version zero. Assign this as the first version to your data.

Constructor Detail

DefaultDataVersion

public DefaultDataVersion()
Constructs with version 0.


DefaultDataVersion

public DefaultDataVersion(long version)
Constructs with a version number.

Method Detail

increment

public DataVersion increment()
Returns a new DataVersion with a newer version number.


newerThan

public boolean newerThan(DataVersion other)
Description copied from interface: DataVersion
Returns true if this is a newer version than other. There is no guarantee that the DataVersion passed in will be of the same implementation, and as such, it is up to the implementation to perform any type checking if needed before comparison.

Specified by:
newerThan in interface DataVersion

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getRawVersion

public long getRawVersion()

writeExternal

public void writeExternal(java.io.ObjectOutput objectOutput)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput objectInput)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.