001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.jena.annotation;
014
015import static java.lang.annotation.ElementType.*;
016import static java.lang.annotation.RetentionPolicy.*;
017
018import java.lang.annotation.*;
019
020import org.apache.juneau.jena.*;
021
022/**
023 * Annotation for specifying options for RDF serializers.
024 *
025 * <p>
026 * Can be applied to Java packages, types, fields, and methods.
027 *
028 * <p>
029 * Can be used for the following:
030 * <ul>
031 *    <li>Override the default behavior of how collections and arrays are serialized.
032 * </ul>
033 */
034@Documented
035@Target({PACKAGE,TYPE,FIELD,METHOD})
036@Retention(RUNTIME)
037@Inherited
038public @interface Rdf {
039
040   /**
041    * Marks a bean property as a resource URI identifier for the bean.
042    *
043    * <p>
044    * Has the following effects on the following serializers:
045    * <ul class='spaced-list'>
046    *    <li>
047    *       {@link RdfSerializer} - Will be rendered as the value of the <js>"rdf:about"</js> attribute
048    *       for the bean.
049    * </ul>
050    */
051   boolean beanUri() default false;
052
053   /**
054    * The format for how collections (lists and arrays for example) are serialized in RDF.
055    *
056    * @see RdfCollectionFormat
057    */
058   RdfCollectionFormat collectionFormat() default RdfCollectionFormat.DEFAULT;
059
060   /**
061    * Sets the namespace URI of this property or class.
062    *
063    * <p>
064    * Must be matched with a {@link #prefix() @Rdf(prefix)} annotation on this object, a parent object, or a {@link RdfNs @RdfNs} with the
065    * same name through the {@link RdfSchema#rdfNs() @RdfSchema(rdfNs)} annotation on the package.
066    */
067   String namespace() default "";
068
069   /**
070    * Dynamically apply this annotation to the specified classes/methods/fields.
071    *
072    * <p>
073    * Used in conjunction with the {@link RdfConfig#applyRdf()}.
074    * It is ignored when the annotation is applied directly to classes/methods/fields.
075    *
076    * <h5 class='section'>Valid patterns:</h5>
077    * <ul class='spaced-list'>
078    *  <li>Classes:
079    *       <ul>
080    *          <li>Fully qualified:
081    *             <ul>
082    *                <li><js>"com.foo.MyClass"</js>
083    *             </ul>
084    *          <li>Fully qualified inner class:
085    *             <ul>
086    *                <li><js>"com.foo.MyClass$Inner1$Inner2"</js>
087    *             </ul>
088    *          <li>Simple:
089    *             <ul>
090    *                <li><js>"MyClass"</js>
091    *             </ul>
092    *          <li>Simple inner:
093    *             <ul>
094    *                <li><js>"MyClass$Inner1$Inner2"</js>
095    *                <li><js>"Inner1$Inner2"</js>
096    *                <li><js>"Inner2"</js>
097    *             </ul>
098    *       </ul>
099    *    <li>Methods:
100    *       <ul>
101    *          <li>Fully qualified with args:
102    *             <ul>
103    *                <li><js>"com.foo.MyClass.myMethod(String,int)"</js>
104    *                <li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js>
105    *                <li><js>"com.foo.MyClass.myMethod()"</js>
106    *             </ul>
107    *          <li>Fully qualified:
108    *             <ul>
109    *                <li><js>"com.foo.MyClass.myMethod"</js>
110    *             </ul>
111    *          <li>Simple with args:
112    *             <ul>
113    *                <li><js>"MyClass.myMethod(String,int)"</js>
114    *                <li><js>"MyClass.myMethod(java.lang.String,int)"</js>
115    *                <li><js>"MyClass.myMethod()"</js>
116    *             </ul>
117    *          <li>Simple:
118    *             <ul>
119    *                <li><js>"MyClass.myMethod"</js>
120    *             </ul>
121    *          <li>Simple inner class:
122    *             <ul>
123    *                <li><js>"MyClass$Inner1$Inner2.myMethod"</js>
124    *                <li><js>"Inner1$Inner2.myMethod"</js>
125    *                <li><js>"Inner2.myMethod"</js>
126    *             </ul>
127    *       </ul>
128    *    <li>Fields:
129    *       <ul>
130    *          <li>Fully qualified:
131    *             <ul>
132    *                <li><js>"com.foo.MyClass.myField"</js>
133    *             </ul>
134    *          <li>Simple:
135    *             <ul>
136    *                <li><js>"MyClass.myField"</js>
137    *             </ul>
138    *          <li>Simple inner class:
139    *             <ul>
140    *                <li><js>"MyClass$Inner1$Inner2.myField"</js>
141    *                <li><js>"Inner1$Inner2.myField"</js>
142    *                <li><js>"Inner2.myField"</js>
143    *             </ul>
144    *       </ul>
145    *    <li>A comma-delimited list of anything on this list.
146    * </ul>
147    *
148    * <ul class='seealso'>
149    *    <li class='link'>{@doc DynamicallyAppliedAnnotations}
150    * </ul>
151    */
152   String on() default "";
153
154   /**
155    * Sets the XML prefix of this property or class.
156    *
157    * <p>
158    * Must either be matched to a {@link #namespace() @Rdf(namespace)} annotation on the same object, parent object, or a {@link RdfNs @RdfNs}
159    * with the same name through the {@link RdfSchema#rdfNs() @RdfSchema(rdfNs)} annotation on the package.
160    */
161   String prefix() default "";
162}