Quaqua 5.4.1 2009-07-14

ch.randelshofer.quaqua.osx
Class OSXClipboardTransferable

java.lang.Object
  extended by ch.randelshofer.quaqua.osx.OSXClipboardTransferable
All Implemented Interfaces:
java.awt.datatransfer.Transferable

public class OSXClipboardTransferable
extends java.lang.Object
implements java.awt.datatransfer.Transferable

OSXClipboardTransferable provides read access to the Mac OS X system clipboard.

All data flavors returned by this object have the mime type application/octet-stream; type=....

The following code snippet shows how to determine the native data type a flavor:

 import java.net.URLDecoder;

 String nativeDataType = URLDecoder.decode(dataFlavor.getParameter("type"),"UTF-8");
 

The system clipboard data is retrieved using the Cocoa class NSPasteboard.

Version:
$Id: OSXClipboardTransferable.java 82 2009-06-11 08:57:33Z wrandelshofer $
Author:
Werner Randelshofer

Constructor Summary
OSXClipboardTransferable()
           
 
Method Summary
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
          Reads the data from the "General Clipboard" Cocoa NSPasteboard.
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
          Returns the data flavors which are currently in the NSPasteboard.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
          Returns true if the "General Clipboard" Cocoa NSPasteboard currently supports the specified data flavor.
static boolean isNativeCodeAvailable()
          Returns true if native code is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSXClipboardTransferable

public OSXClipboardTransferable()
Method Detail

isNativeCodeAvailable

public static boolean isNativeCodeAvailable()
Returns true if native code is available. This method also loads the native code.


getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Returns the data flavors which are currently in the NSPasteboard. The mime type of all flavors is application/octet-stream. The actual type information is in the human presentable name!

Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returns true if the "General Clipboard" Cocoa NSPasteboard currently supports the specified data flavor.

Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
                                 throws java.awt.datatransfer.UnsupportedFlavorException,
                                        java.io.IOException
Reads the data from the "General Clipboard" Cocoa NSPasteboard. If the data flavor is supported, always returns it as a byte array.

Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.