2.17.2: 2011-06-17

net.sf.basedb.core.snapshot
Class AnnotationSnapshot

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

public class AnnotationSnapshot
extends Object
implements Serializable

Stores information about a single primary or inherited annotation or an inherited annotation set. Actual annotation values are only stored for primary annotations.

IMPORTANT NOTE TO DEVELOPERS!!

Do not forget to synchronize all serialization code and to increment the AnnotationSetSnapshot.FILE_VERSION in case the number of variables that needs serialization in this class or in the AnnotationSetSnapshot 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  int annotationId
           
private  int annotationSetId
           
private  int annotationTypeId
           
private  boolean inherited
           
private  int itemId
           
private  Item itemType
           
private static long serialVersionUID
           
private  List<? extends Serializable> values
           
 
Constructor Summary
AnnotationSnapshot()
          Create a new, empty annotation snapshot.
 
Method Summary
(package private)  void deserializeObject(ObjectInputStream in)
           
 Annotation getAnnotation(DbControl dc)
          Get the annotation this is a snapshot of.
 int getAnnotationId()
          Get the id of the annotation this is a snapshot of.
 AnnotationSet getAnnotationSet(DbControl dc)
          Get the annotation set this annotation belongs to.
 int getAnnotationSetId()
          Get the id of the annotation set this annotation belongs to.
 AnnotationType getAnnotationType(DbControl dc)
          Get the annotation type.
 int getAnnotationTypeId()
          Get the id of the annotation type.
 Annotatable getItem(DbControl dc)
          Get the item that this annotation belongs to.
 int getItemId()
          Get the id of the item this annotation belongs to.
 Item getItemType()
          Get the item type of the item this annotation belongs to.
 List<? extends Serializable> getValues()
          Get the annotation values.
 List<? extends Serializable> getValues(UnitConverter converter, Type valueType)
          Get the annotations values, optionally converted to some specific unit and type of values.
(package private)  void initInherited(AnnotationData inherited)
          Initialize the snapshot with information from the given inherited annotation.
(package private)  void initInherited(AnnotationSetData inherited)
          Initialize the snapshot with information from the given inherited annotation set.
(package private)  void initInherited(AnnotationSnapshot primary)
          Initializes this snapshot as an inherited annotation with complete data from another primary annotation snapshot.
(package private)  void initPrimary(AnnotationData primary)
          Initialize the snapshot with information from the given primary annotation.
 boolean isInherited()
          Is this annotation a primary or inherited annotation?
private  void readObject(ObjectInputStream in)
           
(package private)  void serializeObject(ObjectOutputStream out)
           
(package private)  void setItem(int itemId, Item itemType)
           
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

inherited

private transient boolean inherited

annotationId

private transient int annotationId

annotationSetId

private transient int annotationSetId

annotationTypeId

private transient int annotationTypeId

values

private transient List<? extends Serializable> values

itemId

private transient int itemId

itemType

private transient Item itemType
Constructor Detail

AnnotationSnapshot

public AnnotationSnapshot()
Create a new, empty annotation snapshot.

Method Detail

initPrimary

void initPrimary(AnnotationData primary)
Initialize the snapshot with information from the given primary annotation.

Parameters:
primary - A primary annotation

initInherited

void initInherited(AnnotationData inherited)
Initialize the snapshot with information from the given inherited annotation.

Parameters:
inherited - An inherited annotation

initInherited

void initInherited(AnnotationSetData inherited)
Initialize the snapshot with information from the given inherited annotation set.

Parameters:
inherited - An inherited annotation set

initInherited

void initInherited(AnnotationSnapshot primary)
Initializes this snapshot as an inherited annotation with complete data from another primary annotation snapshot.

Parameters:
primary - A snapshot of a primary annotation

isInherited

public boolean isInherited()
Is this annotation a primary or inherited annotation?


getAnnotationId

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

Returns:
The id or 0 if the snapshot is from an inherited annotation set

getAnnotation

public Annotation getAnnotation(DbControl dc)
Get the annotation this is a snapshot of.

Returns:
An Annotation object or null if this snapshot is from an inherited annotation set

getAnnotationSetId

public int getAnnotationSetId()
Get the id of the annotation set this annotation belongs to.


getAnnotationSet

public AnnotationSet getAnnotationSet(DbControl dc)
Get the annotation set this annotation belongs to.


getAnnotationTypeId

public int getAnnotationTypeId()
Get the id of the annotation type.

Returns:
The annotation type id, or 0 if this snapshot is from an inherited annotation set

getAnnotationType

public AnnotationType getAnnotationType(DbControl dc)
Get the annotation type.

Returns:
An AnnotationType object or null if this snapshot is from an inherited annotation set

getValues

public List<? extends Serializable> getValues()
Get the annotation values. NOTE! The values are only available for primary annotations and for inherited annotations returned by SnapshotManager.findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean)

Returns:
A list with the values

getValues

public List<? extends Serializable> getValues(UnitConverter converter,
                                              Type valueType)
Get the annotations values, optionally converted to some specific unit and type of values.

Parameters:
converter - A converter for converting (numerical) values, or null to not convert the values
valueType - The return type of the converted values (ignored if no converter is specified)
Returns:
A list with the values

getItemId

public int getItemId()
Get the id of the item this annotation belongs to. NOTE! this value is only available on annotations returned from the call to: SnapshotManager.findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean)


getItem

public Annotatable getItem(DbControl dc)
Get the item that this annotation belongs to.

Returns:
The item, or null if the item is not know

getItemType

public Item getItemType()
Get the item type of the item this annotation belongs to. NOTE! this value is only available on annotations returned from the call to: SnapshotManager.findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean)

Returns:
The item type, or null if not known

setItem

void setItem(int itemId,
             Item itemType)

serializeObject

void serializeObject(ObjectOutputStream out)
               throws IOException
Throws:
IOException

writeObject

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

deserializeObject

void deserializeObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Throws:
IOException
ClassNotFoundException

readObject

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

2.17.2: 2011-06-17