1 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 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 56 public Modification() 57 { 58 } 59 60 63 public Modification(ModificationType type, Fqn fqn, Object key, Object value) 64 { 65 this.type = type; 66 this.fqn = fqn; 67 this.key = key; 68 this.value = value; 69 } 70 71 74 public Modification(ModificationType type, Fqn fqn, Object key) 75 { 76 this.type = type; 77 this.fqn = fqn; 78 this.key = key; 79 } 80 81 84 public Modification(ModificationType type, Fqn fqn, Map data) 85 { 86 this.type = type; 87 this.fqn = fqn; 88 this.data = data; 89 } 90 91 94 public Modification(ModificationType type, Fqn fqn) 95 { 96 this.type = type; 97 this.fqn = fqn; 98 } 99 100 103 public Modification(ModificationType type, Fqn fqn1, Fqn fqn2) 104 { 105 this.type = type; 106 this.fqn = fqn1; 107 this.fqn2 = fqn2; 108 } 109 110 111 114 public ModificationType getType() 115 { 116 return type; 117 } 118 119 122 public void setType(ModificationType type) 123 { 124 this.type = type; 125 } 126 127 130 public Fqn getFqn() 131 { 132 return fqn; 133 } 134 135 138 public void setFqn(Fqn fqn) 139 { 140 this.fqn = fqn; 141 } 142 143 public void setFqn2(Fqn fqn2) 144 { 145 this.fqn2 = fqn2; 146 } 147 148 public Fqn getFqn2() 149 { 150 return fqn2; 151 } 152 153 156 public Object getKey() 157 { 158 return key; 159 } 160 161 164 public void setKey(Object key) 165 { 166 this.key = key; 167 } 168 169 172 public Object getValue() 173 { 174 return value; 175 } 176 177 180 public void setValue(Object value) 181 { 182 this.value = value; 183 } 184 185 188 public Object getOldValue() 189 { 190 return old_value; 191 } 192 193 196 public void setOldValue(Object old_value) 197 { 198 this.old_value = old_value; 199 } 200 201 204 public Map getData() 205 { 206 return data; 207 } 208 209 212 public void setData(Map data) 213 { 214 this.data = data; 215 } 216 217 220 public void writeExternal(ObjectOutput out) throws IOException 221 { 222 out.writeObject(type); 223 224 out.writeBoolean(fqn != null); 225 if (fqn != null) 226 { 227 fqn.writeExternal(out); 228 } 229 230 out.writeObject(key); 231 out.writeObject(value); 232 out.writeObject(old_value); 233 234 out.writeBoolean(data != null); 235 if (data != null) 236 { 237 out.writeObject(data); 238 } 239 } 240 241 244 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException 245 { 246 type = (ModificationType) in.readObject(); 247 248 if (in.readBoolean()) 249 { 250 fqn = new Fqn(); 251 fqn.readExternal(in); 252 } 253 254 key = in.readObject(); 255 value = in.readObject(); 256 old_value = in.readObject(); 257 258 if (in.readBoolean()) 259 { 260 data = (Map ) in.readObject(); 261 } 262 } 263 264 267 public String toString() 268 { 269 StringBuffer sb = new StringBuffer (); 270 sb.append(type.toString()).append(": ").append(fqn); 271 if (key != null) 272 { 273 sb.append("\nkey=").append(key); 274 } 275 if (value != null) 276 { 277 sb.append("\nvalue=").append(value); 278 } 279 if (old_value != null) 280 { 281 sb.append("\nold_value=").append(old_value); 282 } 283 if (data != null) 284 { 285 sb.append("\ndata=").append(data); 286 } 287 return sb.toString(); 288 } 289 290 } 291 | Popular Tags |