Interface AttributeDefinition
-
public interface AttributeDefinition
An interface to describe an attribute.An
AttributeDefinition
object defines a description of the data type of a property/attribute.- Version:
- $Revision: 5673 $
-
-
Field Summary
Fields Modifier and Type Field Description static int
BIGDECIMAL
Deprecated.As of 1.1.static int
BIGINTEGER
Deprecated.As of 1.1.static int
BOOLEAN
TheBOOLEAN
(11) type.static int
BYTE
TheBYTE
(6) type.static int
CHARACTER
TheCHARACTER
(5) type.static int
DOUBLE
TheDOUBLE
(7) type.static int
FLOAT
TheFLOAT
(8) type.static int
INTEGER
TheINTEGER
(3) type.static int
LONG
TheLONG
(2) type.static int
SHORT
TheSHORT
(4) type.static int
STRING
TheSTRING
(1) type.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getCardinality()
Return the cardinality of this attribute.java.lang.String[]
getDefaultValue()
Return a default for this attribute.java.lang.String
getDescription()
Return a description of this attribute.java.lang.String
getID()
Unique identity for this attribute.java.lang.String
getName()
Get the name of the attribute.java.lang.String[]
getOptionLabels()
Return a list of labels of option values.java.lang.String[]
getOptionValues()
Return a list of option values that this attribute can take.int
getType()
Return the type for this attribute.java.lang.String
validate(java.lang.String value)
Validate an attribute inString
form.
-
-
-
Field Detail
-
STRING
static final int STRING
TheSTRING
(1) type.Attributes of this type should be stored as
String
,Vector
withString
orString[]
objects, depending on thegetCardinality()
value.- See Also:
- Constant Field Values
-
LONG
static final int LONG
TheLONG
(2) type. Attributes of this type should be stored asLong
,Vector
withLong
orlong[]
objects, depending on thegetCardinality()
value.- See Also:
- Constant Field Values
-
INTEGER
static final int INTEGER
TheINTEGER
(3) type. Attributes of this type should be stored asInteger
,Vector
withInteger
orint[]
objects, depending on thegetCardinality()
value.- See Also:
- Constant Field Values
-
SHORT
static final int SHORT
TheSHORT
(4) type. Attributes of this type should be stored asShort
,Vector
withShort
orshort[]
objects, depending on thegetCardinality()
value.- See Also:
- Constant Field Values
-
CHARACTER
static final int CHARACTER
TheCHARACTER
(5) type. Attributes of this type should be stored asCharacter
,Vector
withCharacter
orchar[]
objects, depending on thegetCardinality()
value.- See Also:
- Constant Field Values
-
BYTE
static final int BYTE
TheBYTE
(6) type. Attributes of this type should be stored asByte
,Vector
withByte
orbyte[]
objects, depending on thegetCardinality()
value.- See Also:
- Constant Field Values
-
DOUBLE
static final int DOUBLE
TheDOUBLE
(7) type. Attributes of this type should be stored asDouble
,Vector
withDouble
ordouble[]
objects, depending on thegetCardinality()
value.- See Also:
- Constant Field Values
-
FLOAT
static final int FLOAT
TheFLOAT
(8) type. Attributes of this type should be stored asFloat
,Vector
withFloat
orfloat[]
objects, depending on thegetCardinality()
value.- See Also:
- Constant Field Values
-
BIGINTEGER
static final int BIGINTEGER
Deprecated.As of 1.1.TheBIGINTEGER
(9) type. Attributes of this type should be stored asBigInteger
,Vector
withBigInteger
orBigInteger[]
objects, depending on thegetCardinality()
value.- See Also:
- Constant Field Values
-
BIGDECIMAL
static final int BIGDECIMAL
Deprecated.As of 1.1.TheBIGDECIMAL
(10) type. Attributes of this type should be stored asBigDecimal
,Vector
withBigDecimal
orBigDecimal[]
objects depending ongetCardinality()
.- See Also:
- Constant Field Values
-
BOOLEAN
static final int BOOLEAN
TheBOOLEAN
(11) type. Attributes of this type should be stored asBoolean
,Vector
withBoolean
orboolean[]
objects depending ongetCardinality()
.- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
java.lang.String getName()
Get the name of the attribute. This name may be localized.- Returns:
- The localized name of the definition.
-
getID
java.lang.String getID()
Unique identity for this attribute. Attributes share a global namespace in the registry. E.g. an attributecn
orcommonName
must always be aString
and the semantics are always a name of some object. They share this aspect with LDAP/X.500 attributes. In these standards the OSI Object Identifier (OID) is used to uniquely identify an attribute. If such an OID exists, (which can be requested at several standard organisations and many companies already have a node in the tree) it can be returned here. Otherwise, a unique id should be returned which can be a Java class name (reverse domain name) or generated with a GUID algorithm. Note that all LDAP defined attributes already have an OID. It is strongly advised to define the attributes from existing LDAP schemes which will give the OID. Many such schemes exist ranging from postal addresses to DHCP parameters.- Returns:
- The id or oid
-
getDescription
java.lang.String getDescription()
Return a description of this attribute. The description may be localized and must describe the semantics of this type and any constraints.- Returns:
- The localized description of the definition.
-
getCardinality
int getCardinality()
Return the cardinality of this attribute. The OSGi environment handles multi valued attributes in arrays ([]) or inVector
objects. The return value is defined as follows:x = Integer.MIN_VALUE no limit, but use Vector x < 0 -x = max occurrences, store in Vector x > 0 x = max occurrences, store in array [] x = Integer.MAX_VALUE no limit, but use array [] x = 0 1 occurrence required
- Returns:
- The cardinality of this attribute.
-
getType
int getType()
Return the type for this attribute.Defined in the following constants which map to the appropriate Java type.
STRING
,LONG
,INTEGER
,CHAR
,BYTE
,DOUBLE
,FLOAT
,BOOLEAN
.- Returns:
- The type for this attribute.
-
getOptionValues
java.lang.String[] getOptionValues()
Return a list of option values that this attribute can take.If the function returns
null
, there are no option values available.Each value must be acceptable to validate() (return "") and must be a
String
object that can be converted to the data type defined by getType() for this attribute.This list must be in the same sequence as
getOptionLabels()
. I.e. for each index i ingetOptionValues
, i ingetOptionLabels()
should be the label.For example, if an attribute can have the value male, female, unknown, this list can return
new String[] { "male", "female", "unknown" }
.- Returns:
- A list values
-
getOptionLabels
java.lang.String[] getOptionLabels()
Return a list of labels of option values.The purpose of this method is to allow menus with localized labels. It is associated with
getOptionValues
. The labels returned here are ordered in the same way as the values in that method.If the function returns
null
, there are no option labels available.This list must be in the same sequence as the
getOptionValues()
method. I.e. for each index i ingetOptionLabels
, i ingetOptionValues()
should be the associated value.For example, if an attribute can have the value male, female, unknown, this list can return (for dutch)
new String[] { "Man", "Vrouw", "Onbekend" }
.- Returns:
- A list values
-
validate
java.lang.String validate(java.lang.String value)
Validate an attribute inString
form. An attribute might be further constrained in value. This method will attempt to validate the attribute according to these constraints. It can return three different values:null No validation present "" No problems detected "..." A localized description of why the value is wrong
- Parameters:
value
- The value before turning it into the basic data type- Returns:
null
, "", or another string
-
getDefaultValue
java.lang.String[] getDefaultValue()
Return a default for this attribute. The object must be of the appropriate type as defined by the cardinality andgetType()
. The return type is a list ofString
objects that can be converted to the appropriate type. The cardinality of the return array must follow the absolute cardinality of this type. E.g. if the cardinality = 0, the array must contain 1 element. If the cardinality is 1, it must contain 0 or 1 elements. If it is -5, it must contain from 0 to max 5 elements. Note that the special case of a 0 cardinality, meaning a single value, does not allow arrays or vectors of 0 elements.- Returns:
- Return a default value or
null
if no default exists.
-
-