01: package net.sf.jftp.gui.framework;
02:
03: import java.awt.datatransfer.*;
04: import java.awt.dnd.*;
05:
06: import java.io.*;
07:
08: import java.util.*;
09:
10: public class FileTransferable implements Transferable //, ClipboardOwner
11: {
12: public static final DataFlavor plainTextFlavor = DataFlavor.plainTextFlavor;
13: public static final DataFlavor[] flavors = { FileTransferable.plainTextFlavor, };
14: private static final List flavorList = Arrays.asList(flavors);
15:
16: public synchronized DataFlavor[] getTransferDataFlavors() {
17: return flavors;
18: }
19:
20: public boolean isDataFlavorSupported(DataFlavor flavor) {
21: return (flavorList.contains(flavor));
22: }
23:
24: public synchronized Object getTransferData(DataFlavor flavor)
25: throws UnsupportedFlavorException, IOException {
26: if (flavor.equals(FileTransferable.plainTextFlavor)) {
27: return new ByteArrayInputStream(this .toString().getBytes(
28: "iso8859-1"));
29: } else {
30: throw new UnsupportedFlavorException(flavor);
31: }
32: }
33: }
|