1   /**
2    * JHylaFax - A java client for HylaFAX.
3    *
4    * Copyright (C) 2005 by Steffen Pingel <steffenp@gmx.de>
5    *
6    * This program is free software; you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation; either version 2 of the License, or
9    * (at your option) any later version.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with this program; if not, write to the Free Software
18   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19   */
20  package net.sf.jhylafax.addressbook;
21  
22  import java.awt.datatransfer.DataFlavor;
23  import java.awt.datatransfer.Transferable;
24  import java.awt.datatransfer.UnsupportedFlavorException;
25  import java.io.IOException;
26  import java.io.InputStream;
27  
28  public class ContactTransferable implements Transferable
29  {
30  	public final static DataFlavor VCARD_FLAVOR 
31  		= new DataFlavor("text/x-vcard;class=java.io.InputStream", "vCard");
32  	//charset=UTF-8;
33  	
34  	private InputStream in;
35  
36  	public ContactTransferable(InputStream in)
37  	{
38  		this.in = in;
39  	}
40  	
41  	public DataFlavor[] getTransferDataFlavors()
42  	{
43  		return new DataFlavor[] { VCARD_FLAVOR };
44  	}
45  
46  	public boolean isDataFlavorSupported(DataFlavor flavor)
47  	{
48  		return VCARD_FLAVOR.equals(flavor);
49  	}
50  
51  	public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException
52  	{
53  		return in;
54  	}
55  	
56  }