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