1 23 24 28 50 package com.sun.jts.CosTransactions; 51 52 54 import java.io.*; 55 56 66 73 class LogLSN implements Serializable { 74 75 77 static final LogLSN HEAD_LSN = new LogLSN(0xFFFFFFFF, 0xFFFFFFFF); 78 static final LogLSN TAIL_LSN = new LogLSN(0xFFFFFFFF, 0xFFFFFFFE); 79 static final LogLSN NULL_LSN = new LogLSN(0x00000000, 0x00000000); 80 static final LogLSN FIRST_LSN = new LogLSN(0x00000001, 0x00000000); 81 82 84 static final int SIZEOF = 8; 85 86 88 int offset = 0; 89 int extent = 0; 90 91 99 LogLSN() { 100 offset = 0; 101 extent = 0; 102 } 103 104 113 LogLSN( int ext, 114 int off ) { 115 offset = off; 116 extent = ext; 117 } 118 119 127 LogLSN( LogLSN lsn ) { 128 offset = lsn.offset; 129 extent = lsn.extent; 130 } 131 132 141 LogLSN( byte[] bytes, 142 int index ) { 143 offset = (bytes[index++]&255) + 144 ((bytes[index++]&255) << 8) + 145 ((bytes[index++]&255) << 16) + 146 ((bytes[index++]&255) << 24); 147 extent = (bytes[index++]&255) + 148 ((bytes[index++]&255) << 8) + 149 ((bytes[index++]&255) << 16) + 150 ((bytes[index++]&255) << 24); 151 } 152 153 161 final boolean isNULL() { 162 return offset == 0 && extent == 0; 163 } 164 165 173 final boolean equals( LogLSN other ) { 174 return offset == other.offset && extent == other.extent; 175 } 176 177 185 final boolean lessThan( LogLSN other ) { 186 return ( (offset < other.offset && extent == other.extent) || 187 extent < other.extent); 188 } 189 190 198 final boolean greaterThan( LogLSN other ) { 199 return ( (offset > other.offset && extent == other.extent) || 200 extent > other.extent); 201 } 202 203 211 final void copy( LogLSN other ) { 212 extent = other.extent; 213 offset = other.offset; 214 } 215 216 225 final int toBytes( byte[] bytes, 226 int index ) { 227 bytes[index++] = (byte) offset; 228 bytes[index++] = (byte)(offset >> 8); 229 bytes[index++] = (byte)(offset >> 16); 230 bytes[index++] = (byte)(offset >> 24); 231 bytes[index++] = (byte) extent; 232 bytes[index++] = (byte)(extent >> 8); 233 bytes[index++] = (byte)(extent >> 16); 234 bytes[index++] = (byte)(extent >> 24); 235 236 return SIZEOF; 237 } 238 239 247 public final String toString() { 248 return "LSN(ext="+extent+",off="+offset+")"; 249 } 250 } 251 | Popular Tags |