|
Knopflerfish OSGi 1.3.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knopflerfish.util.metatype.AD
Implementation calss for AttributeDefinition.
This class contains get and parse methods for operations related to constructing AttributeDefinition.
Field Summary |
Fields inherited from interface org.osgi.service.metatype.AttributeDefinition |
BIGDECIMAL, BIGINTEGER, BOOLEAN, BYTE, CHARACTER, DOUBLE, FLOAT, INTEGER, LONG, SHORT, STRING |
Constructor Summary | |
AD(java.lang.String id,
int type,
int card,
java.lang.String name,
java.lang.String[] defValue)
Create an AttributeDefinition with empty descrition and no option labels or option values. |
|
AD(java.lang.String id,
int type,
int card,
java.lang.String name,
java.lang.String desc,
java.lang.String[] defValue,
java.lang.String[] optLabels,
java.lang.String[] optValues)
Create a new attribute definition. |
Method Summary | |
int |
compareTo(java.lang.Object other)
|
boolean |
equals(java.lang.Object other)
|
static java.lang.String |
escape(java.lang.String s)
Escape a string so that it'll be parsed as one item, even if it contains SEQUENCE_SEP. |
static int |
getArrayType(java.lang.Object val)
Get type from an array object. |
int |
getCardinality()
Return the cardinality of this attribute. |
static java.lang.Class |
getClass(int type)
Get java class corresponding to AttributeDefinition type. |
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. |
static java.lang.Class |
getPrimitiveClass(int type)
Get the primitive java class from a specificed type. |
static int |
getPrimitiveType(java.lang.Object val)
Get type from primitive object. |
int |
getType()
Return the type for this attribute. |
static int |
getType(java.lang.Object val)
Get the attribute type given any suported java object. |
int |
hashCode()
|
boolean |
isOptional()
Return true if this attribute is optional. |
static java.lang.Object |
parse(java.lang.String value,
int card,
int type)
Parse a string value to an object given a cardinality and type. |
static java.lang.Object |
parseSingle(java.lang.String value,
int type)
Parse a single value into an object given a type. |
void |
setDefaultValue(java.lang.String[] value)
Set the default value. |
void |
setDescription(java.lang.String s)
|
void |
setOptions(java.lang.String[] optValues,
java.lang.String[] optLabels)
Set values returned by getOptionValues and getOptionLabels. |
java.lang.String |
toString()
Convert to human-readable string. |
static java.lang.String |
toString(java.lang.Object obj)
Convert a object to string that can be parsed by parse |
static java.lang.String |
toString(java.lang.Object[] values)
|
static java.lang.String |
toString(java.util.Vector values)
|
static java.lang.String |
toStringFromArray(java.lang.Object array)
|
java.lang.String |
validate(java.lang.String value)
Implementation of validation function. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public AD(java.lang.String id, int type, int card, java.lang.String name, java.lang.String[] defValue)
public AD(java.lang.String id, int type, int card, java.lang.String name, java.lang.String desc, java.lang.String[] defValue, java.lang.String[] optLabels, java.lang.String[] optValues)
id
- Unique id of the definitioncard
- cardinality of the definitiontype
- One of the type constants STRING...BOOLEAN
java.lang.IllegalArgumentException
- if type is not supported.
java.lang.IllegalArgumentException
- if id is null or empty
java.lang.IllegalArgumentException
- if desc is nullMethod Detail |
public int getCardinality()
AttributeDefinition
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
getCardinality
in interface AttributeDefinition
public java.lang.String[] getDefaultValue()
AttributeDefinition
getDefaultValue
in interface AttributeDefinition
public void setDescription(java.lang.String s)
public void setDefaultValue(java.lang.String[] value)
java.lang.IllegalArgumentException
- if any of the values cannot be validated.public java.lang.String getDescription()
AttributeDefinition
getDescription
in interface AttributeDefinition
public java.lang.String getID()
AttributeDefinition
getID
in interface AttributeDefinition
public java.lang.String getName()
AttributeDefinition
getName
in interface AttributeDefinition
public void setOptions(java.lang.String[] optValues, java.lang.String[] optLabels)
optValues
- Values to be return by getOptionValues. Can
be null.optLabels
- Values to be return by getOptionLabels. Can
be null iff optValues is null.
java.lang.IllegalArgumentException
- if optValues and optLabels are not the
same length.public java.lang.String[] getOptionLabels()
AttributeDefinition
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 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" }.
getOptionLabels
in interface AttributeDefinition
public java.lang.String[] getOptionValues()
AttributeDefinition
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 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" }.
getOptionValues
in interface AttributeDefinition
public int getType()
AttributeDefinition
Defined in the following constants which map to the appropriate Java type. STRING, LONG, INTEGER, CHAR, BYTE, DOUBLE, FLOAT, BIGINTEGER, BIGDECIMAL, BOOLEAN.
getType
in interface AttributeDefinition
public boolean isOptional()
public static int getType(java.lang.Object val)
val
- Any java object, including arrays of primitive types.
If val is a Vector, it must
contain at least one element.
java.lang.IllegalArgumentException
- if type cannot be derived.public static int getArrayType(java.lang.Object val)
val
- an array object
java.lang.IllegalArgumentException
- if type cannot be derived.public static int getPrimitiveType(java.lang.Object val)
val
- an object of one of the boxed primitive java object classes.
java.lang.IllegalArgumentException
- if type cannot be derived.public java.lang.String validate(java.lang.String value)
Validation of primitive types is performed by trying to create an' object from the corresponding String constructor.
Validation of arrays and vectors is performed by splitting the input string into comma-separated words.
validate
in interface AttributeDefinition
value
- The value before turning it into the basic data type
public static java.lang.Object parse(java.lang.String value, int card, int type)
public static java.lang.Object parseSingle(java.lang.String value, int type)
public static java.lang.Class getClass(int type)
java.lang.IllegalArgumentException
- if type is not supporte.dpublic static java.lang.Class getPrimitiveClass(int type)
java.lang.IllegalArgumentException
- if type is not supported.public java.lang.String toString()
public static java.lang.String toString(java.lang.Object obj)
public static java.lang.String escape(java.lang.String s)
public static java.lang.String toStringFromArray(java.lang.Object array)
public static java.lang.String toString(java.lang.Object[] values)
public static java.lang.String toString(java.util.Vector values)
public int compareTo(java.lang.Object other)
compareTo
in interface java.lang.Comparable
public int hashCode()
public boolean equals(java.lang.Object other)
|
Knopflerfish OSGi 1.3.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |