org.apache.juneau.xml.annotation.XmlSchema Maven / Gradle / Ivy
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
// * with the License. You may obtain a copy of the License at *
// * *
// * http://www.apache.org/licenses/LICENSE-2.0 *
// * *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
package org.apache.juneau.xml.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
/**
* Identifies the default XML namespaces at the package level.
*/
@Documented
@Target(PACKAGE)
@Retention(RUNTIME)
@Inherited
public @interface XmlSchema {
/**
* Sets the default XML prefix for all classes in this and child packages.
*
*
* Must either be matched with a {@link #namespace()} annotation, or an {@link #xmlNs()} mapping with the same
* {@link XmlNs#prefix} value.
*/
public String prefix() default "";
/**
* Sets the default XML namespace URL for all classes in this and child packages.
*
*
* Must either be matched with a {@link #prefix()} annotation, or an {@link #xmlNs()} mapping with the same
* {@link XmlNs#namespaceURI} value.
*/
public String namespace() default "";
/**
* Lists all namespace mappings to be used on all classes within this package.
*
*
* The purpose of this annotation is to allow namespace mappings to be defined in a single location and referred
* to by name through just the {@link Xml#prefix()} annotation.
*
*
* Inherited by child packages.
*
*
Example:
*
* Contents of package-info.java
...
*
* // XML namespaces used within this package.
* @XmlSchema (prefix="ab" ,
* namespaces={
* @XmlNs (prefix="ab" , namespaceURI="http://www.apache.org/addressBook/" ),
* @XmlNs (prefix="per" , namespaceURI="http://www.apache.org/person/" ),
* @XmlNs (prefix="addr" , namespaceURI="http://www.apache.org/address/" ),
* @XmlNs (prefix="mail" , namespaceURI="http://www.apache.org/mail/" )
* }
* )
* package org.apache.juneau.examples.addressbook;
* import org.apache.juneau.xml.annotation.*;
*
*
*
* Class in package using defined namespaces...
*
* package corg.apache.juneau.examples.addressbook;
*
* // Bean class, override "ab" namespace on package.
* @Xml (prefix="addr" )
* public class Address {
*
* // Bean property, use "addr" namespace on class.
* public int id ;
*
* // Bean property, override with "mail" namespace.
* @Xml (prefix="mail" )
* public String street , city , state ;
* }
*
*/
public XmlNs[] xmlNs() default {};
}