org.rapla.entities.dynamictype
Interface Attribute
- All Superinterfaces:
- Annotatable, MultiLanguageNamed, Named, RaplaObject
public interface Attribute
- extends RaplaObject, MultiLanguageNamed, Annotatable
Attributes are to DynamicTypes, what properties are to Beans.
Currently Rapla supports the following types:
string
int
date
boolean
rapla:category
- See Also:
DynamicType
Methods inherited from interface org.rapla.entities.Named |
getName |
TYPE
static final RaplaType TYPE
ATTRIBUTE_ARRAY
static final Attribute[] ATTRIBUTE_ARRAY
getType
AttributeType getType()
setType
void setType(AttributeType type)
- Set the type of the Attribute.
Warning: Changing the type after initialization can lead to data loss,
if there are already classifications that use this attribute and the classification value
can't be converted to the new type. Example a non numerical string can't be converted to an int.
setKey
void setKey(String key)
getKey
String getKey()
- The Key is identifier in string-form. Keys could be helpfull
for interaction with other modules. An Invoice-Plugin could
work on attributes with a "price" key. Keys also allow for a
better readability of the XML-File. Changing of a key is
possible, but should be used with care.
defaultValue
Object defaultValue()
convertValue
Object convertValue(Object oldValue)
- converts the passed value to fit the attributes type.
Example Conversions are:
- to string: The result of the method toString() will be the new value.
- boolean to int: The new value will be 1 when the oldValue is true. Otherwise it is 0.
- other types to int: First the value will be converted to string-type. And then the
trimmed string will be parsed for Integer-values. If that is not possible the new value will
be null
- to boolean: First the value will be converted to string-type. If the trimmed string equals
"0" or "false" the new value is false. Otherwise it is true
needsChange
boolean needsChange(Object value)
- Checks if the passed value matches the attribute type or needs conversion.
- See Also:
convertValue(java.lang.Object)
isValid
boolean isValid(Object object)
isOptional
boolean isOptional()
setOptional
void setOptional(boolean bOptional)
getConstraint
Object getConstraint(String key)
getConstraintClass
Class getConstraintClass(String key)
setConstraint
void setConstraint(String key,
Object constraint)
getConstraintKeys
String[] getConstraintKeys()
getDynamicType
DynamicType getDynamicType()
Copyright © 2000-2006 Rapla Team. All Rights Reseserved.