1 24 package org.objectweb.jalisto.se.storage.raf.log.asynraf; 25 26 import org.objectweb.jalisto.se.impl.InFileAddress; 27 28 public class LogInfo implements Comparable { 29 30 public byte[] getOldValue() { 31 return oldValue; 32 } 33 34 public void setOldValue(byte[] oldValue) { 35 this.oldValue = oldValue; 36 } 37 38 public long getOldValueAddress() { 39 return oldValueAddress; 40 } 41 42 public void setOldValueAddress(long oldValueAddress) { 43 this.oldValueAddress = oldValueAddress; 44 } 45 46 public long getOldValueLength() { 47 if (oldValue != null) { 48 return oldValue.length; 49 } 50 return oldValueLength; 51 } 52 53 public void setOldValueLength(long oldValueLength) { 54 this.oldValueLength = oldValueLength; 55 } 56 57 public byte[] getValue() { 58 return value; 59 } 60 61 public void setValue(byte[] value) { 62 this.value = value; 63 } 64 65 public long getValueAddress() { 66 return valueAddress; 67 } 68 69 public void setValueAddress(long valueAddress) { 70 this.valueAddress = valueAddress; 71 } 72 73 public long getValueLength() { 74 if (value != null) { 75 return value.length; 76 } 77 return valueLength; 78 } 79 80 public void setValueLength(long valueLength) { 81 this.valueLength = valueLength; 82 } 83 84 public LogInfo(short actionType, InFileAddress ifa, int index) { 85 this.actionType = actionType; 86 this.ifa = ifa; 87 this.index = index; 88 } 89 90 public short getActionType() { 91 return actionType; 92 } 93 94 public InFileAddress getIfa() { 95 return ifa; 96 } 97 98 public int getIndex() { 99 return index; 100 } 101 102 public void setIndex(int index) { 103 this.index = index; 104 } 105 106 public int compareTo(Object object) { 107 try { 108 LogInfo candidate = (LogInfo) object; 109 if (this.index < candidate.index) { 110 return -1; 111 } else if (this.index == candidate.index) { 112 return 0; 113 } else { 114 return 1; 115 } 116 } catch (ClassCastException cce) { 117 } 118 return -1; 119 } 120 121 public String toString() { 122 StringBuffer sb = new StringBuffer (); 123 if (actionType == INSERT_TYPE) { 124 sb.append("insert:"); 125 } else if (actionType == UPDATE_TYPE) { 126 sb.append("update:"); 127 } else { 128 sb.append("delete:"); 129 } 130 sb.append(ifa); 131 return sb.toString(); 132 } 133 134 private short actionType; 135 private InFileAddress ifa; 136 private long valueAddress; 137 private long valueLength; 138 private byte[] value; 139 private long oldValueAddress; 140 private long oldValueLength; 141 private byte[] oldValue; 142 143 private int index; 144 145 public final static short INSERT_TYPE = 44; 146 public final static short UPDATE_TYPE = 64; 147 public final static short DELETE_TYPE = 97; 148 149 } 150 | Popular Tags |