Coverage Report - org.mule.module.ibeans.spi.support.DataTypeConverter
 
Classes in this File Line Coverage Branch Coverage Complexity
DataTypeConverter
0%
0/9
0%
0/4
3
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.module.ibeans.spi.support;
 8  
 
 9  
 import org.mule.api.transformer.DataType;
 10  
 import org.mule.transformer.types.CollectionDataType;
 11  
 import org.mule.transformer.types.DataTypeFactory;
 12  
 
 13  
 import javax.activation.MimeTypeParseException;
 14  
 
 15  
 import org.ibeans.api.channel.MimeType;
 16  
 
 17  
 /**
 18  
  * Both Mule and iBeans define a DataType model for associating Java types with other info such as mime type and encoding
 19  
  * This classes provides a couple of functions to convert between the two models
 20  
  */
 21  0
 public class DataTypeConverter
 22  
 {
 23  
     public static org.ibeans.api.DataType convertMuleToIBeans(DataType muleDT) throws MimeTypeParseException
 24  
     {
 25  
     //Both Mule and iBeans have DataType implementations, need to wrap the Mule DataType to work with iBeans
 26  0
         if(muleDT instanceof CollectionDataType)
 27  
         {
 28  0
             CollectionDataType dt = (CollectionDataType)muleDT;
 29  0
             return org.ibeans.impl.support.datatype.DataTypeFactory.create(dt.getType(), dt.getItemType(), new MimeType(dt.getMimeType()));
 30  
         }
 31  
         else
 32  
         {
 33  0
             return org.ibeans.impl.support.datatype.DataTypeFactory.create(muleDT.getType(), new MimeType(muleDT.getMimeType()));
 34  
         }
 35  
 
 36  
     }
 37  
 
 38  
     public static DataType convertIBeansToMule(org.ibeans.api.DataType ibeansDT) throws MimeTypeParseException
 39  
     {
 40  
     //Both Mule and iBeans have DataType implementations, need to wrap the Mule DataType to work with iBeans
 41  0
         if(ibeansDT instanceof org.ibeans.impl.support.datatype.CollectionDataType)
 42  
         {
 43  0
             org.ibeans.impl.support.datatype.CollectionDataType dt = (org.ibeans.impl.support.datatype.CollectionDataType)ibeansDT;
 44  0
             return DataTypeFactory.create(dt.getType(), dt.getItemType(), dt.getMimeType());
 45  
         }
 46  
         else
 47  
         {
 48  0
             return DataTypeFactory.create(ibeansDT.getType(), ibeansDT.getMimeType());
 49  
         }
 50  
 
 51  
     }
 52  
 }