1 package net.sf.mmapps.applications.developer.dnd;
2
3 import java.awt.datatransfer.*;
4 import java.io.*;
5
6 public class XMLConfigurationTransferable implements Transferable, Serializable {
7 final public static DataFlavor XML_FLAVOR = new DataFlavor(XMLConfigurationTransferable.class, "XML Configuration");
8 static DataFlavor flavors[] = {XML_FLAVOR };
9 String type;
10 String xmlData;
11 String name;
12
13 public String getType(){
14 return type;
15 }
16
17 public String getXMLData(){
18 return xmlData;
19 }
20
21 public String getName(){
22 return name;
23 }
24
25 public XMLConfigurationTransferable(String type,String name,String xmlData){
26 this.type = type;
27 this.xmlData= xmlData;
28 this.name = name;
29 }
30
31 /*** Returns an object which represents the data to be transferred. The class
32 * of the object returned is defined by the representation class of the flavor.
33 *
34 * @param flavor the requested flavor for the data
35 * @see DataFlavor#getRepresentationClass
36 * @exception IOException if the data is no longer available
37 * in the requested flavor.
38 * @exception UnsupportedFlavorException if the requested data flavor is
39 * not supported.
40 *
41 */
42 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
43 if (flavor.equals(XML_FLAVOR)) {
44 return this;
45 }
46 else throw new UnsupportedFlavorException(flavor);
47
48 }
49
50 /*** Returns an array of DataFlavor objects indicating the flavors the data
51 * can be provided in. The array should be ordered according to preference
52 * for providing the data (from most richly descriptive to least descriptive).
53 * @return an array of data flavors in which this data can be transferred
54 *
55 */
56 public DataFlavor[] getTransferDataFlavors() {
57 return flavors;
58 }
59
60 /*** Returns whether or not the specified data flavor is supported for
61 * this object.
62 * @param flavor the requested flavor for the data
63 * @return boolean indicating whether or not the data flavor is supported
64 *
65 */
66 public boolean isDataFlavorSupported(DataFlavor flavor) {
67 return flavor.equals(XML_FLAVOR);
68
69 }
70 private void writeObject(java.io.ObjectOutputStream out) throws IOException {
71 out.defaultWriteObject();
72 }
73
74 private void readObject(java.io.ObjectInputStream in)
75 throws IOException, ClassNotFoundException {
76 in.defaultReadObject();
77 }
78
79 }