1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache; |
8 |
| |
9 |
| |
10 |
| import java.io.Externalizable; |
11 |
| import java.io.IOException; |
12 |
| import java.io.ObjectInput; |
13 |
| import java.io.ObjectOutput; |
14 |
| import java.util.Map; |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| public class Modification implements Externalizable |
29 |
| { |
30 |
| |
31 |
| private static final long serialVersionUID = 7463314130283897197L; |
32 |
| |
33 |
| public enum ModificationType |
34 |
| { |
35 |
| PUT_KEY_VALUE, |
36 |
| PUT_DATA, |
37 |
| PUT_DATA_ERASE, |
38 |
| REMOVE_NODE, |
39 |
| REMOVE_KEY_VALUE, |
40 |
| REMOVE_DATA, |
41 |
| MOVE, |
42 |
| UNKNOWN |
43 |
| } |
44 |
| |
45 |
| private ModificationType type = ModificationType.UNKNOWN; |
46 |
| private Fqn fqn = null; |
47 |
| private Fqn fqn2 = null; |
48 |
| private Object key = null; |
49 |
| private Object value = null; |
50 |
| private Object old_value = null; |
51 |
| private Map data = null; |
52 |
| |
53 |
| |
54 |
| |
55 |
| |
56 |
406
| public Modification()
|
57 |
| { |
58 |
| } |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
42526
| public Modification(ModificationType type, Fqn fqn, Object key, Object value)
|
64 |
| { |
65 |
42526
| this.type = type;
|
66 |
42526
| this.fqn = fqn;
|
67 |
42526
| this.key = key;
|
68 |
42526
| this.value = value;
|
69 |
| } |
70 |
| |
71 |
| |
72 |
| |
73 |
| |
74 |
2051
| public Modification(ModificationType type, Fqn fqn, Object key)
|
75 |
| { |
76 |
2051
| this.type = type;
|
77 |
2051
| this.fqn = fqn;
|
78 |
2051
| this.key = key;
|
79 |
| } |
80 |
| |
81 |
| |
82 |
| |
83 |
| |
84 |
2733
| public Modification(ModificationType type, Fqn fqn, Map data)
|
85 |
| { |
86 |
2733
| this.type = type;
|
87 |
2733
| this.fqn = fqn;
|
88 |
2733
| this.data = data;
|
89 |
| } |
90 |
| |
91 |
| |
92 |
| |
93 |
| |
94 |
2370
| public Modification(ModificationType type, Fqn fqn)
|
95 |
| { |
96 |
2370
| this.type = type;
|
97 |
2370
| this.fqn = fqn;
|
98 |
| } |
99 |
| |
100 |
| |
101 |
| |
102 |
| |
103 |
6
| public Modification(ModificationType type, Fqn fqn1, Fqn fqn2)
|
104 |
| { |
105 |
6
| this.type = type;
|
106 |
6
| this.fqn = fqn1;
|
107 |
6
| this.fqn2 = fqn2;
|
108 |
| } |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
131240
| public ModificationType getType()
|
115 |
| { |
116 |
131240
| return type;
|
117 |
| } |
118 |
| |
119 |
| |
120 |
| |
121 |
| |
122 |
336
| public void setType(ModificationType type)
|
123 |
| { |
124 |
336
| this.type = type;
|
125 |
| } |
126 |
| |
127 |
| |
128 |
| |
129 |
| |
130 |
10877
| public Fqn getFqn()
|
131 |
| { |
132 |
10877
| return fqn;
|
133 |
| } |
134 |
| |
135 |
| |
136 |
| |
137 |
| |
138 |
336
| public void setFqn(Fqn fqn)
|
139 |
| { |
140 |
336
| this.fqn = fqn;
|
141 |
| } |
142 |
| |
143 |
0
| public void setFqn2(Fqn fqn2)
|
144 |
| { |
145 |
0
| this.fqn2 = fqn2;
|
146 |
| } |
147 |
| |
148 |
6
| public Fqn getFqn2()
|
149 |
| { |
150 |
6
| return fqn2;
|
151 |
| } |
152 |
| |
153 |
| |
154 |
| |
155 |
| |
156 |
4910
| public Object getKey()
|
157 |
| { |
158 |
4910
| return key;
|
159 |
| } |
160 |
| |
161 |
| |
162 |
| |
163 |
| |
164 |
194
| public void setKey(Object key)
|
165 |
| { |
166 |
194
| this.key = key;
|
167 |
| } |
168 |
| |
169 |
| |
170 |
| |
171 |
| |
172 |
2798
| public Object getValue()
|
173 |
| { |
174 |
2798
| return value;
|
175 |
| } |
176 |
| |
177 |
| |
178 |
| |
179 |
| |
180 |
164
| public void setValue(Object value)
|
181 |
| { |
182 |
164
| this.value = value;
|
183 |
| } |
184 |
| |
185 |
| |
186 |
| |
187 |
| |
188 |
4265
| public Object getOldValue()
|
189 |
| { |
190 |
4265
| return old_value;
|
191 |
| } |
192 |
| |
193 |
| |
194 |
| |
195 |
| |
196 |
4309
| public void setOldValue(Object old_value)
|
197 |
| { |
198 |
4309
| this.old_value = old_value;
|
199 |
| } |
200 |
| |
201 |
| |
202 |
| |
203 |
| |
204 |
2917
| public Map getData()
|
205 |
| { |
206 |
2917
| return data;
|
207 |
| } |
208 |
| |
209 |
| |
210 |
| |
211 |
| |
212 |
82
| public void setData(Map data)
|
213 |
| { |
214 |
82
| this.data = data;
|
215 |
| } |
216 |
| |
217 |
| |
218 |
| |
219 |
| |
220 |
70
| public void writeExternal(ObjectOutput out) throws IOException
|
221 |
| { |
222 |
70
| out.writeObject(type);
|
223 |
| |
224 |
70
| out.writeBoolean(fqn != null);
|
225 |
70
| if (fqn != null)
|
226 |
| { |
227 |
70
| fqn.writeExternal(out);
|
228 |
| } |
229 |
| |
230 |
70
| out.writeObject(key);
|
231 |
70
| out.writeObject(value);
|
232 |
70
| out.writeObject(old_value);
|
233 |
| |
234 |
70
| out.writeBoolean(data != null);
|
235 |
70
| if (data != null)
|
236 |
| { |
237 |
7
| out.writeObject(data);
|
238 |
| } |
239 |
| } |
240 |
| |
241 |
| |
242 |
| |
243 |
| |
244 |
70
| public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
|
245 |
| { |
246 |
70
| type = (ModificationType) in.readObject();
|
247 |
| |
248 |
70
| if (in.readBoolean())
|
249 |
| { |
250 |
70
| fqn = new Fqn();
|
251 |
70
| fqn.readExternal(in);
|
252 |
| } |
253 |
| |
254 |
70
| key = in.readObject();
|
255 |
70
| value = in.readObject();
|
256 |
70
| old_value = in.readObject();
|
257 |
| |
258 |
70
| if (in.readBoolean())
|
259 |
| { |
260 |
7
| data = (Map) in.readObject();
|
261 |
| } |
262 |
| } |
263 |
| |
264 |
| |
265 |
| |
266 |
| |
267 |
0
| public String toString()
|
268 |
| { |
269 |
0
| StringBuffer sb = new StringBuffer();
|
270 |
0
| sb.append(type.toString()).append(": ").append(fqn);
|
271 |
0
| if (key != null)
|
272 |
| { |
273 |
0
| sb.append("\nkey=").append(key);
|
274 |
| } |
275 |
0
| if (value != null)
|
276 |
| { |
277 |
0
| sb.append("\nvalue=").append(value);
|
278 |
| } |
279 |
0
| if (old_value != null)
|
280 |
| { |
281 |
0
| sb.append("\nold_value=").append(old_value);
|
282 |
| } |
283 |
0
| if (data != null)
|
284 |
| { |
285 |
0
| sb.append("\ndata=").append(data);
|
286 |
| } |
287 |
0
| return sb.toString();
|
288 |
| } |
289 |
| |
290 |
| } |