Coverage Report - org.simpleframework.xml.transform.LongTransform
 
Classes in this File Line Coverage Branch Coverage Complexity
LongTransform
100%
3/3
N/A
1
 
 1  
 /*
 2  
  * LongTransform.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  
  * The <code>LongTransform</code> object is used to transform long
 23  
  * values to and from string representations, which will be inserted
 24  
  * in the generated XML document as the value place holder. The
 25  
  * value must be readable and writable in the same format. Fields
 26  
  * and methods annotated with the XML attribute annotation will use
 27  
  * this to persist and retrieve the value to and from the XML source.
 28  
  * <pre>
 29  
  * 
 30  
  *    &#64;Attribute
 31  
  *    private Long octet;
 32  
  *    
 33  
  * </pre>
 34  
  * As well as the XML attribute values using transforms, fields and
 35  
  * methods annotated with the XML element annotation will use this.
 36  
  * Aside from the obvious difference, the element annotation has an
 37  
  * advantage over the attribute annotation in that it can maintain
 38  
  * any references using the <code>CycleStrategy</code> object. 
 39  
  * 
 40  
  * @author Niall Gallagher
 41  
  */
 42  225
 class LongTransform implements Transform<Long> {
 43  
    
 44  
    /**
 45  
     * This method is used to convert the string value given to an
 46  
     * appropriate representation. This is used when an object is
 47  
     * being deserialized from the XML document and the value for
 48  
     * the string representation is required.
 49  
     * 
 50  
     * @param value this is the string representation of the value
 51  
     * 
 52  
     * @return this returns an appropriate instanced to be used
 53  
     */
 54  
    public Long read(String value) {
 55  57
       return Long.valueOf(value);
 56  
    }
 57  
    
 58  
    /**
 59  
     * This method is used to convert the provided value into an XML
 60  
     * usable format. This is used in the serialization process when
 61  
     * there is a need to convert a field value in to a string so 
 62  
     * that that value can be written as a valid XML entity.
 63  
     * 
 64  
     * @param value this is the value to be converted to a string
 65  
     * 
 66  
     * @return this is the string representation of the given value
 67  
     */
 68  
    public String write(Long value) {
 69  98
       return value.toString();
 70  
    }
 71  
 }