Interface AttributeDefinition
An AttributeDefinition
object defines a description of the data type
of a property/attribute.
- "ThreadSafe"
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Deprecated.As of 1.1.static final int
Deprecated.As of 1.1.static final int
TheBOOLEAN
type.static final int
TheBYTE
type.static final int
TheCHARACTER
type.static final int
TheDOUBLE
type.static final int
TheFLOAT
type.static final int
TheINTEGER
type.static final int
TheLONG
type.static final int
ThePASSWORD
type.static final int
TheSHORT
type.static final int
TheSTRING
type. -
Method Summary
Modifier and TypeMethodDescriptionint
Return the cardinality of this attribute.String[]
Return a default for this attribute.Return a description of this attribute.getID()
Unique identity for this attribute.getName()
Get the name of the attribute.String[]
Return a list of labels of option values.String[]
Return a list of option values that this attribute can take.int
getType()
Return the type for this attribute.Validate an attribute inString
form.
-
Field Details
-
STRING
static final int STRINGTheSTRING
type.Attributes of this type should be stored as
String
,List<String>
orString[]
objects, depending on thegetCardinality()
value.- See Also:
-
LONG
static final int LONGTheLONG
type. Attributes of this type should be stored asLong
,List<Long>
orlong[]
objects, depending on thegetCardinality()
value.- See Also:
-
INTEGER
static final int INTEGERTheINTEGER
type. Attributes of this type should be stored asInteger
,List<Integer>
orint[]
objects, depending on thegetCardinality()
value.- See Also:
-
SHORT
static final int SHORTTheSHORT
type. Attributes of this type should be stored asShort
,List<Short>
orshort[]
objects, depending on thegetCardinality()
value.- See Also:
-
CHARACTER
static final int CHARACTERTheCHARACTER
type. Attributes of this type should be stored asCharacter
,List<Character>
orchar[]
objects, depending on thegetCardinality()
value.- See Also:
-
BYTE
static final int BYTETheBYTE
type. Attributes of this type should be stored asByte
,List<Byte>
orbyte[]
objects, depending on thegetCardinality()
value.- See Also:
-
DOUBLE
static final int DOUBLETheDOUBLE
type. Attributes of this type should be stored asDouble
,List<Double>
ordouble[]
objects, depending on thegetCardinality()
value.- See Also:
-
FLOAT
static final int FLOATTheFLOAT
type. Attributes of this type should be stored asFloat
,List<Float>
orfloat[]
objects, depending on thegetCardinality()
value.- See Also:
-
BIGINTEGER
static final int BIGINTEGERDeprecated.As of 1.1.TheBIGINTEGER
type. Attributes of this type should be stored asBigInteger
,List<BigInteger>
orBigInteger[]
objects, depending on thegetCardinality()
value.- See Also:
-
BIGDECIMAL
static final int BIGDECIMALDeprecated.As of 1.1.TheBIGDECIMAL
type. Attributes of this type should be stored asBigDecimal
,List<BigDecimal>
orBigDecimal[]
objects depending ongetCardinality()
.- See Also:
-
BOOLEAN
static final int BOOLEANTheBOOLEAN
type. Attributes of this type should be stored asBoolean
,List<Boolean>
orboolean[]
objects depending ongetCardinality()
.- See Also:
-
PASSWORD
static final int PASSWORDThePASSWORD
type. Attributes of this type must be stored asString
,List<String>
orString[]
objects depending ongetCardinality()
. APASSWORD
must be treated as a string but the type can be used to disguise the information when displayed to a user to prevent others from seeing it.- Since:
- 1.2
- See Also:
-
-
Method Details
-
getName
String getName()Get the name of the attribute. This name may be localized.- Returns:
- The localized name of the definition.
-
getID
String getID()Unique identity for this attribute. Attributes share a global namespace in the registry. For example, 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 organizations 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
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 inList
objects. The return value is defined as follows:x = Integer.MIN_VALUE no limit, but use List x < 0 -x = max occurrences, store in List 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
,SHORT
,CHARACTER
,BYTE
,DOUBLE
,FLOAT
,BOOLEAN
,PASSWORD
.- Returns:
- The type for this attribute.
-
getOptionValues
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()
. That is, 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
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. That is, 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
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
If the cardinality of this attribute is multi-valued then this string must be interpreted as a comma delimited string. The complete value must be trimmed from white space as well as spaces around commas. Commas (','
\u002C) and spaces (' '
\u0020) and backslashes ('\'
\u005C) can be escaped with another backslash. Escaped spaces must not be trimmed. For example:value=" a\,b,b\,c,\ c\\,d " => [ "a,b", "b,c", " c\", "d" ]
- Parameters:
value
- The value before turning it into the basic data type. If the cardinality indicates a multi-valued attribute then the given string must be escaped.- Returns:
null
, "", or another string
-
getDefaultValue
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. For example, 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 lists of 0 elements.- Returns:
- Return a default value or
null
if no default exists.
-