2.17.2: 2011-06-17

net.sf.basedb.core.snapshot
Class AnnotationSetSnapshot

java.lang.Object
  extended by net.sf.basedb.core.snapshot.AnnotationSetSnapshot
All Implemented Interfaces:
Serializable

public class AnnotationSetSnapshot
extends Object
implements Serializable

A snapshot of an annotation set that is used to store information as a file. This will make it quicker to load annotation values than if we have to do it from the database each time. The snapshot will store information about:

The reason that the snapshot doesn't include values for inherited annotations is that it is better to just store a reference to the annotation set the annotations are inherited from. The values can then be loaded from the referenced snapshot. This design makes it easier to "invalidate" (eg. delete the serialized file) a cached snapshot when an annotation has been modified. We only have to delete the file that is associated with the primary annotation set.

IMPORTANT NOTE TO DEVELOPERS!!

Do not forget to synchronize all serialization code and to increment the FILE_VERSION in case the number of variables that needs serialization in this class or in the AnnotationSnapshot changes.

Version:
2.14
Author:
Nicklas
See Also:
Serialized Form
Last modified
$Date: 2010-08-13 10:50:27 +0200 (Fri, 13 Aug 2010) $

Field Summary
private  List<AnnotationSnapshot> annotations
           
private  int annotationSetId
           
private  long created
           
static int FILE_VERSION
          The version number for the file format in use when serializing this data.
private  int itemId
           
private  Item itemType
           
private static long serialVersionUID
           
 
Constructor Summary
AnnotationSetSnapshot()
          Creates a new, empty snapshot.
 
Method Summary
(package private)  List<AnnotationSnapshot> getAnnotations()
          Get a list with the all annotations in this snapshot.
 AnnotationSet getAnnotationSet(DbControl dc)
          Get the annotation set this is a snapshot of.
 int getAnnotationSetId()
          Get the id of the annotation set this is a snapshot of.
 Annotatable getItem(DbControl dc)
          Get item the annotations belong to.
 int getItemId()
          Get the ID of the item the annotations in this snapshot belong to.
 Item getItemType()
          Get the item type of the item the annotations in this snapshot belong to.
 int getSize()
          Get the number of annotations.
 Date getSnapshotDate()
          Get the date and time this snapshot was created.
 void init(AnnotationSetData set)
          Initialise the snapshot with data from the given annotation set, including values for all primary annotations and information about inherited annotations and annotation sets.
private  void readObject(ObjectInputStream in)
           
private  void writeObject(ObjectOutputStream out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

FILE_VERSION

public static final int FILE_VERSION
The version number for the file format in use when serializing this data. If the format changes in an incompatible way, this number must be increased. This will make sure that the old files are not used and that new files are generated instead.

See Also:
Constant Field Values

created

private transient long created

annotationSetId

private transient int annotationSetId

itemId

private transient int itemId

itemType

private transient Item itemType

annotations

private transient List<AnnotationSnapshot> annotations
Constructor Detail

AnnotationSetSnapshot

public AnnotationSetSnapshot()
Creates a new, empty snapshot.

Method Detail

init

public void init(AnnotationSetData set)
Initialise the snapshot with data from the given annotation set, including values for all primary annotations and information about inherited annotations and annotation sets.


getSnapshotDate

public Date getSnapshotDate()
Get the date and time this snapshot was created.


getItemId

public int getItemId()
Get the ID of the item the annotations in this snapshot belong to.


getItem

public Annotatable getItem(DbControl dc)
Get item the annotations belong to.

Parameters:
dc - A DbControl to use for database access

getItemType

public Item getItemType()
Get the item type of the item the annotations in this snapshot belong to.


getSize

public int getSize()
Get the number of annotations.


getAnnotations

List<AnnotationSnapshot> getAnnotations()
Get a list with the all annotations in this snapshot.


getAnnotationSetId

public int getAnnotationSetId()
Get the id of the annotation set this is a snapshot of.


getAnnotationSet

public AnnotationSet getAnnotationSet(DbControl dc)
Get the annotation set this is a snapshot of.


writeObject

private void writeObject(ObjectOutputStream out)
                  throws IOException
Throws:
IOException

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Throws:
IOException
ClassNotFoundException

2.17.2: 2011-06-17