1 2 5 14 package org.jacorb.trading.db.simple.types; 15 16 import java.io.*; 17 import org.omg.CosTradingRepos.ServiceTypeRepositoryPackage.*; 18 19 public class Incarnation implements Serializable 20 { 21 private long m_high; 22 private long m_low; 23 private transient boolean m_dirty; 24 private static final long MAX_VALUE = 4294967295L; 25 26 static final long serialVersionUID = -6506601918195268342L; 27 28 29 private Incarnation(long high, long low) { 31 m_high = high; 32 m_low = low; 33 m_dirty = true; 34 } 35 36 37 public Incarnation() 38 { 39 m_high = 0; 40 m_low = 1; 41 m_dirty = true; 42 } 43 44 45 public Incarnation(IncarnationNumber inc) 46 { 47 m_high = inc.high; 48 m_low = inc.low; 49 m_dirty = true; 50 } 51 52 53 public IncarnationNumber getIncarnationNumber() 54 { 55 return new IncarnationNumber((int)m_high, (int)m_low); 56 } 57 58 59 public int compareTo(Incarnation inc) 60 { 61 int result; 62 63 if ((m_high < inc.m_high) || (m_high == inc.m_high && m_low < inc.m_low)) 64 result = -1; 65 else if (m_high == inc.m_high && m_low == inc.m_low) 66 result = 0; 67 else 68 result = 1; 69 70 return result; 71 } 72 73 74 public void increment() 75 { 76 if (m_low < MAX_VALUE) 77 m_low++; 78 else { 79 m_low = 0; 80 m_high++; 81 } 82 m_dirty = true; 83 } 84 85 86 public boolean getDirty() 87 { 88 return m_dirty; 89 } 90 91 92 public String toString() 93 { 94 return "{" + m_high + "," + m_low + "}"; 95 } 96 97 98 private void writeObject(ObjectOutputStream out) 99 throws IOException 100 { 101 out.defaultWriteObject(); 102 m_dirty = false; 103 } 104 105 106 private void readObject(ObjectInputStream in) 107 throws IOException, ClassNotFoundException 108 { 109 in.defaultReadObject(); 110 m_dirty = false; 111 } 112 113 114 142 } 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | Popular Tags |