Coverage Report - org.simpleframework.xml.core.Detail
 
Classes in this File Line Coverage Branch Coverage Complexity
Detail
N/A
N/A
1
 
 1  
 /*
 2  
  * Detail.java July 2012
 3  
  *
 4  
  * Copyright (C) 2012, Niall Gallagher <niallg@users.sf.net>
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 15  
  * implied. See the License for the specific language governing 
 16  
  * permissions and limitations under the License.
 17  
  */
 18  
 
 19  
 package org.simpleframework.xml.core;
 20  
 
 21  
 import java.lang.annotation.Annotation;
 22  
 import java.lang.reflect.Constructor;
 23  
 import java.util.List;
 24  
 
 25  
 import org.simpleframework.xml.DefaultType;
 26  
 import org.simpleframework.xml.Namespace;
 27  
 import org.simpleframework.xml.NamespaceList;
 28  
 import org.simpleframework.xml.Order;
 29  
 import org.simpleframework.xml.Root;
 30  
 
 31  
 /**
 32  
  * The <code>Detail</code> object is used to provide various details
 33  
  * for a type. Most of the data that can be acquired from this can
 34  
  * also be acquired from the <code>Class</code>. However, in some
 35  
  * environments, particularly Android, reflection and introspection
 36  
  * is very slow. This class attempts to reduce the overheads by 
 37  
  * caching all the data extracted from the class for future use.
 38  
  * 
 39  
  * @author Niall Gallagher
 40  
  * 
 41  
  * @see org.simpleframework.xml.core.Support
 42  
  */
 43  
 interface Detail {
 44  
    
 45  
    /**
 46  
     * This method is used to determine whether strict mappings are
 47  
     * required. Strict mapping means that all labels in the class
 48  
     * schema must match the XML elements and attributes in the
 49  
     * source XML document. When strict mapping is disabled, then
 50  
     * XML elements and attributes that do not exist in the schema
 51  
     * class will be ignored without breaking the parser.
 52  
     *
 53  
     * @return true if strict parsing is enabled, false otherwise
 54  
     */ 
 55  
    boolean isStrict();
 56  
    
 57  
    /**
 58  
     * This is used to determine if the generated annotations are
 59  
     * required or not. By default generated parameters are required.
 60  
     * Setting this to false means that null values are accepted
 61  
     * by all defaulted fields or methods depending on the type.
 62  
     * 
 63  
     * @return this is used to determine if defaults are required
 64  
     */
 65  
    boolean isRequired();
 66  
    
 67  
    /**
 68  
     * This is used to determine if the class is an inner class. If
 69  
     * the class is a inner class and not static then this returns
 70  
     * false. Only static inner classes can be instantiated using
 71  
     * reflection as they do not require a "this" argument.
 72  
     * 
 73  
     * @return this returns true if the class is a static inner
 74  
     */
 75  
    boolean isInstantiable();
 76  
    
 77  
    /**
 78  
     * This is used to determine whether this detail represents a
 79  
     * primitive type. A primitive type is any type that does not
 80  
     * extend <code>Object</code>, examples are int, long and double.
 81  
     * 
 82  
     * @return this returns true if no XML annotations were found
 83  
     */
 84  
    boolean isPrimitive();
 85  
    
 86  
    /**
 87  
     * This is used to acquire the super type for the class that is
 88  
     * represented by this detail. If the super type for the class
 89  
     * is <code>Object</code> then this will return null.
 90  
     * 
 91  
     * @return returns the super type for this class or null
 92  
     */
 93  
    Class getSuper();
 94  
    
 95  
    /**
 96  
     * This returns the type represented by this detail. The type is
 97  
     * the class that has been scanned for annotations, methods and
 98  
     * fields. All super types of this are represented in the detail.
 99  
     * 
 100  
     * @return the type that this detail object represents
 101  
     */
 102  
    Class getType();
 103  
    
 104  
    /**
 105  
     * This returns the name of the class represented by this detail.
 106  
     * The name is either the name as specified in the last found
 107  
     * <code>Root</code> annotation, or if a name was not specified
 108  
     * within the discovered root then the Java Bean class name of
 109  
     * the last class annotated with a root annotation.
 110  
     * 
 111  
     * @return this returns the name of the object being scanned
 112  
     */
 113  
    String getName();
 114  
    
 115  
    /**
 116  
     * This returns the <code>Root</code> annotation for the class.
 117  
     * The root determines the type of deserialization that is to
 118  
     * be performed and also contains the name of the root element. 
 119  
     * 
 120  
     * @return this returns the name of the object being scanned
 121  
     */
 122  
    Root getRoot();
 123  
    
 124  
    /**
 125  
     * This returns the order annotation used to determine the order
 126  
     * of serialization of attributes and elements. The order is a
 127  
     * class level annotation that can be used only once per class
 128  
     * XML schema. If none exists then this will return null.
 129  
     *  of the class processed by this scanner.
 130  
     * 
 131  
     * @return this returns the name of the object being scanned
 132  
     */
 133  
    Order getOrder();
 134  
    
 135  
    /**
 136  
     * This returns the <code>Default</code> annotation access type
 137  
     * that has been specified by this. If no default annotation has
 138  
     * been declared on the type then this will return null.
 139  
     * 
 140  
     * @return this returns the default access type for this type
 141  
     */
 142  
    DefaultType getAccess();
 143  
    
 144  
    /**
 145  
     * This returns the <code>Namespace</code> annotation that was
 146  
     * declared on the type. If no annotation has been declared on the
 147  
     * type this will return null as not belonging to any.
 148  
     * 
 149  
     * @return this returns the namespace this type belongs to, if any
 150  
     */
 151  
    Namespace getNamespace();
 152  
    
 153  
    /**
 154  
     * This returns the <code>NamespaceList</code> annotation that was
 155  
     * declared on the type. A list of namespaces are used to simply 
 156  
     * declare the namespaces without specifically making the type
 157  
     * belong to any of the declared namespaces.
 158  
     * 
 159  
     * @return this returns the namespace declarations, if any
 160  
     */
 161  
    NamespaceList getNamespaceList();
 162  
    
 163  
    /**
 164  
     * This returns a list of the methods that belong to this type. 
 165  
     * The methods here do not include any methods from the super
 166  
     * types and simply provides a means of caching method data.
 167  
     * 
 168  
     * @return returns the list of methods declared for the type
 169  
     */
 170  
    List<MethodDetail> getMethods();
 171  
    
 172  
    /**
 173  
     * This returns a list of the fields that belong to this type. 
 174  
     * The fields here do not include any fields from the super
 175  
     * types and simply provides a means of caching method data.
 176  
     * 
 177  
     * @return returns the list of fields declared for the type
 178  
     */
 179  
    List<FieldDetail> getFields();
 180  
    
 181  
    /**
 182  
     * This returns the annotations that have been declared for this
 183  
     * type. It is preferable to acquire the declared annotations
 184  
     * from this method as they are cached. Older versions of some
 185  
     * runtime environments, particularly Android, are slow at this.
 186  
     * 
 187  
     * @return this returns the annotations associated with this
 188  
     */
 189  
    Annotation[] getAnnotations();
 190  
    
 191  
    /**
 192  
     * This returns the constructors that have been declared for this
 193  
     * type. It is preferable to acquire the declared constructors
 194  
     * from this method as they are cached. Older versions of some
 195  
     * runtime environments, particularly Android, are slow at this.
 196  
     * 
 197  
     * @return this returns the constructors associated with this
 198  
     */
 199  
    Constructor[] getConstructors();
 200  
 }