KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > storage > raf > log > asynraf > LogInfo


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

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 JavaDoc {
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 JavaDoc 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 JavaDoc cce) {
117         }
118         return -1;
119     }
120
121     public String JavaDoc toString() {
122         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
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