KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > ftp > FtpMessageAdapter


1 /*
2  * $Id: FtpMessageAdapter.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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.providers.AbstractMessageAdapter;
14 import org.mule.umo.MessagingException;
15 import org.mule.umo.provider.MessageTypeNotSupportedException;
16
17 public class FtpMessageAdapter extends AbstractMessageAdapter
18 {
19     /**
20      * Serial version
21      */

22     private static final long serialVersionUID = 7268290145485349941L;
23
24     private final byte[] message;
25
26     public FtpMessageAdapter(Object JavaDoc message) throws MessagingException
27     {
28         if (message instanceof byte[])
29         {
30             this.message = (byte[])message;
31         }
32         else
33         {
34             throw new MessageTypeNotSupportedException(message, getClass());
35         }
36     }
37
38     /**
39      * Converts the message implementation into a String representation
40      *
41      * @param encoding The encoding to use when transforming the message (if
42      * necessary). The parameter is used when converting from a byte array
43      * @return String representation of the message payload
44      * @throws Exception Implementation may throw an endpoint specific exception
45      */

46     public String JavaDoc getPayloadAsString(String JavaDoc encoding) throws Exception JavaDoc
47     {
48         return new String JavaDoc(message, encoding);
49     }
50
51     public byte[] getPayloadAsBytes() throws Exception JavaDoc
52     {
53         return message;
54     }
55
56     public Object JavaDoc getPayload()
57     {
58         return message;
59     }
60
61 }
62
Popular Tags