Class EntryWriter
java.lang.Object
org.apache.felix.dm.annotation.plugin.bnd.EntryWriter
This class encodes a component descriptor entry line, using json.
We are using a slightly adapted version of the nice JsonSerializingImpl class from the Apache Felix Converter project.
Internally, we store parameters in a map. The format of key/values stored in the map is the following:
The JSON object has the following form:
entry ::= String | String[] | dictionary
dictionary ::= key-value-pair*
key-value-pair ::= key value
value ::= String | String[] | value-type
value-type ::= jsonObject with value-type-info
value-type-info ::= "type"=primitive java type
"value"=String|String[]
Exemple:
{"string-param" : "string-value",
"string-array-param" : ["string1", "string2"],
"properties" : {
"string-param" : "string-value",
"string-array-param" : ["str1", "str2],
"long-param" : {"type":"java.lang.Long", "value":"1"}}
"long-array-param" : {"type":"java.lang.Long", "value":["1"]}}
}
}
- Author:
- Felix Project Team
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProperty(String name, Object value, Class<?> type) Adds a property in this descriptor entry.getParameter(EntryParam param) Returns a parameter value (either a String, or a List). voidput(EntryParam param, String value) Adds a String parameter in this descritor entry.voidput(EntryParam param, String[] values) Adds a String[] parameter in this descriptor entry.voidput(EntryParam param, List<String> values) Adds a List of Strings in this descriptor entry.voidputClass(aQute.bnd.osgi.Annotation annotation, EntryParam param) Get a class attribute value from an annotation and write it into this descriptor entry.intputClassArray(aQute.bnd.osgi.Annotation annotation, EntryParam param, Object def, Set<String> collect) Get a class array attribute value from an annotation and write it into this descriptor entry.putString(aQute.bnd.osgi.Annotation annotation, EntryParam param, String def) Get a String attribute value from an annotation and write it into this descriptor entry.toString()Returns a string representation for the given component descriptor entry.
-
Constructor Details
-
EntryWriter
Makes a new component descriptor entry.
-
-
Method Details
-
toString
Returns a string representation for the given component descriptor entry. -
put
Adds a String parameter in this descritor entry. -
put
Adds a String[] parameter in this descriptor entry. -
put
Adds a List of Strings in this descriptor entry. -
getParameter
Returns a parameter value (either a String, or a List). -
addProperty
Adds a property in this descriptor entry. -
putString
Get a String attribute value from an annotation and write it into this descriptor entry. -
putClass
Get a class attribute value from an annotation and write it into this descriptor entry. -
putClassArray
public int putClassArray(aQute.bnd.osgi.Annotation annotation, EntryParam param, Object def, Set<String> collect) Get a class array attribute value from an annotation and write it into this descriptor entry.- Parameters:
annotation- the annotation containing an array of classesparam- the attribute name corresponding to an array of classesdef- the default array of classes (String[]), if the attribute is not defined in the annotation- Returns:
- the class array size.
-