Coverage Report - org.apache.commons.convert1.format.FormatConverter
 
Classes in this File Line Coverage Branch Coverage Complexity
FormatConverter
0%
0/6
0%
0/4
2
 
 1  
 /*
 2  
  *  Copyright 2003-2004 The Apache Software Foundation
 3  
  *
 4  
  *  Licensed under the Apache License, Version 2.0 (the "License");
 5  
  *  you may not use this file except in compliance with the License.
 6  
  *  You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  *  Unless required by applicable law or agreed to in writing, software
 11  
  *  distributed under the License is distributed on an "AS IS" BASIS,
 12  
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  *  See the License for the specific language governing permissions and
 14  
  *  limitations under the License.
 15  
  */
 16  
 package org.apache.commons.convert1.format;
 17  
 
 18  
 
 19  
 import org.apache.commons.convert1.ConversionException;
 20  
 import org.apache.commons.convert1.Converter;
 21  
 
 22  
 import java.text.Format;
 23  
 
 24  
 /**
 25  
  * java.text.Format.format(Object); String based converter.
 26  
  *
 27  
  * @author Henri Yandell
 28  
  * @version $Id: FormatConverter.java 155441 2005-02-26 13:19:22Z dirkv $
 29  
  * @since 0.1
 30  
  */
 31  
 
 32  
 public final class FormatConverter implements Converter {
 33  
 
 34  
     private Format format;
 35  
 
 36  0
     public FormatConverter(Format format) {
 37  0
         this.format = format;
 38  0
     }
 39  
 
 40  
     /**
 41  
      * Format the specified input object into a String
 42  
      *
 43  
      * @param type Data type to which this value should be converted
 44  
      * @param value The input value to be converted
 45  
      *
 46  
      * @exception ConversionException if conversion cannot be performed
 47  
      *  successfully
 48  
      */
 49  
     public Object convert(Class type, Object value) {
 50  0
         if(type != String.class) {
 51  0
             throw new ConversionException("FormatConverter must create Strings. ");
 52  
         }
 53  0
         return this.format.format(value);
 54  
     }
 55  
 
 56  
 
 57  
 }