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
020/**
021 * Identifies the default RDF namespaces at the package level.
022 */
023@Documented
024@Target(PACKAGE)
025@Retention(RUNTIME)
026@Inherited
027public @interface RdfSchema {
028
029   /**
030    * Sets the default RDF namespace URL for all classes in this and child packages.
031    *
032    * <p>
033    * Must either be matched with a {@link #prefix()} annotation, or an {@link #rdfNs()} mapping with the same
034    * {@link RdfNs#namespaceURI() @RdfNs(namespaceURI)} value.
035    */
036   public String namespace() default "";
037
038   /**
039    * Sets the default RDF prefix for all classes in this and child packages.
040    *
041    * <p>
042    * Must either be matched with a {@link #namespace()} annotation, or an {@link #rdfNs()} mapping with the same
043    * {@link RdfNs#prefix} value.
044    */
045   public String prefix() default "";
046
047   /**
048    * Lists all namespace mappings to be used on all classes within this package.
049    *
050    * <p>
051    * The purpose of this annotation is to allow namespace mappings to be defined in a single location and referred to
052    * by name through just the {@link Rdf#prefix() @Rdf(prefix)} annotation.
053    *
054    * <p>
055    * Inherited by child packages.
056    *
057    * <h5 class='section'>Example:</h5>
058    *
059    * Contents of <c>package-info.java</c>...
060    * <p class='bcode w800'>
061    *    <jc>// XML namespaces used within this package.</jc>
062    *    <ja>@RdfSchema</ja>(prefix=<js>"ab"</js>,
063    *       namespaces={
064    *          <ja>@RdfNs</ja>(prefix=<js>"ab"</js>, namespaceURI=<js>"http://www.apache.org/addressBook/"</js>),
065    *          <ja>@RdfNs</ja>(prefix=<js>"per"</js>, namespaceURI=<js>"http://www.apache.org/person/"</js>),
066    *          <ja>@RdfNs</ja>(prefix=<js>"addr"</js>, namespaceURI=<js>"http://www.apache.org/address/"</js>),
067    *          <ja>@RdfNs</ja>(prefix=<js>"mail"</js>, namespaceURI="<js>http://www.apache.org/mail/"</js>)
068    *       }
069    *    )
070    *    <jk>package</jk> org.apache.juneau.examples.addressbook;
071    *    <jk>import</jk> org.apache.juneau.rdf.annotation.*;
072    * </p>
073    *
074    * <p>
075    * Class in package using defined namespaces...
076    * <p class='bcode w800'>
077    *    <jk>package</jk> org.apache.juneau.examples.addressbook;
078    *
079    *    <jc>// Bean class, override "ab" namespace on package.</jc>
080    *    <ja>@Rdf</ja>(prefix=<js>"addr"</js>)
081    *    <jk>public class</jk> Address {
082    *
083    *       <jc>// Bean property, use "addr" namespace on class.</jc>
084    *       <jk>public int</jk> <jf>id</jf>;
085    *
086    *       <jc>// Bean property, override with "mail" namespace.</jc>
087    *       <ja>@Rdf</ja>(prefix=<js>"mail"</js>)
088    *       <jk>public</jk> String <jf>street</jf>, <jf>city</jf>, <jf>state</jf>;
089    *    }
090    * </p>
091    */
092   public RdfNs[] rdfNs() default {};
093}