Class EntryWriter

java.lang.Object
org.apache.felix.dm.annotation.plugin.bnd.EntryWriter

public class EntryWriter extends Object
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 Details

    • EntryWriter

      public EntryWriter(EntryType type)
      Makes a new component descriptor entry.
  • Method Details

    • toString

      public String toString()
      Returns a string representation for the given component descriptor entry.
      Overrides:
      toString in class Object
      Parameters:
      m_logger -
    • put

      public void put(EntryParam param, String value)
      Adds a String parameter in this descritor entry.
    • put

      public void put(EntryParam param, String[] values)
      Adds a String[] parameter in this descriptor entry.
    • put

      public void put(EntryParam param, List<String> values)
      Adds a List of Strings in this descriptor entry.
    • getParameter

      public Object getParameter(EntryParam param)
      Returns a parameter value (either a String, or a List).
    • addProperty

      public void addProperty(String name, Object value, Class<?> type)
      Adds a property in this descriptor entry.
    • putString

      public String 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.
    • putClass

      public void putClass(aQute.bnd.osgi.Annotation annotation, EntryParam param)
      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 classes
      param - the attribute name corresponding to an array of classes
      def - the default array of classes (String[]), if the attribute is not defined in the annotation
      Returns:
      the class array size.