Changeset 5124
- Timestamp:
- Oct 9, 2009, 1:20:25 PM (14 years ago)
- Location:
- trunk/src/core/net/sf/basedb/core/snapshot
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/snapshot/AnnotationSetSnapshot.java
r5120 r5124 22 22 package net.sf.basedb.core.snapshot; 23 23 24 import java.io.IOException; 24 25 import java.io.Serializable; 25 26 import java.util.ArrayList; … … 53 54 when an annotation has been modified. We only have to delete the file 54 55 that is associated with the primary annotation set. 56 <p> 57 <b>IMPORTANT NOTE TO DEVELOPERS!!</b> 58 <p> 59 Do not forget to synchronize all serialization code and to increment 60 the {@link #FILE_VERSION} in case the number of variables that needs 61 serialization in this class or in the {@link AnnotationSnapshot} changes. 55 62 56 63 @author Nicklas … … 72 79 public static final int FILE_VERSION = 1; 73 80 74 private long created;75 private int annotationSetId;76 private int itemId;77 private Item itemType;78 private List<AnnotationSnapshot> annotations;81 private transient long created; 82 private transient int annotationSetId; 83 private transient int itemId; 84 private transient Item itemType; 85 private transient List<AnnotationSnapshot> annotations; 79 86 80 87 /** … … 188 195 } 189 196 197 private void writeObject(java.io.ObjectOutputStream out) 198 throws IOException 199 { 200 out.writeLong(created); 201 out.writeInt(annotationSetId); 202 out.writeInt(itemId); 203 out.writeInt(itemType.getValue()); 204 out.writeInt(annotations == null ? 0 : annotations.size()); 205 if (annotations != null) 206 { 207 for (AnnotationSnapshot tmp : annotations) 208 { 209 tmp.writeObject(out); 210 } 211 } 212 } 213 private void readObject(java.io.ObjectInputStream in) 214 throws IOException, ClassNotFoundException 215 { 216 created = in.readLong(); 217 annotationSetId = in.readInt(); 218 itemId = in.readInt(); 219 itemType = Item.fromValue(in.readInt()); 220 int numAnnotations = in.readInt(); 221 annotations = new ArrayList<AnnotationSnapshot>(numAnnotations); 222 for (int i = 0; i < numAnnotations; ++i) 223 { 224 AnnotationSnapshot tmp = new AnnotationSnapshot(); 225 tmp.readObject(in); 226 annotations.add(tmp); 227 } 228 } 229 190 230 } -
trunk/src/core/net/sf/basedb/core/snapshot/AnnotationSnapshot.java
r5123 r5124 22 22 package net.sf.basedb.core.snapshot; 23 23 24 import java.io.IOException; 24 25 import java.io.Serializable; 25 26 import java.util.ArrayList; … … 41 42 annotation or an inherited annotation set. Actual 42 43 annotation values are only stored for primary annotations. 44 <p> 45 <b>IMPORTANT NOTE TO DEVELOPERS!!</b> 46 <p> 47 Do not forget to synchronize all serialization code and to increment 48 the {@link AnnotationSetSnapshot#FILE_VERSION} in case the number of variables 49 that needs serialization in this class or in the {@link AnnotationSetSnapshot} 50 changes. 43 51 44 52 @author Nicklas … … 52 60 private static final long serialVersionUID = -4919156087324273194L; 53 61 54 private boolean inherited;55 private int annotationId;56 private int annotationSetId;57 private int annotationTypeId;58 private List<? extends Serializable> values;62 private transient boolean inherited; 63 private transient int annotationId; 64 private transient int annotationSetId; 65 private transient int annotationTypeId; 66 private transient List<? extends Serializable> values; 59 67 private transient int itemId; 60 68 private transient Item itemType; … … 259 267 } 260 268 269 void writeObject(java.io.ObjectOutputStream out) 270 throws IOException 271 { 272 out.writeBoolean(inherited); 273 out.writeInt(annotationId); 274 out.writeInt(annotationSetId); 275 out.writeInt(annotationTypeId); 276 out.writeInt(values == null ? 0 : values.size()); 277 if (values != null) 278 { 279 for (Serializable tmp : values) 280 { 281 out.writeObject(tmp); 282 } 283 } 284 } 285 void readObject(java.io.ObjectInputStream in) 286 throws IOException, ClassNotFoundException 287 { 288 inherited = in.readBoolean(); 289 annotationId = in.readInt(); 290 annotationSetId = in.readInt(); 291 annotationTypeId = in.readInt(); 292 int numValues = in.readInt(); 293 if (numValues > 0) 294 { 295 List<Serializable> values = new ArrayList<Serializable>(numValues); 296 for (int i = 0; i < numValues; ++i) 297 { 298 values.add((Serializable)in.readObject()); 299 } 300 this.values = values; 301 } 302 } 303 261 304 }
Note: See TracChangeset
for help on using the changeset viewer.