|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.BasicItem<AnnotationData> net.sf.basedb.core.Annotation
public class Annotation
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.
Nested Class Summary | |
---|---|
private static class |
Annotation.QueryRuntimeFilterImpl
|
Field Summary | |
---|---|
private AnnotationSet |
annotationSet
|
private static QueryRuntimeFilter |
RUNTIME_FILTER
This filter gives everybody read permission to annotations. |
static Item |
TYPE
The type of item represented by this class. |
Constructor Summary | |
---|---|
Annotation(AnnotationData annotationData)
|
|
Annotation(AnnotationData annotationData,
AnnotationSet annotationSet)
|
Method Summary | ||
---|---|---|
boolean |
belongsTo(AnnotationSet as)
Check if this annotation belongs to the primaray annotations for a specified annotation set. |
|
AnnotationSet |
getAnnotationSet()
Get the annotation set this annotation belongs to. |
|
AnnotationType |
getAnnotationType()
Get the annotation type of this annotation. |
|
static Annotation |
getById(DbControl dc,
int id)
Get an Annotation item when you know the id. |
|
Date |
getLastUpdate()
Get the date and time the values in this annotation was last updated. |
|
(package private) static Annotation |
getNew(DbControl dc,
AnnotationType annotationType,
AnnotationSet annotationSet)
Create a new annotation. |
|
(package private) PluginPermission |
getPluginPermissions()
|
|
(package private) static ItemQuery<Annotation> |
getQuery()
Get a query configured to retrieve annotations. |
|
Item |
getType()
Get the type of item represented by the object. |
|
Unit |
getUnit()
Get the unit used for the values in this annotation. |
|
UnitConverter |
getUnitConverter(Unit unit)
Get a converter for converting the values in this annotation to a specific unit. |
|
|
getUnitFormatter(Formatter<T> parent,
Unit unit)
Wrap a parent formatter with a formatter for units. |
|
String |
getUnitSymbol(Unit unit)
Shortcut for Unit.getDisplaySymbol() , but also
checks the default unit of the annotation type. |
|
List<?> |
getValues()
Get the values this annotation contains. |
|
List<?> |
getValues(Unit unit)
Get the values for this annotation in a specific unit. |
|
int |
getValuesVersion()
Get the version number of the item keeping the values. |
|
Type |
getValueType()
Get the value type for this annotation type. |
|
boolean |
hasUnit()
Checks if the values in this annotation has a unit. |
|
(package private) void |
initPermissions(int granted,
int denied)
READ permission is granted if the logged in user has READ permission on the associated item. |
|
void |
setValue(Object value)
|
|
void |
setValue(Object value,
Unit unit)
Set the value of the annotation, replacing any previous values. |
|
void |
setValues(List<?> values)
|
|
void |
setValues(List<?> values,
Unit unit)
Set the values of the annotation, replacing any previous values. |
Methods inherited from class net.sf.basedb.core.BasicItem |
---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Item TYPE
Item.ANNOTATION
,
getType()
private static final QueryRuntimeFilter RUNTIME_FILTER
private AnnotationSet annotationSet
Constructor Detail |
---|
Annotation(AnnotationData annotationData)
Annotation(AnnotationData annotationData, AnnotationSet annotationSet)
Method Detail |
---|
static Annotation getNew(DbControl dc, AnnotationType annotationType, AnnotationSet annotationSet) throws BaseException
dc
- The DbControl objectannotationType
- The annotation type of the new annotationannotationSet
- The annotation set of the new annotation
BaseException
AnnotationSet.getAnnotation(AnnotationType)
public static Annotation getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
Annotation
item when you know the id.
dc
- The DbControl
which will be used for
permission checking and database access.id
- The id of the item to load
Annotation
item
ItemNotFoundException
- If an item with the specified
id is not found
PermissionDeniedException
- If the logged in user doesn't
have read permission to the item
BaseException
- If there is another errorstatic ItemQuery<Annotation> getQuery()
ItemQuery
objectpublic Item getType()
Identifiable
Item
enumeration.
void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem<AnnotationData>
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass
BaseException
- If the permissions couldn't be initialisedPluginPermission getPluginPermissions()
getPluginPermissions
in class BasicItem<AnnotationData>
public AnnotationSet getAnnotationSet() throws PermissionDeniedException, BaseException
AnnotationSet
PermissionDeniedException
- If the logged in user doesn't have
read permission for the annotation set (should never happen)
BaseException
- If anything else goes wrong when getting the annotation set.public Date getLastUpdate()
public boolean belongsTo(AnnotationSet as)
as
- The annotation set to check
public AnnotationType getAnnotationType() throws PermissionDeniedException, BaseException
AnnotationType
PermissionDeniedException
- If the logged in user doesn't have
read permission for the annotation type
BaseException
- If anything else goes wrong when getting the annotation type.public boolean hasUnit()
public Unit getUnit()
public UnitConverter getUnitConverter(Unit unit)
unit
- The unit to convert the values to, or null
to convert the values to the unit specified by getUnit()
AnnotationType.getDefaultUnit()
public <T> Formatter<T> getUnitFormatter(Formatter<T> parent, Unit unit)
getValues(Unit)
to be correctly formatted with the
returned formatter.
parent
- The parent formatter, which should be of the
correct type for the annotation valuesunit
- The unit to use for formatting, or null to
use the annotation's unit
public String getUnitSymbol(Unit unit)
Unit.getDisplaySymbol()
, but also
checks the default unit of the annotation type.
unit
- The unit to get the symbol for, or null to use
the annotation's unit
public Type getValueType()
public List<?> getValues() throws BaseException
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.
If this is an annotation with units, the values are returned in the unit
of the annotation type (AnnotationType.getDefaultUnit()
). Use
getValues(Unit)
to get the values in a different unit, including the
specific unit used on this annotation.
BaseException
- If there is an errorAnnotationType.getValueType()
public List<?> getValues(Unit unit) throws BaseException
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.
unit
- The unit to convert the values to, or null to get the values
in the unit used on this annotation
BaseException
- If there is an errorAnnotationType.getValueType()
public int getValuesVersion()
public void setValue(Object value) throws PermissionDeniedException, InvalidDataException, BaseException
PermissionDeniedException
InvalidDataException
BaseException
public void setValue(Object value, Unit unit) throws PermissionDeniedException, InvalidDataException, BaseException
value
- The new valueunit
- The unit of the value, or null to use the default unit of
the annotation type
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 errorpublic void setValues(List<?> values) throws PermissionDeniedException, InvalidDataException, BaseException
PermissionDeniedException
InvalidDataException
BaseException
public void setValues(List<?> values, Unit unit) throws PermissionDeniedException, InvalidDataException, BaseException
values
- A list containing the new valuesunit
- The unit of the value, or null to use the default unit of
the annotation type
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
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |