Last update: 2011-06-23

org.proteios.core
Class Annotation

java.lang.Object
  extended by org.proteios.core.BasicItem<AnnotationData>
      extended by org.proteios.core.Annotation
All Implemented Interfaces:
AccessControlled, Identifiable

public class Annotation
extends BasicItem<AnnotationData>

This class represents an annotation. Annotations are user-defined properties that can be attached to Annotatable items. They can be very useful in the filtering and analysis process.

An annotation must have an AnnotationType, which controls the type of and how many values that can be attached to an annotation.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Field Summary
static Item TYPE
          The type of item represented by this class.
 
Method Summary
 AnnotationSet getAnnotationSet()
          Get the annotation set this annotation belongs to.
 AnnotationType getAnnotationType()
          Get the annotation type of this annotation.
 Item getType()
          Get the type of item represented by the object.
 List<?> getValues()
          Get the values this annotation contains.
 int getValuesVersion()
          Get the version number of the item keeping the values.
 boolean isUsed()
          Always return FALSE.
 void setAnnotationSet(AnnotationSet set)
           
 void setValue(Object value)
          Set the value of the annotation, replacing any previous values.
 void setValues(List<?> values)
          Set the values of the annotation, replacing any previous values.
 
Methods inherited from class org.proteios.core.BasicItem
checkPermission, equals, getDbControl, getId, getPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.ANNOTATION, getType()
Method Detail

getType

public Item getType()
Description copied from interface: Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.

Returns:
A value indicating the type of item

isUsed

public boolean isUsed()
               throws BaseException
Always return FALSE.

Specified by:
isUsed in class BasicItem<AnnotationData>
Returns:
TRUE if this item is used, FALSE otherwise
Throws:
BaseException

getAnnotationSet

public AnnotationSet getAnnotationSet()
                               throws PermissionDeniedException,
                                      BaseException
Get the annotation set this annotation belongs to.

Returns:
An AnnotationSet
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission for the annotation set (should never happen)
BaseException

setAnnotationSet

public void setAnnotationSet(AnnotationSet set)

getAnnotationType

public AnnotationType getAnnotationType()
                                 throws PermissionDeniedException,
                                        BaseException
Get the annotation type of this annotation.

Returns:
An AnnotationType
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission for the annotation type
BaseException

getValues

public List<?> getValues()
                  throws BaseException
Get the values this annotation contains. The values are of a Type appropriate for the given annotation type, ie. Integer object for an integer annotation type. All objects in the list are of the same type.

Returns:
A list of objects
Throws:
BaseException - If there is an error
See Also:
AnnotationType.getValueType()

getValuesVersion

public int getValuesVersion()
Get the version number of the item keeping the values. This is useful when you need to know if the annotation values has been modified by another transaction since they were read from the database. Unlike other items the version number of the annotation item doesn't change when the values are modified.


setValue

public void setValue(Object value)
              throws PermissionDeniedException,
                     InvalidDataException,
                     BaseException
Set the value of the annotation, replacing any previous values.

Parameters:
value - The new value
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission for the annotation or read permission for the annotation type
InvalidDataException - If the value isn't a valid value for the annotation type, see AnnotationType.validateAnnotationValue(Object)
BaseException - If there is another error

setValues

public void setValues(List<?> values)
               throws PermissionDeniedException,
                      InvalidDataException,
                      BaseException
Set the values of the annotation, replacing any previous values.

Parameters:
values - A list containing the new values
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission for the annotation or read permission for the annotation type
InvalidDataException - If the number of values are too many according to the AnnotationType.getMultiplicity() setting any of the values isn't a valid value for the annotation type, see AnnotationType.validateAnnotationValue(Object)
BaseException - If there is another error

Last update: 2011-06-23