home *** CD-ROM | disk | FTP | other *** search
- package java.rmi.server;
-
- import java.io.DataInput;
- import java.io.DataOutput;
- import java.io.IOException;
- import java.io.Serializable;
-
- public final class UID implements Serializable {
- private int unique;
- private long time;
- private short count;
- private static int hostUnique = getHostUniqueNum();
- private static long lastTime = System.currentTimeMillis();
- private static short lastCount = Short.MIN_VALUE;
- private static Object mutex = new Object();
- private static long ONE_SECOND = 1000L;
-
- private static int getHostUniqueNum() {
- return (new Object()).hashCode();
- }
-
- public UID() {
- Object var1 = mutex;
- synchronized(var1){}
-
- try {
- if (lastCount == 32767) {
- boolean var3 = false;
-
- while(!var3) {
- this.time = System.currentTimeMillis();
- if (this.time < lastTime + ONE_SECOND) {
- try {
- Thread.currentThread();
- Thread.sleep(ONE_SECOND);
- } catch (InterruptedException var6) {
- }
- } else {
- lastTime = this.time;
- lastCount = Short.MIN_VALUE;
- var3 = true;
- }
- }
- } else {
- this.time = lastTime;
- }
-
- this.unique = hostUnique;
- short var10001 = lastCount;
- lastCount = (short)(var10001 + 1);
- this.count = var10001;
- } catch (Throwable var7) {
- throw var7;
- }
-
- }
-
- public UID(short var1) {
- this.unique = 0;
- this.time = 0L;
- this.count = var1;
- }
-
- private UID(int var1, long var2, short var4) {
- this.unique = var1;
- this.time = var2;
- this.count = var4;
- }
-
- public int hashCode() {
- return (int)this.time + this.count;
- }
-
- public boolean equals(Object var1) {
- if (var1 != null && var1 instanceof UID) {
- UID var2 = (UID)var1;
- return this.unique == var2.unique && this.count == var2.count && this.time == var2.time;
- } else {
- return false;
- }
- }
-
- public String toString() {
- return Integer.toString(this.unique, 16) + ":" + Long.toString(this.time, 16) + ":" + Integer.toString(this.count, 16);
- }
-
- public void write(DataOutput var1) throws IOException {
- var1.writeInt(this.unique);
- var1.writeLong(this.time);
- var1.writeShort(this.count);
- }
-
- public static UID read(DataInput var0) throws IOException {
- int var1 = var0.readInt();
- long var2 = var0.readLong();
- short var4 = var0.readShort();
- return new UID(var1, var2, var4);
- }
- }
-