001/*
002 * Root.java July 2006
003 *
004 * Copyright (C) 2006, 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 * This <code>Root</code> annotation is used to annotate classes that
026 * need to be serialized. Also, elements within an element list, as
027 * represented by the <code>ElementList</code> annotation need this
028 * annotation so that the element names can be determined. All other
029 * field or method names can be determined using the annotation and 
030 * so the <code>Root</code> annotation is not needed for such objects. 
031 * 
032 * @author Niall Gallagher
033 */
034@Retention(RetentionPolicy.RUNTIME)
035public @interface Root {
036  
037   /**
038    * This represents the name of the XML element. This is optional
039    * an is used when the name of the class is not suitable as an
040    * element name. If this is not specified then the name of the
041    * XML element will be the name of the class. If specified the
042    * class will be serialized and deserialized with the given name.
043    * 
044    * @return the name of the XML element this represents
045    */
046   String name() default "";
047
048   /**
049    * This is used to determine whether the object represented
050    * should be parsed in a strict manner. Strict parsing requires
051    * that each element and attribute in the XML document match a 
052    * field in the class schema. If an element or attribute does
053    * not match a field then the parsing fails with an exception.
054    * Setting strict parsing to false allows details within the
055    * source XML document to be skipped during deserialization.
056    * 
057    * @return true if strict parsing is enabled, false otherwise
058    */ 
059   boolean strict() default true;
060}