Debian Codegraph @

src/aQute/bnd/annotation/xml/XMLAttribute.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 package aQute.bnd.annotation.xml;
2
3 import java.lang.annotation.ElementType;
4 import java.lang.annotation.Retention;
5 import java.lang.annotation.RetentionPolicy;
6 import java.lang.annotation.Target;
7
8 /**
9 * Define an xml attribute extension annotation. In cooperation with an
10 * XMLAttribute-aware annotation processor, such as the bnd plugins for DS and
11 * (spec) metatype annotations, the values specified for the members of the
12 * annotation will be added to the appropriate xml element in the document being
13 * generated, using the namespace specified and attempting to use the prefix
14 * specified. This will only occur if the generated document namespace matches
15 * one of the embedIn strings. Supporting classes for this are in the
16 * aQute.bnd.xmlattribute package.
17 * <p>
18 * For example:
19 *
20 * <pre>
21 * &#064;XMLAttribute(namespace = &quot;org.foo.extensions.v1&quot;, prefix =
22 * &quot;foo&quot;, embedIn = &quot;*&quot;)
23 * &#064;Retention(RetentionPolicy.CLASS) &#064;Target(ElementType.TYPE)
24 * &#064;interface OCDTestExtensions { boolean booleanAttr() default true; //
25 * default provided, thus optional String stringAttr(); // no default, must be
26 * specified Foo fooAttr(); } &#064;ObjectClassDefinition
27 * &#064;OCDTestExtensions(stringAttr = &quot;ocd&quot;, fooAttr = Foo.A) public
28 * static interface TestExtensions {}
29 * </pre>
30 *
31 * results in
32 *
33 * <pre>
34 * <metatype:MetaData
35 * xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.3.0"
36 * xmlns:foo="org.foo.extensions.v1"
37 * localization="OSGI-INF/l10n/test.metatype.SpecMetatypeTest$TestExtensions">
38 * <OCD id="test.metatype.SpecMetatypeTest$TestExtensions" name="Test metatype
39 * spec metatype test test extensions" description="" foo:stringAttr="ocd"
40 * foo:fooAttr="A"> ...
41 * </pre>
42 */
43 @Retention(RetentionPolicy.CLASS)
44 @Target({
45 ElementType.ANNOTATION_TYPE
46 })
47 public @interface XMLAttribute {
48
49 /**
50 * xml namespace for the emitted attritrbutes
51 *
52 * @return xml namespace for the emitted attritrbutes
53 */
54 String namespace();
55
56 /**
57 * Suggested prefix for the specified namespace. This will be modified as
58 * necessary to avoid conflicts.
59 *
60 * @return suggested prefix for the specified namespace.
61 */
62 String prefix() default "ns";
63
64 /**
65 * Array of document namespaces this annotation should embed attributes in.
66 *
67 * @return array of applicable xml namespaces
68 */
69 String[] embedIn() default {
70 "*"
71 };
72
73 /**
74 * Array of Strings of the form key=value where the key is the name of a
75 * member and the value is the xml attribute name to use for that member's
76 * value. For instance, "value=simple" causes @Simple("foo") to emit
77 * ns:simple="foo".
78 *
79 * @return Array of member-name to xml-attribute-name mappings.
80 * @since 1.1
81 */
82 String[] mapping() default {};
83
84 }