[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Wed Dec 6 07:54:46 EST 2006
User: msurtani
Date: 06/12/06 07:54:46
Modified: src/org/jboss/cache GlobalTransaction.java
Log:
JBCACHE-895
Revision Changes Path
1.16 +52 -34 JBossCache/src/org/jboss/cache/GlobalTransaction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: GlobalTransaction.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/GlobalTransaction.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- GlobalTransaction.java 6 Nov 2006 23:34:08 -0000 1.15
+++ GlobalTransaction.java 6 Dec 2006 12:54:46 -0000 1.16
@@ -22,9 +22,10 @@
*
* @author <a href="mailto:bela at jboss.org">Bela Ban</a> Apr 12, 2003
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
- * @version $Revision: 1.15 $
+ * @version $Revision: 1.16 $
*/
-public class GlobalTransaction implements Externalizable {
+public class GlobalTransaction implements Externalizable
+{
private static final long serialVersionUID = 8011434781266976149L;
@@ -35,7 +36,7 @@
private transient boolean remote = false;
// cache the hashcode
- private transient int hash_code=-1; // in the worst case, hashCode() returns 0, then increases, so we're safe here
+ private transient int hash_code = -1; // in the worst case, hashCode() returns 0, then increases, so we're safe here
/**
* empty ctor used by externalization
@@ -46,11 +47,12 @@
private GlobalTransaction(Address addr)
{
- this.addr=addr;
- id=newId();
+ this.addr = addr;
+ id = newId();
}
- private static synchronized long newId() {
+ private static synchronized long newId()
+ {
return ++sid;
}
@@ -59,7 +61,8 @@
return new GlobalTransaction(addr);
}
- public Object getAddress() {
+ public Object getAddress()
+ {
return addr;
}
@@ -68,55 +71,70 @@
addr = address;
}
- public long getId() {
+ public long getId()
+ {
return id;
}
- public int hashCode() {
- if(hash_code == -1)
+ public int hashCode()
{
- hash_code=(addr != null ? addr.hashCode() : 0) + (int)id;
+ if (hash_code == -1)
+ {
+ hash_code = (addr != null ? addr.hashCode() : 0) + (int) id;
}
return hash_code;
}
- public boolean equals(Object other) {
+ public boolean equals(Object other)
+ {
if (this == other)
return true;
- if(!(other instanceof GlobalTransaction))
+ if (!(other instanceof GlobalTransaction))
return false;
return compareTo(other) == 0;
}
- public int compareTo(Object o) {
+ public int compareTo(Object o)
+ {
GlobalTransaction other;
int comp;
- if(o == null || !(o instanceof GlobalTransaction))
+ if (o == null || !(o instanceof GlobalTransaction))
throw new ClassCastException("GlobalTransaction.compareTo(): other object is " + o);
- other=(GlobalTransaction)o;
- comp=addr != null ? addr.compareTo(other.addr) : 0;
- if(comp == 0)
+ other = (GlobalTransaction) o;
+ if (addr == null && other.addr == null)
+ comp = 0;
+ else if (addr != null && other.addr == null)
+ comp = 1;
+ else if (addr == null && other.addr != null)
+ comp = -1;
+ else
+ comp = addr.compareTo(other.addr);
+
+ if (comp == 0)
{
- if(id < other.getId()) comp = -1;
- else if(id > other.getId()) comp = 1;
+ if (id < other.getId()) comp = -1;
+ else if (id > other.getId()) comp = 1;
}
return comp;
}
- public String toString() {
- StringBuffer sb=new StringBuffer();
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
sb.append("GlobalTransaction:<").append(addr).append(">:").append(id);
return sb.toString();
}
- public void writeExternal(ObjectOutput out) throws IOException {
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
out.writeObject(addr);
out.writeLong(id);
// out.writeInt(hash_code);
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- addr = (Address)in.readObject();
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ addr = (Address) in.readObject();
id = in.readLong();
hash_code = -1;
}
More information about the jboss-cvs-commits
mailing list