Coverage Report - org.simpleframework.xml.core.Parameter
 
Classes in this File Line Coverage Branch Coverage Complexity
Parameter
N/A
N/A
1
 
 1  
 /*
 2  
  * Parameter.java July 2009
 3  
  *
 4  
  * Copyright (C) 2009, 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  
 
 23  
 /**
 24  
  * The <code>Parameter</code> is used to represent a constructor 
 25  
  * parameter. It contains the XML annotation used on the parameter
 26  
  * as well as the name of the parameter and its position index.
 27  
  * A parameter is used to validate against the annotated methods 
 28  
  * and fields and also to determine the deserialized values that
 29  
  * should be injected in to the constructor to instantiate it.
 30  
  * 
 31  
  * @author Niall Gallagher
 32  
  */
 33  
 interface Parameter {
 34  
    
 35  
    /**
 36  
     * This is the key used to represent the parameter. The key is
 37  
     * used to store the parameter in hash containers. Unlike the
 38  
     * path is not necessarily the path for the parameter.
 39  
     * 
 40  
     * @return this is the key used to represent the parameter
 41  
     */
 42  
    Object getKey();
 43  
    
 44  
    /**
 45  
     * This is used to acquire the annotated type class. The class
 46  
     * is the type that is to be deserialized from the XML. This
 47  
     * is used to validate against annotated fields and methods.
 48  
     * 
 49  
     * @return this returns the type used for the parameter
 50  
     */
 51  
    Class getType();
 52  
    
 53  
    /**
 54  
     * This returns the index position of the parameter in the
 55  
     * constructor. This is used to determine the order of values
 56  
     * that are to be injected in to the constructor.
 57  
     * 
 58  
     * @return this returns the index for the parameter
 59  
     */
 60  
    int getIndex();
 61  
    
 62  
    /**
 63  
     * This is used to acquire the annotation that is used for the
 64  
     * parameter. The annotation provided will be an XML annotation
 65  
     * such as the <code>Element</code> or <code>Attribute</code>
 66  
     * annotation.
 67  
     * 
 68  
     * @return this returns the annotation used on the parameter
 69  
     */
 70  
    Annotation getAnnotation();
 71  
 
 72  
    /**
 73  
     * This method is used to return an XPath expression that is 
 74  
     * used to represent the position of this parameter. If there is 
 75  
     * no XPath expression associated with this then an empty path 
 76  
     * is returned. This will never return a null expression.
 77  
     * 
 78  
     * @return the XPath expression identifying the location
 79  
     */
 80  
    Expression getExpression(); 
 81  
    
 82  
    /**
 83  
     * This is used to acquire the name of the parameter that this
 84  
     * represents. The name is determined using annotation and 
 85  
     * the name attribute of that annotation, if one is provided.
 86  
     * 
 87  
     * @return this returns the name of the annotated parameter
 88  
     */
 89  
    String getName();
 90  
    
 91  
    /**
 92  
     * This is used to acquire the path of the element or attribute
 93  
     * represented by this parameter. The path is determined by
 94  
     * acquiring the XPath expression and appending the name of the
 95  
     * label to form a fully qualified path.
 96  
     * 
 97  
     * @return returns the path that is used for this parameter
 98  
     */
 99  
    String getPath();
 100  
    
 101  
    /**
 102  
     * This is used to determine if the parameter is required. If 
 103  
     * an attribute is not required then it can be null. Which 
 104  
     * means that we can inject a null value. Also, this means we
 105  
     * can match constructors in a more flexible manner.
 106  
     * 
 107  
     * @return this returns true if the parameter is required
 108  
     */
 109  
    boolean isRequired();
 110  
    
 111  
    /**
 112  
     * This is used to determine if the parameter is primitive. A
 113  
     * primitive parameter must not be null. As there is no way to
 114  
     * provide the value to the constructor. A default value is 
 115  
     * not a good solution as it affects the constructor score.
 116  
     * 
 117  
     * @return this returns true if the parameter is primitive
 118  
     */
 119  
    boolean isPrimitive();
 120  
    
 121  
    /**
 122  
     * This method is used to determine if the parameter represents 
 123  
     * an attribute. This is used to style the name so that elements
 124  
     * are styled as elements and attributes are styled as required.
 125  
     * 
 126  
     * @return this is used to determine if this is an attribute
 127  
     */
 128  
    boolean isAttribute();
 129  
    
 130  
    /**
 131  
     * This is used to determine if the parameter represents text. 
 132  
     * If this represents text it typically does not have a name,
 133  
     * instead the empty string represents the name. Also text
 134  
     * parameters can not exist with other text parameters.
 135  
     * 
 136  
     * @return returns true if this parameter represents text
 137  
     */
 138  
    boolean isText();
 139  
    
 140  
    /**
 141  
     * This is used to provide a textual representation of the 
 142  
     * parameter. Providing a string describing the parameter is
 143  
     * useful for debugging and for exception messages.
 144  
     * 
 145  
     * @return this returns the string representation for this
 146  
     */
 147  
    String toString();
 148  
 }