Coverage Report - org.simpleframework.xml.convert.Convert
 
Classes in this File Line Coverage Branch Coverage Complexity
Convert
N/A
N/A
0
 
 1  
 /*
 2  
  * Convert.java January 2010
 3  
  *
 4  
  * Copyright (C) 2010, 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.convert;
 20  
 
 21  
 import java.lang.annotation.Retention;
 22  
 import java.lang.annotation.RetentionPolicy;
 23  
 
 24  
 /**
 25  
  * The <code>Convert</code> annotation is used to specify a converter
 26  
  * class to use for serialization. This annotation is used when an
 27  
  * object needs to be serialized but can not be annotated or when the
 28  
  * object can not conform to an existing XML structure. In order to
 29  
  * specify a <code>Converter</code> object a field or method can be
 30  
  * annotated like the field below.
 31  
  * <pre>
 32  
  * 
 33  
  *    &#64;Element
 34  
  *    &#64;Convert(ExampleConverter.class)
 35  
  *    private Example example;
 36  
  * 
 37  
  * </pre>
 38  
  * Note that for the above field the <code>Element</code> annotation
 39  
  * is required. If this is used with any other XML annotation such 
 40  
  * as the <code>ElementList</code> or <code>Text</code> annotation
 41  
  * then an exception will be thrown. As well as field and methods
 42  
  * this can be used to suggest a converter for a class. Take the 
 43  
  * class below which is annotated.
 44  
  * <pre>
 45  
  * 
 46  
  *    &#64;Root
 47  
  *    &#64;Convert(DemoConverter.class)
 48  
  *    public class Demo {
 49  
  *       ...
 50  
  *    }
 51  
  * 
 52  
  * </pre>
 53  
  * For the above class the specified converter will be used. This is
 54  
  * useful when the class is used within a <code>java.util.List</code>
 55  
  * or another similar collection. Finally, in order for this to work
 56  
  * it must be used with the <code>AnnotationStrategy</code> which is
 57  
  * used to scan for annotations in order to delegate to converters.
 58  
  * 
 59  
  * @author Niall Gallagher
 60  
  * 
 61  
  * @see org.simpleframework.xml.convert.AnnotationStrategy
 62  
  */
 63  
 @Retention(RetentionPolicy.RUNTIME)
 64  
 public @interface Convert {
 65  
    
 66  
    /**
 67  
     * Specifies the <code>Converter</code> implementation to be used
 68  
     * to convert the annotated object. The converter specified will
 69  
     * be used to convert the object to XML by intercepting the 
 70  
     * serialization and deserialization process as it happens. A
 71  
     * converter should typically be used to handle an object of 
 72  
     * a specific type.
 73  
     * 
 74  
     * @return this returns the converter that has been specified
 75  
     */
 76  
    Class<? extends Converter> value();
 77  
 }