Coverage details for org.chwf.converter.DefaultConverter

LineHitsSource
1 /*
2 Chrysalis Web Framework [http://chrysalis.sourceforge.net]
3 Copyright (c) 2002, 2003, 2004, Paul Strack
4  
5 All rights reserved.
6  
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9  
10 1. Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12  
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16  
17 3. Neither the name of the copyright holder nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20  
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32  
33 package org.chwf.converter;
34  
35 /**
36  * Default converter class. It does not support the parse method, and uses the
37  * object's <code>toString()</code> method for formatting.<p>
38  *
39  * @author <a href="mailto:pfstrack@users.sourceforge.net">Paul Strack</a>
40  */
411public class DefaultConverter extends Converter {
42  
43   /** Empty array */
441  private static final Object[] EMPTY_ARRAY = new Object[0];
45  
46   /**
47    * Always fails for the default converter.<p>
48    *
49    * @param value The value being parsed.
50    * @return The resulting object.
51    * @throws ConversionException Always thrown for default converter.
52    */
53   public Object parse(String value) throws ConversionException {
541    throw new ConversionException(
55       ConversionException.MESSAGE_NO_PARSING,
56       EMPTY_ARRAY);
57   }
58  
59   /**
60    * Format the object as a string using the its <code>toString()</code>
61    * method.<p>
62    *
63    * @param value The value being format.
64    * @return The resulting string.
65    */
66   public String format(Object value) {
672    if (value == null) {
681      return null;
69     } else {
701      return value.toString();
71     }
72   }
73  
74   /**
75    * Overrides the superclass method.<p>
76    *
77    * @return Always false; types using the default converter are by definition
78    * not simple.
79    */
80   public boolean isSimpleType() {
8133    return false;
82   }
83 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.