Annotation Type XMLAttribute


  • @Retention(CLASS)
    @Target(ANNOTATION_TYPE)
    public @interface XMLAttribute
    Define an xml attribute extension annotation. In cooperation with an XMLAttribute-aware annotation processor, such as the bnd plugins for DS and (spec) metatype annotations, the values specified for the members of the annotation will be added to the appropriate xml element in the document being generated, using the namespace specified and attempting to use the prefix specified. This will only occur if the generated document namespace matches one of the embedIn strings. Supporting classes for this are in the aQute.bnd.xmlattribute package.

    For example:

     @XMLAttribute(namespace = "org.foo.extensions.v1", prefix =
     "foo", embedIn = "*")
     @Retention(RetentionPolicy.CLASS) @Target(ElementType.TYPE)
     @interface OCDTestExtensions { boolean booleanAttr() default true; //
     default provided, thus optional String stringAttr(); // no default, must be
     specified Foo fooAttr(); } @ObjectClassDefinition
     @OCDTestExtensions(stringAttr = "ocd", fooAttr = Foo.A) public
     static interface TestExtensions {}
     
    results in
      
      ...
     
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String namespace
      xml namespace for the emitted attritrbutes
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String[] embedIn
      Array of document namespaces this annotation should embed attributes in.
      java.lang.String[] mapping
      Array of Strings of the form key=value where the key is the name of a member and the value is the xml attribute name to use for that member's value.
      java.lang.String prefix
      Suggested prefix for the specified namespace.
    • Element Detail

      • namespace

        java.lang.String namespace
        xml namespace for the emitted attritrbutes
        Returns:
        xml namespace for the emitted attritrbutes
      • prefix

        java.lang.String prefix
        Suggested prefix for the specified namespace. This will be modified as necessary to avoid conflicts.
        Returns:
        suggested prefix for the specified namespace.
        Default:
        "ns"
      • embedIn

        java.lang.String[] embedIn
        Array of document namespaces this annotation should embed attributes in.
        Returns:
        array of applicable xml namespaces
        Default:
        {"*"}
      • mapping

        java.lang.String[] mapping
        Array of Strings of the form key=value where the key is the name of a member and the value is the xml attribute name to use for that member's value. For instance, "value=simple" causes @Simple("foo") to emit ns:simple="foo".
        Returns:
        Array of member-name to xml-attribute-name mappings.
        Since:
        1.1
        Default:
        {}