Package net.sf.basedb.core
Class AnnotationType
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.OwnedItem
net.sf.basedb.core.SharedItem
net.sf.basedb.core.CommonItem
net.sf.basedb.core.AnnotationType
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Nameable
,Ownable
,Registered
,Removable
,Shareable
Objects of this class defines an annotation type. An
annotation type is always of a specific
Type
,
ie. a string, integer, etc. Limitations on the values can be specified, ie.
min and max values, max string length, etc. It is also possible
to use a predefined list of allowed values, ie an enumeration.
An annotation type also specifies which types of items it can be used on.
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2023-09-18 09:37:37 +0200 (Mon, 18 Sep 2023) $
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum length of the default value.static final int
The maximum length of the external id that can be stored in the database.static final int
The maximum length of an option.static final Item
The type of item represented by this class.Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCategory
(AnnotationTypeCategory category) Add a category to this annotation type.void
addUsableUnit
(Unit unit) Add a unit to be used with this annotation type.void
Clear all units.long
Count the number of project-specific annotations that exists for this annotation type.void
disableForItem
(Item itemType) Disable this annotation type to be used for items of the specified type.void
enableForItem
(Item itemType) Enable this annotation type to be used for items of the specified type.This method should be used on enumerated string annotation types to find a matching predefined string value, optionally ignoring case and white-space.Load the IDs of all annotation types with the disable inheritance flag set.(package private) boolean
getBooleanOption
(String name, boolean defaultValue) Get an option and convert the value to a boolean.static AnnotationType
Get anAnnotationType
item when you know the id.Get a query that returns the categories an annotation type belongs to.(package private) AnnotationTypeData
getData()
Get theBasicData
object that holds all data for this item.Get the default unit for this annotation type.Get the recommended default value for new annotations of this annotation type.boolean
If this flag is set, annotations of this type can't be inherited to child items.boolean
If this flag is set, the change history logging will not include actual annotation values.boolean
Check if the enumeration values should be displayed as a selection list or as radio buttons/checkboxes by the client application.(package private) Double
getDoubleOption
(String name, Double defaultValue) Get an option and convert the value to a double.Get theItem
types this annotation type is enabled for.Get the date that the item was registered in the database.Get the external id of the annotation type.<T> FastAnnotationLoader<T>
Create a loader that can be used for fast loading of annotation values for multiple items.(package private) Float
getFloatOption
(String name, Float defaultValue) Get an option and convert the value to a float.int
Get the recommended height in characters a client application should use to render an input field for annotations of this annotation type.(package private) Integer
getIntOption
(String name, Integer defaultValue) Get an option and convert the value to an integer.(package private) Long
getLongOption
(String name, Long defaultValue) Get an option and convert the value to a long.Get the maximum allowed string length for aType.STRING
annotation.Get the maximum allowed value for aType.FLOAT
orType.DOUBLE
annotation.Get the minumum allowed value for aType.FLOAT
orType.DOUBLE
annotation.int
Get the multiplicity.static AnnotationType
Create a newAnnotationType
item.Get an option.boolean
If this flag is set, annotation values can be set per project.Get the quantity for this annotation type.static ItemQuery<AnnotationType>
Get aItemQuery
that returns annotation types.getType()
Get the type of item represented by the object.Get a query for returning the units that are considered "usable" for this annotation type.Get all: Annotations of this type Experiments that are using this annotation type as an experimental factor Protocols that are using this annotation type as a protocol parameter<T> List<T>
Get the list of allowed values if this annotation type is an enumeration.Get the value type for this annotation type.int
getWidth()
Get the recommended width in characters a client application should use to render an input field for annotations of this annotation type.boolean
isEnabledForItem
(Item itemType) Check if this annotation type can be used to annotate item of the specified type.boolean
Check if this annotation type provides a list of predefined allowed values.boolean
If this flag is set, annotation values are considered to be alternate identifiers for the items they belong to.boolean
isMember
(AnnotationTypeCategory category) Checks if the annotation type is a member of a category.boolean
If this annotation type is intended to be used as a protocol parameter or as a regular annotations.boolean
isProtocolParameter
(Protocol protocol) Check if this annotation type is a parameter to the specified protocol.boolean
Check an annotation of this annotation type required for an item to be compliant with the MIAME recommendation.boolean
isUsableUnit
(Unit unit) Checks if the given unit is a unit that has been specified as a "usable" unit for this annotation type.boolean
isUsed()
Checks if: Annotations of this type exists Experiments are using this annotation type as an experimental factor Protocols are using this annotation type as a protocol parametervoid
removeCategory
(AnnotationTypeCategory category) Remove a category from this annotation type.void
removeUsableUnit
(Unit unit) Remove a unit from this annotation type.void
setDefaultUnit
(Unit defaultUnit) Set the default unit to use for this annotation type.void
setDefaultValue
(String defaultValue) Set the recommended default value for new annotation of this annotation type.void
setDisableInheritance
(boolean disableInheritance) If this flag is set, annotations of this type can't be inherited to child items.void
setDisableLogOfValues
(boolean disableLogOfValues) If this flag is set, the change history logging will not include actual annotation values.void
setDisplayAsList
(boolean displayAsList) Set if the enumeration values should be displayed as a selection list or as radio buttons/checkboxes by the client application.void
setEntryDate
(Date entryDate) Set the date the entry was registered in the database.void
setEnumeration
(boolean isEnumeration) Set if this annotation type should provide a list of predefined allowed values.void
setExternalId
(String externalId) Set the external id of the annotation type.void
setHeight
(int height) Set the recommended height in characters a client application should use to render an input field for annotations of this annotation type.void
setIdentifier
(boolean isIdentifier) void
setItemTypes
(Collection<Item> items) Enable the annotation type for all of the specified item and disable it for all other.void
setMaxLength
(Integer maxLength) Set the maximum allowed string length for aType.STRING
annotation.void
setMaxValueDouble
(Double maxValue) Set the maximum allowed value for aType.FLOAT
orType.DOUBLE
annotation.void
setMaxValueLong
(Long maxValue) void
setMinValueDouble
(Double minValue) Set the minimum allowed value for aType.FLOAT
orType.DOUBLE
annotation.void
setMinValueLong
(Long minValue) void
setMultiplicity
(int multiplicity) Set the multiplicity.(package private) void
Set an option.void
setProjectAnnotations
(boolean projectAnnotations) If this flag is set, annotation values can be set per project.void
setProtocolParameter
(boolean isProtocolParameter) Specify if this annotation type should be used as a protocol parameter or as a regular annotation typevoid
setRequiredForMiame
(boolean required) Set if an annotation of this annotation type is required for an item to be compliant with the MIAME recommendation.void
Set the list of allowed values for an enumerated annotation type.void
setWidth
(int width) Set the recommended width in characters a client application should use to render an input field for annotations of this annotation type.boolean
Checks if this annotation types support units.void
validateAnnotationValue
(Object value) Validate an annotation value assuming that the value is in the default unit.validateAnnotationValue
(Object value, Unit unit) Validate an annotation value that can be in a different unit than the default unit.Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, getRemovedBy, isRemoved, setDescription, setName, setRemoved
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership
Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
-
Field Details
-
TYPE
The type of item represented by this class.- See Also:
-
MAX_EXTERNAL_ID_LENGTH
public static final int MAX_EXTERNAL_ID_LENGTHThe maximum length of the external id that can be stored in the database.- Since:
- 2.2
- See Also:
-
MAX_DEFAULT_VALUE_LENGTH
public static final int MAX_DEFAULT_VALUE_LENGTHThe maximum length of the default value.- See Also:
-
MAX_OPTION_LENGTH
public static final int MAX_OPTION_LENGTHThe maximum length of an option.- See Also:
-
-
Constructor Details
-
AnnotationType
AnnotationType(AnnotationTypeData annotationTypeData)
-
-
Method Details
-
getNew
Create a newAnnotationType
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessvalueType
- The type of values to use- Returns:
- The new
AnnotationType
item - Throws:
BaseException
- If there is an error
-
getById
public static AnnotationType getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get anAnnotationType
item when you know the id.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessid
- The id of the item to load- Returns:
- The
AnnotationType
item - Throws:
ItemNotFoundException
- If an item with the specified id is not foundPermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission to the itemBaseException
- If there is another error
-
getQuery
Get aItemQuery
that returns annotation types. If the itemType parameter is null, annotation types for all item types will be returned- Parameters:
itemType
- Optional, limit the annotation types to those that are enabled for the specified item- Returns:
- An
ItemQuery
object
-
getAllAnnotationTypesWithInheritanceDisabled
Load the IDs of all annotation types with the disable inheritance flag set. This method will return all such IDs without checking permissions of the current user. The returned set is not modifiable.- Since:
- 3.5
-
getData
AnnotationTypeData getData()Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.- Overrides:
getData
in classCommonItem
-
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 theItem
enumeration.- Specified by:
getType
in interfaceIdentifiable
- Returns:
- A value indicating the type of item
-
getEntryDate
Description copied from interface:Registered
Get the date that the item was registered in the database.- Specified by:
getEntryDate
in interfaceRegistered
- Returns:
- A date or null if this is not known
-
setEntryDate
Description copied from interface:Registered
Set the date the entry was registered in the database. Implementations should only allow this property to be set before the item is first stored in the database. The intention of this method is to facilitate export/import of data between server.- Specified by:
setEntryDate
in interfaceRegistered
- Parameters:
entryDate
- A date or null to use today's date
-
isUsed
Checks if:- Annotations of this type exists
- Experiments are using this annotation type as an experimental factor
- Protocols are using this annotation type as a protocol parameter
- Overrides:
isUsed
in classBasicItem
- Returns:
- TRUE if this item is used, FALSE otherwise
- Throws:
BaseException
- If not able to tell if item is used or not.- See Also:
-
getUsingItems
Get all:- Annotations of this type
- Experiments that are using this annotation type as an experimental factor
- Protocols that are using this annotation type as a protocol parameter
- Overrides:
getUsingItems
in classBasicItem
- Returns:
- A set containing proxies for the items, or an empty set if no items are using this item
- Since:
- 2.2
- See Also:
-
getFastLoader
Create a loader that can be used for fast loading of annotation values for multiple items. The loader can be used for reading only.- Since:
- 3.19.10
-
supportUnits
public boolean supportUnits()Checks if this annotation types support units.- Returns:
- TRUE if a unit is used, FALSE otherwise
- Since:
- 2.9
-
getQuantity
Get the quantity for this annotation type. If the quantity is null, units are not used with this annotation type. An annotation type without units can be changed to use units with thesetDefaultUnit(Unit)
method. Once a unit has been configured, it is not possible to change theQuantity
.- Returns:
- The quantity, or null
- Since:
- 2.9
-
getDefaultUnit
Get the default unit for this annotation type.- Returns:
- The default unit, or null if this annotation type doesn't use units
- Since:
- 2.9
-
setDefaultUnit
Set the default unit to use for this annotation type. If the annotation type doesn't have any current default unit, any unit can be used. If there already is a default unit, the new unit must be from the sameQuantity
as the existing unit.Note! Changing units will result in a conversion of existing annotation values to the new unit. This may result in loss of precision due to rounding or truncation errors.
- Parameters:
defaultUnit
- The new default unit- Since:
- 2.9
-
getUsableUnits
Get a query for returning the units that are considered "usable" for this annotation type. This is typically used by client applications to limit the list of choices in the graphical interface. If this query doesn't return any items, all units should be considered usable.- Returns:
- A query
- Since:
- 2.9
-
isUsableUnit
Checks if the given unit is a unit that has been specified as a "usable" unit for this annotation type.- Parameters:
unit
- The unit to check- Returns:
- TRUE if the unit is "usable", FALSE otherwise
- Since:
- 2.9
-
addUsableUnit
Add a unit to be used with this annotation type. Note! This doesn't prevent other units (from the sameQuantity
) from being used. This is just a recommendation to allow client applications to limit the list of choices in the graphical interface.- Parameters:
unit
- The unit to add- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission for the annotation type or use permission for the unitInvalidDataException
- If the unit is null- Since:
- 2.9
-
removeUsableUnit
Remove a unit from this annotation type. This will not affect already existing annotation with this unit.- Parameters:
unit
- The unit to remove from the set of usable units- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.WRITE
permission for the annotation typeInvalidDataException
- If the unit is null- Since:
- 2.9
-
clearUsableUnits
public void clearUsableUnits()Clear all units.- Since:
- 2.9
-
getExternalId
Get the external id of the annotation type. This value can be used to link with information in external databases. It is not used by the BASE core and it doesn't have to be unique.- Returns:
- The external id for the annotation type
- Since:
- 2.2
-
setExternalId
Set the external id of the annotation type. The value may be null but must not be longer than the value specified by theMAX_EXTERNAL_ID_LENGTH
constant.- Parameters:
externalId
- The new value for the external id- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the string is too long- Since:
- 2.2
-
addCategory
public void addCategory(AnnotationTypeCategory category) throws PermissionDeniedException, InvalidDataException Add a category to this annotation type.- Parameters:
category
- The category to add- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission for the annotation type and use permission for the categoryInvalidDataException
- If the category is null
-
removeCategory
public void removeCategory(AnnotationTypeCategory category) throws PermissionDeniedException, InvalidDataException Remove a category from this annotation type.- Parameters:
category
- The category to remove- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission for the annotation typeInvalidDataException
- If the category is null
-
isMember
Checks if the annotation type is a member of a category.- Parameters:
category
- The category to check- Returns:
- TRUE if the annotation type is a member, FALSE otherwise
-
getCategories
Get a query that returns the categories an annotation type belongs to.- Returns:
- An
ItemQuery
object
-
getValueType
Get the value type for this annotation type. It can't be change once the object has been created.- Returns:
- A
Type
constant
-
getMultiplicity
public int getMultiplicity()Get the multiplicity. The multiplicity tells the core how many values an annotation of this annotation type may contain. The default is one. Zero denotes unlimited values.- Returns:
- the multiplicity as an int.
-
setMultiplicity
public void setMultiplicity(int multiplicity) throws PermissionDeniedException, InvalidDataException Set the multiplicity. The multiplicity tells the core how many values an annotation of this annotation type may contain. The default is one. Zero denotes unlimited values.- Parameters:
multiplicity
- Multiplicity to set.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the multiplicity is lower than zero
-
isRequiredForMiame
public boolean isRequiredForMiame()Check an annotation of this annotation type required for an item to be compliant with the MIAME recommendation.- Returns:
- TRUE if required, FALSE otherwise.
- See Also:
-
setRequiredForMiame
Set if an annotation of this annotation type is required for an item to be compliant with the MIAME recommendation.- Parameters:
required
- Should be TRUE if required or FALSE if it is not.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission- See Also:
-
isEnumeration
public boolean isEnumeration()Check if this annotation type provides a list of predefined allowed values.- Returns:
- TRUE if it is provided, FALSE otherwise.
-
setEnumeration
public void setEnumeration(boolean isEnumeration) throws PermissionDeniedException, InvalidDataException Set if this annotation type should provide a list of predefined allowed values.- Parameters:
isEnumeration
- TRUE if this should be provided, FALSE otherwise- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the value type doesn't support enumerations, seeType.canEnumerate
-
getDisplayAsList
public boolean getDisplayAsList()Check if the enumeration values should be displayed as a selection list or as radio buttons/checkboxes by the client application. The client application may decide to use some other display format that better suits the situation.- Returns:
- TRUE if it should be displayed as a selection list, FALSE if radio buttons/check-boxes.
-
setDisplayAsList
public void setDisplayAsList(boolean displayAsList) throws PermissionDeniedException, InvalidDataException Set if the enumeration values should be displayed as a selection list or as radio buttons/checkboxes by the client application. The client application may decide to use some other display format that better suits the situation.- Parameters:
displayAsList
- Set to TRUE to display as a selection list or set to FALSE to display as radio buttons/check-boxes.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- Never
-
getHeight
public int getHeight()Get the recommended height in characters a client application should use to render an input field for annotations of this annotation type. A client application is not required to use this value if it is not appropriate for the situation.- Returns:
- Characters height as an int.
-
setHeight
Set the recommended height in characters a client application should use to render an input field for annotations of this annotation type. A client application is not required to use this value if it is not appropriate for the situation.- Parameters:
height
- The height in characters- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the height is less than one
-
getWidth
public int getWidth()Get the recommended width in characters a client application should use to render an input field for annotations of this annotation type. A client application is not required to use this value if it is not appropriate for the situation.- Returns:
- The width as an int.
-
setWidth
Set the recommended width in characters a client application should use to render an input field for annotations of this annotation type. A client application is not required to use this value if it is not appropriate for the situation.- Parameters:
width
- The width in characters- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the width is less than one
-
getDefaultValue
Get the recommended default value for new annotations of this annotation type. It is not certain that the string represents a value that can be converted to the correct value type as specified by thegetValueType()
setting.- Returns:
- Default value as a String.
-
setDefaultValue
public void setDefaultValue(String defaultValue) throws PermissionDeniedException, InvalidDataException Set the recommended default value for new annotation of this annotation type. It is not checked that the string can be converted to the correct value type as specified by thegetValueType()
setting.- Parameters:
defaultValue
- The default value for new annotation.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the default value is longer thanMAX_DEFAULT_VALUE_LENGTH
-
isEnabledForItem
Check if this annotation type can be used to annotate item of the specified type.- Parameters:
itemType
- TheItem
type- Returns:
- TRUE if annotations are possible, FALSE otherwise
-
enableForItem
Enable this annotation type to be used for items of the specified type.- Parameters:
itemType
- TheItem
type to enable this annotation type for- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the item type is null, or not represents an annotatable item
-
disableForItem
Disable this annotation type to be used for items of the specified type.- Parameters:
itemType
- TheItem
type to disable this annotation type for- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the item type is null
-
getEnabledItems
Get theItem
types this annotation type is enabled for.- Returns:
- A
Set
ofItem
:s
-
setItemTypes
Enable the annotation type for all of the specified item and disable it for all other.- Since:
- 3.8
-
isProtocolParameter
public boolean isProtocolParameter()If this annotation type is intended to be used as a protocol parameter or as a regular annotations.- Returns:
- TRUE if the annotation type is a protocol parameter, FALSE if it is a regular annotation type
- Since:
- 2.2
-
setProtocolParameter
Specify if this annotation type should be used as a protocol parameter or as a regular annotation type- Parameters:
isProtocolParameter
- TRUE to use the annotation type as a protocol parameter, FALSE to use it as a regular annotation type- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission- Since:
- 2.2
-
isProtocolParameter
Check if this annotation type is a parameter to the specified protocol. NOTE! This method doesn't use the value from theisProtocolParameter()
.- Parameters:
protocol
- The protocol to check, null always return false- Returns:
- TRUE if the annotation type is a parameter to the protocol, FALSE otherwise
- Since:
- 2.2
- See Also:
-
getDisableLogOfValues
public boolean getDisableLogOfValues()If this flag is set, the change history logging will not include actual annotation values. Use this to prevent sensitive data from appearing in the log.- Since:
- 3.3
-
setDisableLogOfValues
If this flag is set, the change history logging will not include actual annotation values. Use this to prevent sensitive data from appearing in the log.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission- Since:
- 3.3
-
getDisableInheritance
public boolean getDisableInheritance()If this flag is set, annotations of this type can't be inherited to child items. Use this to prevent sensitive data from being used in other contexts.- Since:
- 3.5
-
setDisableInheritance
If this flag is set, annotations of this type can't be inherited to child items. Use this to prevent sensitive data from being used in other contexts. Changing this from FALSE to TRUE will automatically trigger a database action that remove all existing inherited annotations of this type.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission- Since:
- 3.5
-
getProjectAnnotations
public boolean getProjectAnnotations()If this flag is set, annotation values can be set per project. The active project as set bySessionControl.getActiveProjectId()
controls which annotation values that are visible.- Since:
- 3.10
-
setProjectAnnotations
If this flag is set, annotation values can be set per project. The active project as set bySessionControl.getActiveProjectId()
controls which annotation values that are visible. Note that it is not possible to change this flag from TRUE to FALSE if there are existing projec-specific annotations for this annotation type.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission- Since:
- 3.10
-
setIdentifier
- Throws:
PermissionDeniedException
- Since:
- 3.15
- See Also:
-
isIdentifier
public boolean isIdentifier()If this flag is set, annotation values are considered to be alternate identifiers for the items they belong to. But note that BASE will not check or prevent the same value from being used for more than one item.- Since:
- 3.15
-
countProjectSpecificAnnotations
public long countProjectSpecificAnnotations()Count the number of project-specific annotations that exists for this annotation type. If this returns a non-zero value, it is not possible to turn off the project-specific annotations feature until all annotations are deleted.- Returns:
- The number of project-specific annotations
- Since:
- 3.10
-
getMinValueLong
- Returns:
- The minimum allowed value or null if none has been specfied or
if this annotation type hasn't an
INT
orLONG
value type
-
setMinValueLong
- Parameters:
minValue
- The minimum allowed value or null if no limit is specified- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If this annotation type hasn't anINT
orLONG
value type
-
getMaxValueLong
- Returns:
- The maximum allowed value or null if none has been specfied or
if this annotation type hasn't an
INT
orLONG
value type
-
setMaxValueLong
- Parameters:
maxValue
- The maximum allowed value or null if no limit is specified- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If this annotation type hasn't anINT
value type
-
getMinValueDouble
Get the minumum allowed value for aType.FLOAT
orType.DOUBLE
annotation.- Returns:
- The minimum allowed value or null if none has been specfied or
if this annotation type hasn't a
FLOAT
orDOUBLE
value type
-
setMinValueDouble
public void setMinValueDouble(Double minValue) throws PermissionDeniedException, InvalidDataException Set the minimum allowed value for aType.FLOAT
orType.DOUBLE
annotation.- Parameters:
minValue
- The minimum allowed value or null if no limit is specified- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If this annotation type hasn't aFLOAT
orDOUBLE
value type
-
getMaxValueDouble
Get the maximum allowed value for aType.FLOAT
orType.DOUBLE
annotation.- Returns:
- The maximum allowed value or null if none has been specfied or
if this annotation type hasn't a
FLOAT
orDOUBLE
value type
-
setMaxValueDouble
public void setMaxValueDouble(Double maxValue) throws PermissionDeniedException, InvalidDataException Set the maximum allowed value for aType.FLOAT
orType.DOUBLE
annotation.- Parameters:
maxValue
- The maximum allowed value or null if no limit is specified- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If this annotation type hasn't aFLOAT
orDOUBLE
value type
-
getMaxLength
Get the maximum allowed string length for aType.STRING
annotation.- Returns:
- The maximum allowed string length or null if none has been specfied or
if this annotation type hasn't an
STRING
value type
-
setMaxLength
Set the maximum allowed string length for aType.STRING
annotation.- Parameters:
maxLength
- The maximum allowed value or null if no limit is specified- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If this annotation type hasn't aSTRING
value type
-
getValues
Get the list of allowed values if this annotation type is an enumeration.- Returns:
- A
List
with the allowed values or null if this annotation type is not an enumeration or no values has been specified - Throws:
BaseException
- If there is an error- See Also:
-
setValues
Set the list of allowed values for an enumerated annotation type.- Parameters:
values
- The list of allowed values, or null to clear the values- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the list contains values of the wrong type as checked by theType.validate(List)
method
-
findValue
This method should be used on enumerated string annotation types to find a matching predefined string value, optionally ignoring case and white-space.- Parameters:
value
- The value to look forignoreCase
- TRUE to ignore casetrim
- TRUE to trim white-space from the start and end of string- Returns:
- The matching string, or null if not found or if the annotation isn't an enumeration of strings
- Since:
- 2.4
-
getOption
Get an option. -
getIntOption
Get an option and convert the value to an integer. If the option doesn't exist or the value can't be converted, the default value is returned. -
getLongOption
Get an option and convert the value to a long. If the option doesn't exist or the value can't be converted, the default value is returned. -
getFloatOption
Get an option and convert the value to a float. If the option doesn't exist or the value can't be converted, the default value is returned. -
getDoubleOption
Get an option and convert the value to a double. If the option doesn't exist or the value can't be converted, the default value is returned. -
getBooleanOption
Get an option and convert the value to a boolean. If the option doesn't exist the default value is returned. If the option contains the string "true" (case ignored) true is returned, false otherwise. -
setOption
Set an option.- Throws:
InvalidDataException
-
validateAnnotationValue
Validate an annotation value assuming that the value is in the default unit.- Parameters:
value
- The object to be validated- Throws:
InvalidDataException
- If the value object can not be used.- See Also:
-
validateAnnotationValue
Validate an annotation value that can be in a different unit than the default unit. We check the following:- The object is of the correct type, ie.
Float
ifgetValueType()
returnsType.FLOAT
, etc. NOTE! If a unit is specified it is only required that the value is aNumber
. It will automatically be converted to the correct class after unit conversion has taken place. - The value is within the min and max bouds if specified
- A string value is not too long
- The value exists in the predefined list if this annotation type is an enumeration
- Parameters:
value
- The object to be validatedunit
- The unit if the value, this parameter is ignored if the value type doesn't support units (eg. strings) or if the no default unit has been set for this annotation type- Returns:
- The validated value which may have been converted to the default unit
- Throws:
InvalidDataException
- If the value object can not be used.- Since:
- 2.11
- The object is of the correct type, ie.
-