KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jftp > gui > framework > FileTransferable


1 package net.sf.jftp.gui.framework;
2
3 import java.awt.datatransfer.*;
4 import java.awt.dnd.*;
5
6 import java.io.*;
7
8 import java.util.*;
9
10
11 public class FileTransferable implements Transferable //, ClipboardOwner
12
{
13     public static final DataFlavor plainTextFlavor = DataFlavor.plainTextFlavor;
14     public static final DataFlavor[] flavors =
15                                                {
16                                                    FileTransferable.plainTextFlavor,
17                                                };
18     private static final List flavorList = Arrays.asList(flavors);
19
20     public synchronized DataFlavor[] getTransferDataFlavors()
21     {
22         return flavors;
23     }
24
25     public boolean isDataFlavorSupported(DataFlavor flavor)
26     {
27         return (flavorList.contains(flavor));
28     }
29
30     public synchronized Object JavaDoc getTransferData(DataFlavor flavor)
31                                         throws UnsupportedFlavorException,
32                                                IOException
33     {
34         if(flavor.equals(FileTransferable.plainTextFlavor))
35         {
36             return new ByteArrayInputStream(this.toString().getBytes("iso8859-1"));
37         }
38         else
39         {
40             throw new UnsupportedFlavorException(flavor);
41         }
42     }
43 }
44
Popular Tags