Coverage Report - org.apache.commons.betwixt.schema.DefaultDataTypeMapper

Classes in this File Line Coverage Branch Coverage Complexity
DefaultDataTypeMapper
100% 
100% 
21

 1  
 /*
 2  
  * Copyright 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  
 
 17  
 package org.apache.commons.betwixt.schema;
 18  
 
 19  
 import java.math.BigDecimal;
 20  
 import java.math.BigInteger;
 21  
 
 22  
 /**
 23  
  * Default <code>DataTypeMapper</code>implementation.
 24  
  * Provides a reasonably standard and compatible mapping.
 25  
  * @author <a href='http://jakarta.apache.org/'>Apache Commons Team</a>
 26  
  * @version $Revision: 155402 $
 27  
  */
 28  260
 public class DefaultDataTypeMapper extends DataTypeMapper {
 29  
 
 30  
     /**
 31  
      * This implementation provides
 32  
      * @see org.apache.commons.betwixt.schema.DataTypeMapper#toXMLSchemaDataType(java.lang.Class)
 33  
      */
 34  
     public String toXMLSchemaDataType(Class type) {
 35  
         // default mapping is to string
 36  975
         String result = "xsd:string";
 37  975
         if (String.class.equals(type)) {
 38  429
             result = "xsd:string";
 39  
             
 40  546
         } else if (BigInteger.class.equals(type)) {
 41  26
             result = "xsd:integer";
 42  
             
 43  520
         } else if (Integer.TYPE.equals(type)) {
 44  52
             result = "xsd:int";
 45  
 
 46  468
         } else if (Integer.class.equals(type)) {
 47  26
             result = "xsd:int";
 48  
             
 49  442
         } else if (Long.TYPE.equals(type)) {
 50  26
             result = "xsd:long";
 51  
 
 52  416
         } else if (Long.class.equals(type)) {
 53  26
             result = "xsd:long";
 54  
 
 55  390
         } else if (Short.TYPE.equals(type)) {
 56  26
             result = "xsd:short";
 57  
 
 58  364
         } else if (Short.class.equals(type)) {
 59  26
             result = "xsd:short";
 60  
 
 61  338
         } else if (BigDecimal.class.equals(type)) {
 62  26
             result = "xsd:decimal";
 63  
 
 64  312
         } else if (Float.TYPE.equals(type)) {
 65  26
             result = "xsd:float";
 66  
 
 67  286
         } else if (Float.class.equals(type)) {
 68  26
             result = "xsd:float";
 69  
 
 70  260
         } else if (Double.TYPE.equals(type)) {
 71  26
             result = "xsd:double";
 72  
 
 73  234
         } else if (Double.class.equals(type)) {
 74  26
             result = "xsd:double";
 75  
 
 76  208
         } else if (Boolean.TYPE.equals(type)) {
 77  26
             result = "xsd:boolean";
 78  
 
 79  182
         } else if (Boolean.class.equals(type)) {
 80  26
             result = "xsd:boolean";
 81  
 
 82  156
         } else if (Byte.TYPE.equals(type)) {
 83  39
             result = "xsd:byte";
 84  
 
 85  117
         } else if (Byte.class.equals(type)) {
 86  13
             result = "xsd:byte";
 87  
 
 88  104
         } else if (java.util.Date.class.equals(type)) {
 89  26
             result = "xsd:dateTime";
 90  
             
 91  78
         } else if (java.sql.Date.class.equals(type)) {
 92  26
             result = "xsd:date";
 93  
 
 94  52
         } else if (java.sql.Time.class.equals(type)) {
 95  26
             result = "xsd:time";
 96  
         }
 97  
         
 98  975
         return result;
 99  
     }
 100  
     
 101  
     
 102  
 }