Coverage Report - org.simpleframework.xml.Text
 
Classes in this File Line Coverage Branch Coverage Complexity
Text
N/A
N/A
0
 
 1  
 /*
 2  
  * Text.java April 2007
 3  
  *
 4  
  * Copyright (C) 2007, 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;
 20  
 
 21  
 import java.lang.annotation.RetentionPolicy;
 22  
 import java.lang.annotation.Retention;
 23  
 
 24  
 /**
 25  
  * The <code>Text</code> annotation is used to represent a field or
 26  
  * method that appears as text within an XML element. Methods and
 27  
  * fields annotated with this must represent primitive values, which
 28  
  * means that the type is converted to and from an XML representation
 29  
  * using a <code>Transform</code> object. For example, the primitive 
 30  
  * types typically annotated could be strings, integers, or dates.  
 31  
  * <p>
 32  
  * One restriction on this annotation is that it can only appear once 
 33  
  * within a schema class, and it can not appear with the another XML 
 34  
  * element annotations, such as the <code>Element</code> annotation. 
 35  
  * It can however appear with any number of <code>Attribute</code> 
 36  
  * annotations.
 37  
  * <pre>
 38  
  * 
 39  
  *    &lt;example one="value" two="value"&gt;
 40  
  *       Example text value       
 41  
  *    &lt;/example&gt;
 42  
  * 
 43  
  * </pre>
 44  
  * Text values are used when an element containing attributes is
 45  
  * used to wrap a text value with no child elements. This can be
 46  
  * used in place of an element annotation to represent a primitive
 47  
  * which is wrapped in a surrounding XML element.
 48  
  * 
 49  
  * @author Niall Gallagher
 50  
  * 
 51  
  * @see org.simpleframework.xml.transform.Transformer
 52  
  */ 
 53  
 @Retention(RetentionPolicy.RUNTIME)
 54  
 public @interface Text {
 55  
    
 56  
    /**
 57  
     * This is used to provide a default value for the text data if
 58  
     * the annotated field or method is null. This ensures the the
 59  
     * serialization process writes the text data with a value even
 60  
     * if the value is null, and allows deserialization to determine
 61  
     * whether the value within the object was null or not.
 62  
     * 
 63  
     * @return this returns the default attribute value to use
 64  
     */
 65  
    String empty() default "";
 66  
    
 67  
    /**
 68  
     * This is used to determine whether the text is written within 
 69  
     * CDATA block or not. If this is set to true then the text is
 70  
     * written within a CDATA block, by default the text is output
 71  
     * as escaped XML. Typically this is used for large text values.
 72  
     * 
 73  
     * @return true if the data is to be wrapped in a CDATA block
 74  
     */
 75  
    boolean data() default false;
 76  
    
 77  
    /**
 78  
     * Determines whether the text value is required within the XML
 79  
     * document. Any field marked as not required may not have its
 80  
     * value set when the object is deserialized. If an object is to
 81  
     * be serialized only a null attribute will not appear in XML.
 82  
     * 
 83  
     * @return true if the element is required, false otherwise
 84  
     */
 85  
    boolean required() default true; 
 86  
 }