001/*
002 * Order.java November 2007
003 *
004 * Copyright (C) 2007, Niall Gallagher <niallg@users.sf.net>
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
015 * implied. See the License for the specific language governing 
016 * permissions and limitations under the License.
017 */
018
019package org.simpleframework.xml;
020
021import java.lang.annotation.RetentionPolicy;
022import java.lang.annotation.Retention;
023
024/**
025 * The <code>Order</code> annotation is used to specify the order of
026 * appearance of XML elements and attributes. When used it ensures 
027 * that on serialization the XML generated is predictable. By default
028 * serialization of fields is done in declaration order. 
029 * 
030 * @author Niall Gallagher
031 */
032@Retention(RetentionPolicy.RUNTIME)
033public @interface Order {
034
035   /**
036    * Specifies the appearance order of the XML elements within the
037    * generated document. This overrides the default order used, 
038    * which is the declaration order within the class. If an element 
039    * is not specified within this array then its order will be the
040    * appearance order directly after the last specified element.
041    * 
042    * @return an ordered array of elements representing order
043    */
044   String[] elements() default {};
045   
046   /**
047    * Specifies the appearance order of the XML attributes within 
048    * the generated document. This overrides the default order used, 
049    * which is the declaration order within the class. If an attribute 
050    * is not specified within this array then its order will be the
051    * appearance order directly after the last specified attribute.
052    * 
053    * @return an ordered array of attributes representing order
054    */
055   String[] attributes() default {};
056}