KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > spds > WBXMLSyncMLClient


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.syncclient.spds;
20
21 import java.io.IOException JavaDoc;
22
23 import sync4j.framework.tools.WBXMLTools;
24
25 /**
26  * Implement send / receive message in WBXML format by HttpConnection.
27  *
28  * The charSet is specified with the system property
29  * <code>spds.charset</code>;
30  * if <code>DEFAULT</code> value, the default charSet value is taken.<br>
31  * if no value, the default charSet API <code>UTF-8</vode> value is taken.
32  *
33  * @author Fabio Maggi
34  *
35  * @version $Id: WBXMLSyncMLClient.java,v 1.4 2005/07/14 10:18:02 harrie Exp $
36  *
37  */

38
39 public class WBXMLSyncMLClient
40 extends BaseSyncMLClient
41 implements SyncMLClient {
42
43     // --------------------------------------------------------------- Constants
44

45     // --------------------------------------------------------------- Private data
46

47     // --------------------------------------------------------------- Properties
48

49     // --------------------------------------------------------------- Public methods
50

51     public String JavaDoc sendMessage(String JavaDoc msg)
52     throws IOException JavaDoc {
53         return sendMessage(msg, "UTF-8");
54     }
55
56     // Note charset is not used yet, because of WBXML.
57
public String JavaDoc sendMessage(String JavaDoc msg, String JavaDoc charSet)
58     throws IOException JavaDoc {
59
60         String JavaDoc value = null;
61
62         try {
63             value = WBXMLTools.
64                 wbxmlToXml((sendMessage(WBXMLTools.toWBXML(msg))).getBytes());
65         } catch (Exception JavaDoc e) {
66             throw new IOException JavaDoc(e.getMessage());
67         }
68
69         return value;
70
71     }
72
73 }
74
Popular Tags