Coverage Report - org.mule.providers.ftp.FtpMessageAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
FtpMessageAdapter
42%
5/12
50%
1/2
1.333
 
 1  
 /*
 2  
  * $Id: FtpMessageAdapter.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.providers.ftp;
 12  
 
 13  
 import org.mule.impl.ThreadSafeAccess;
 14  
 import org.mule.providers.AbstractMessageAdapter;
 15  
 import org.mule.umo.MessagingException;
 16  
 import org.mule.umo.provider.MessageTypeNotSupportedException;
 17  
 
 18  
 public class FtpMessageAdapter extends AbstractMessageAdapter
 19  
 {
 20  
     /**
 21  
      * Serial version
 22  
      */
 23  
     private static final long serialVersionUID = 7268290145485349941L;
 24  
 
 25  
     private final byte[] message;
 26  
 
 27  
     public FtpMessageAdapter(Object message) throws MessagingException
 28  4
     {
 29  4
         if (message instanceof byte[])
 30  
         {
 31  4
             this.message = (byte[])message;
 32  
         }
 33  
         else
 34  
         {
 35  0
             throw new MessageTypeNotSupportedException(message, getClass());
 36  
         }
 37  4
     }
 38  
 
 39  
     protected FtpMessageAdapter(FtpMessageAdapter template)
 40  
     {
 41  0
         super(template);
 42  0
         message = template.message;
 43  0
     }
 44  
 
 45  
     /**
 46  
      * Converts the message implementation into a String representation
 47  
      * 
 48  
      * @param encoding The encoding to use when transforming the message (if
 49  
      *            necessary). The parameter is used when converting from a byte array
 50  
      * @return String representation of the message payload
 51  
      * @throws Exception Implementation may throw an endpoint specific exception
 52  
      */
 53  
     public String getPayloadAsString(String encoding) throws Exception
 54  
     {
 55  2
         return new String(message, encoding);
 56  
     }
 57  
 
 58  
     public byte[] getPayloadAsBytes() throws Exception
 59  
     {
 60  0
         return message;
 61  
     }
 62  
 
 63  
     public Object getPayload()
 64  
     {
 65  0
         return message;
 66  
     }
 67  
 
 68  
     public ThreadSafeAccess newThreadCopy()
 69  
     {
 70  0
         return new FtpMessageAdapter(this);
 71  
     }
 72  
     
 73  
 }