1 23 24 28 50 package com.sun.jts.CosTransactions; 51 52 import java.io.*; 53 54 63 class LogRecordHeader implements Serializable { 64 65 68 final static int SIZEOF = 3 * LogLSN.SIZEOF + 8; 69 70 int recordType = 0; 71 LogLSN currentLSN = null; 72 LogLSN previousLSN = null; 73 LogLSN nextLSN = null; 74 int recordLength = 0; 75 76 LogRecordHeader() { 77 currentLSN = new LogLSN(); 78 previousLSN = new LogLSN(); 79 nextLSN = new LogLSN(); 80 } 81 82 93 LogRecordHeader(byte[] bytes, int index) { 94 recordType = (bytes[index++]&255) + 95 ((bytes[index++]&255) << 8) + 96 ((bytes[index++]&255) << 16) + 97 ((bytes[index++]&255) << 24); 98 99 currentLSN = new LogLSN(bytes,index); index += LogLSN.SIZEOF; 100 previousLSN = new LogLSN(bytes,index); index += LogLSN.SIZEOF; 101 nextLSN = new LogLSN(bytes,index); index += LogLSN.SIZEOF; 102 103 recordLength = (bytes[index++]&255) + 104 ((bytes[index++]&255) << 8) + 105 ((bytes[index++]&255) << 16) + 106 ((bytes[index++]&255) << 24); 107 } 108 109 118 void copy( LogRecordHeader other) { 119 recordType = other.recordType; 120 currentLSN.copy(other.currentLSN); 121 previousLSN.copy(other.previousLSN); 122 nextLSN.copy(other.nextLSN); 123 recordLength = other.recordLength; 124 } 125 126 136 final int toBytes(byte[] bytes, int index) { 137 bytes[index++] = (byte) recordType; 138 bytes[index++] = (byte)(recordType >> 8); 139 bytes[index++] = (byte)(recordType >> 16); 140 bytes[index++] = (byte)(recordType >> 24); 141 index += currentLSN.toBytes(bytes,index); 142 index += previousLSN.toBytes(bytes,index); 143 index += nextLSN.toBytes(bytes,index); 144 bytes[index++] = (byte) recordLength; 145 bytes[index++] = (byte)(recordLength >> 8); 146 bytes[index++] = (byte)(recordLength >> 16); 147 bytes[index++] = (byte)(recordLength >> 24); 148 149 return SIZEOF; 150 } 151 152 162 public final String toString() { 163 return "LRH(type=" + recordType + ",curr=" + currentLSN + 164 ",prev=" + previousLSN + ",next=" + nextLSN + 165 ",len=" + recordLength + ")"; 166 } 167 } 168 | Popular Tags |