Package net.sf.basedb.core
Class ExtendedProperty
java.lang.Object
net.sf.basedb.core.ExtendedProperty
- Direct Known Subclasses:
ClonableProperty
,RawDataProperty
Holds information about an extended property for a
class.
- Version:
- 2.0
- Author:
- Nicklas, Samuel
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Formula.AverageMethod
private final String
private final String
private final boolean
private final boolean
private final int
private final List<ExtendedPropertyLinker>
private final String
private final boolean
private final boolean
private final String
private final Type
private final boolean
private static final Pattern
A regexp checking for invalid characters. -
Constructor Summary
ConstructorDescriptionExtendedProperty
(String name, String title, String description, String column, Type type, int length, boolean nullable, boolean insertable, boolean updateable, boolean restrictedEdit, boolean hidden, Formula.AverageMethod averageMethod, List<ExtendedPropertyLinker> linkers) Create a new extended property. -
Method Summary
Modifier and TypeMethodDescriptionWhich method to use when calculating the average of a set of values.Get the database column of the extended property.Get a description of the extended property.int
Get the maximum allowed length of the property value.getName()
Get the name of the extended property.getTitle()
Get the title of the extended property.getType()
Get the type of the extended property.Create a link for this extended property.boolean
If it makes sense to take the average of multiple values for this property or not.boolean
isHidden()
Check if the value of this property is hidden or not.boolean
Check if the value of this property should be inserted into the datbase when creating new items.boolean
Check if the property allows null values or not.boolean
Check if the value of this property is restricted for editing or not.boolean
Check if the value of this property should be updated in the database when an item is updated.static boolean
isValidName
(String name) Check that the name only contains a-zA-Z0-9_ and starts with a letter or underscore.parseString
(String value) Parse a string and return an object of the correct type for this property.parseString
(String value, NumberFormat numberFormat, boolean nullIfException) Parse a string and return an object of the correct type for this property.void
validateValue
(Object value) Check if an object is valid according to the specifications of this property.
-
Field Details
-
valid
A regexp checking for invalid characters. -
name
-
type
-
column
-
title
-
description
-
length
private final int length -
nullable
private final boolean nullable -
insertable
private final boolean insertable -
updateable
private final boolean updateable -
restrictedEdit
private final boolean restrictedEdit -
averageMethod
-
linkers
-
-
Constructor Details
-
ExtendedProperty
ExtendedProperty(String name, String title, String description, String column, Type type, int length, boolean nullable, boolean insertable, boolean updateable, boolean restrictedEdit, boolean hidden, Formula.AverageMethod averageMethod, List<ExtendedPropertyLinker> linkers) Create a new extended property. See the getter methods for a description of the parameters.
-
-
Method Details
-
isValidName
Check that the name only contains a-zA-Z0-9_ and starts with a letter or underscore.- Parameters:
name
- Name to check- Returns:
- TRUE if valid, FALSE otherwise
- Since:
- 2.4
-
getName
Get the name of the extended property. This is the name that is used in queries and for thename
parameter of thegetExtended/setExtended
methods to get or set the value of the property of anExtendable
item.- Returns:
- A string with the name
- See Also:
-
getTitle
Get the title of the extended property. The title is not used by the core but can be used by client applications for example to display a column header.- Returns:
- A string with the title
-
getDescription
Get a description of the extended property. The description is not used by the core but can be used by client applications.- Returns:
- A string with the description
-
getColumn
Get the database column of the extended property. This is the name of the column in the database which holds the value.- Returns:
- a
String
-
getType
Get the type of the extended property. The value returned is one of the defined constants by theType
enumeration.- Returns:
- a Type enumeration.
-
getLength
public int getLength()Get the maximum allowed length of the property value. This is only useful if it a string property.- Returns:
- The maximum allowed length
-
isNullable
public boolean isNullable()Check if the property allows null values or not.- Returns:
- TRUE if null values are allowed, FALSE otherwise
-
isInsertable
public boolean isInsertable()Check if the value of this property should be inserted into the datbase when creating new items.- Returns:
- TRUE if the value should be inserted, FALSE otherwise
-
isUpdateable
public boolean isUpdateable()Check if the value of this property should be updated in the database when an item is updated.- Returns:
- TRUE if the value should be updated, FALSE otherwise
-
isRestrictedEdit
public boolean isRestrictedEdit()Check if the value of this property is restricted for editing or not. This typically means that the logged in user must have a specific permission in order to change the value. To begin with restricted editing is only used forUser
items to lock some properties for non-administrator editing.- Since:
- 3.3
-
isHidden
public boolean isHidden()Check if the value of this property is hidden or not. Hidden properties should normally not show up in user interfaces that have not been specifically designed to work with the property.- Since:
- 3.13
-
isAveragable
public boolean isAveragable()If it makes sense to take the average of multiple values for this property or not. For example, it doesn't make sense to average over position coordinates, but it does make sense to average over intensity values. By default all numerical values are averagable.- Returns:
- TRUE if it makes sense to take the average, FALSE otherwise
- See Also:
-
getAverageMethod
Which method to use when calculating the average of a set of values. Prior to 2.4 only arithmetic mean was supported.- Returns:
- The average method to use
- Since:
- 2.4
-
parseString
Parse a string and return an object of the correct type for this property.- Parameters:
value
- The value to parse- Returns:
- An object
- Throws:
InvalidDataException
- If the string cannot be converted to the correct type- See Also:
-
parseString
Parse a string and return an object of the correct type for this property. Numeric properties are parsed with the specified number format. If the nullIfException parameter is TRUE null is returned if the string can't be parsed. Otherwise an exception is thrown.- Parameters:
value
- The value to parsenumberFormat
- The number format, or null to use Double.valueOfnullIfException
- TRUE to return null in case the string can't be parsed, FALSE to throw an exception- Returns:
- An object or null
- Throws:
InvalidDataException
- If the string cannot be converted to the correct type and the nullIfException parameter is false- Since:
- 2.4
- See Also:
-
validateValue
Check if an object is valid according to the specifications of this property. The checks include checking for null values if the property notisNullable()
, check that the object is of the correctgetType()
and the maximumgetLength()
of a string.- Parameters:
value
- The value to check- Throws:
InvalidDataException
-
getUrl
Create a link for this extended property. This method checks the linkers in the order they are defined. The first one to return a non-null value is the winner.- Parameters:
value
- The value to link- Returns:
- The URL, or null if no matching linker could be found
-