Coverage Report - org.simpleframework.xml.transform.Transform
 
Classes in this File Line Coverage Branch Coverage Complexity
Transform
N/A
N/A
1
 
 1  
 /*
 2  
  * Transform.java May 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.transform;
 20  
 
 21  
 /**
 22  
  * A <code>Transform</code> represents a an object used to transform
 23  
  * an object to and from a string value. This is typically used when
 24  
  * either an <code>Attribute</code> or <code>Element</code> annotation
 25  
  * is used to mark the field of a type that does not contain any of
 26  
  * the XML annotations, and so does not represent an XML structure.
 27  
  * For example take the following annotation.
 28  
  * <pre>
 29  
  * 
 30  
  *    &#64;Text
 31  
  *    private Date date;
 32  
  *    
 33  
  * </pre> 
 34  
  * The above annotation marks an object from the Java class libraries
 35  
  * which does not contain any XML annotations. During serialization
 36  
  * and deserialization of such types a transform is used to process
 37  
  * the object such that it can be written and read to and from XML.
 38  
  * 
 39  
  * @author Niall Gallagher
 40  
  */
 41  
 public interface Transform<T> {
 42  
    
 43  
    /**
 44  
     * This method is used to convert the string value given to an
 45  
     * appropriate representation. This is used when an object is
 46  
     * being deserialized from the XML document and the value for
 47  
     * the string representation is required.
 48  
     * 
 49  
     * @param value this is the string representation of the value
 50  
     * 
 51  
     * @return this returns an appropriate instanced to be used
 52  
     */
 53  
     T read(String value) throws Exception;
 54  
     
 55  
     /**
 56  
      * This method is used to convert the provided value into an XML
 57  
      * usable format. This is used in the serialization process when
 58  
      * there is a need to convert a field value in to a string so 
 59  
      * that that value can be written as a valid XML entity.
 60  
      * 
 61  
      * @param value this is the value to be converted to a string
 62  
      * 
 63  
      * @return this is the string representation of the given value
 64  
      */
 65  
     String write(T value) throws Exception;
 66  
 }