KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > dnd > RTFTransfer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.dnd;
12
13  
14 /**
15  * The class <code>RTFTransfer</code> provides a platform specific mechanism
16  * for converting text in RTF format represented as a java <code>String</code>
17  * to a platform specific representation of the data and vice versa. See
18  * <code>Transfer</code> for additional information.
19  *
20  * <p>An example of a java <code>String</code> containing RTF text is shown
21  * below:</p>
22  *
23  * <code><pre>
24  * String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
25  * </code></pre>
26  */

27 public class RTFTransfer extends ByteArrayTransfer {
28
29     private static RTFTransfer _instance = new RTFTransfer();
30     private static final String JavaDoc TYPENAME1 = "text/rtf\0";
31     private static final int TYPEID1 = registerType(TYPENAME1);
32     private static final String JavaDoc TYPENAME2 = "TEXT/RTF\0";
33     private static final int TYPEID2 = registerType(TYPENAME2);
34     private static final String JavaDoc TYPENAME3 = "application/rtf\0";
35     private static final int TYPEID3 = registerType(TYPENAME3);
36
37 private RTFTransfer() {
38 }
39 /**
40  * Returns the singleton instance of the RTFTransfer class.
41  *
42  * @return the singleton instance of the RTFTransfer class
43  */

44 public static RTFTransfer getInstance () {
45     return _instance;
46 }
47 /**
48  * This implementation of <code>javaToNative</code> converts RTF-formatted text
49  * represented by a java <code>String</code> to a platform specific representation.
50  * For additional information see <code>Transfer#javaToNative</code>.
51  *
52  * @param object a java <code>String</code> containing RTF text
53  * @param transferData an empty <code>TransferData</code> object; this
54  * object will be filled in on return with the platform specific format of the data
55  */

56 public void javaToNative (Object JavaDoc object, TransferData transferData){
57 }
58 /**
59  * This implementation of <code>nativeToJava</code> converts a platform specific
60  * representation of RTF text to a java <code>String</code>.
61  * For additional information see <code>Transfer#nativeToJava</code>.
62  *
63  * @param transferData the platform specific representation of the data to be
64  * been converted
65  * @return a java <code>String</code> containing RTF text if the
66  * conversion was successful; otherwise null
67  */

68 public Object JavaDoc nativeToJava(TransferData transferData){
69     return null;
70 }
71 protected String JavaDoc[] getTypeNames(){
72     return new String JavaDoc[]{TYPENAME1, TYPENAME2, TYPENAME3};
73 }
74 protected int[] getTypeIds(){
75     return new int[]{TYPEID1, TYPEID2, TYPEID3};
76 }
77 }
78
Popular Tags