@ConsumerType public interface AttributeDefinition
An AttributeDefinition
object defines a description of the data type
of a property/attribute.
Modifier and Type | Field and Description |
---|---|
static int |
BIGDECIMAL
Deprecated.
As of 1.1.
|
static int |
BIGINTEGER
Deprecated.
As of 1.1.
|
static int |
BOOLEAN
The
BOOLEAN type. |
static int |
BYTE
The
BYTE type. |
static int |
CHARACTER
The
CHARACTER type. |
static int |
DOUBLE
The
DOUBLE type. |
static int |
FLOAT
The
FLOAT type. |
static int |
INTEGER
The
INTEGER type. |
static int |
LONG
The
LONG type. |
static int |
PASSWORD
The
PASSWORD type. |
static int |
SHORT
The
SHORT type. |
static int |
STRING
The
STRING type. |
Modifier and Type | Method and Description |
---|---|
int |
getCardinality()
Return the cardinality of this attribute.
|
String[] |
getDefaultValue()
Return a default for this attribute.
|
String |
getDescription()
Return a description of this attribute.
|
String |
getID()
Unique identity for this attribute.
|
String |
getName()
Get the name of the attribute.
|
String[] |
getOptionLabels()
Return a list of labels of option values.
|
String[] |
getOptionValues()
Return a list of option values that this attribute can take.
|
int |
getType()
Return the type for this attribute.
|
String |
validate(String value)
Validate an attribute in
String form. |
static final int STRING
STRING
type.
Attributes of this type should be stored as String
,
List<String>
or String[]
objects, depending on the
getCardinality()
value.
static final int LONG
LONG
type.
Attributes of this type should be stored as Long
,
List<Long>
or long[]
objects, depending on the
getCardinality()
value.static final int INTEGER
INTEGER
type.
Attributes of this type should be stored as Integer
,
List<Integer>
or int[]
objects, depending on the
getCardinality()
value.static final int SHORT
SHORT
type.
Attributes of this type should be stored as Short
,
List<Short>
or short[]
objects, depending on the
getCardinality()
value.static final int CHARACTER
CHARACTER
type.
Attributes of this type should be stored as Character
,
List<Character>
or char[]
objects, depending on the
getCardinality()
value.static final int BYTE
BYTE
type.
Attributes of this type should be stored as Byte
,
List<Byte>
or byte[]
objects, depending on the
getCardinality()
value.static final int DOUBLE
DOUBLE
type.
Attributes of this type should be stored as Double
,
List<Double>
or double[]
objects, depending on the
getCardinality()
value.static final int FLOAT
FLOAT
type.
Attributes of this type should be stored as Float
,
List<Float>
or float[]
objects, depending on the
getCardinality()
value.static final int BIGINTEGER
BIGINTEGER
type.
Attributes of this type should be stored as BigInteger
,
List<BigInteger>
or BigInteger[]
objects, depending on
the getCardinality()
value.static final int BIGDECIMAL
BIGDECIMAL
type.
Attributes of this type should be stored as BigDecimal
,
List<BigDecimal>
or BigDecimal[]
objects depending on
getCardinality()
.static final int BOOLEAN
BOOLEAN
type.
Attributes of this type should be stored as Boolean
,
List<Boolean>
or boolean[]
objects depending on
getCardinality()
.static final int PASSWORD
PASSWORD
type.
Attributes of this type must be stored as String
,
List<String>
or String[]
objects depending on
getCardinality()
. A PASSWORD
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.String getName()
String getID()
cn
or commonName
must always be a
String
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.String getDescription()
int getCardinality()
List
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
int getType()
Defined in the following constants which map to the appropriate Java
type. STRING
,LONG
,INTEGER
, SHORT
,
CHARACTER
, BYTE
,DOUBLE
,FLOAT
,
BOOLEAN
, PASSWORD
.
String[] getOptionValues()
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 in getOptionValues
, i in
getOptionLabels()
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" }
.
String[] getOptionLabels()
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 in getOptionLabels
, i in
getOptionValues()
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" }
.
String validate(String value)
String
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 wrongIf 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" ]
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.null
, "", or another stringString[] getDefaultValue()
getType()
. The return type is a list of String
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.null
if no default exists.Copyright © OSGi Alliance (2000, 2015). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0