KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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>TextTransfer</code> provides a platform specific mechanism
16  * for converting plain text represented as a java <code>String</code>
17  * to a platform specific representation of the data and vice versa.
18  *
19  * <p>An example of a java <code>String</code> containing plain text is shown
20  * below:</p>
21  *
22  * <code><pre>
23  * String textData = "Hello World";
24  * </code></pre>
25  *
26  * @see Transfer
27  */

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

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

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

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