APIdia Launch Partner
Top Description Fields Constructors Methods
sun.awt.datatransfer

public abstract Class SunClipboard

extends Clipboard
Class Inheritance
Known Direct Subclasses
sun.awt.X11.XClipboard
Imports
java.awt.EventQueue, java.awt.datatransfer.Clipboard, .FlavorTable, .SystemFlavorMap, .Transferable, .ClipboardOwner, .DataFlavor, .FlavorListener, .FlavorEvent, .UnsupportedFlavorException, java.beans.PropertyChangeEvent, .PropertyChangeListener, java.util.Arrays, .Set, .HashSet, java.io.IOException, sun.awt.PeerEvent, .SunToolkit

Serves as a common, helper superclass for the Win32 and X11 system Clipboards.
Authors
Danila Sinopalnikov, Alexander Gerasimov
Since
1.3

Field Summary

Modifier and TypeField and Description
private volatile long[]
currentFormats

A set of DataFlavors that is available on this clipboard.

private static Set<FlavorListener>
private volatile int
numberOfFlavorListeners

A number of FlavorListeners currently registered on this clipboard

Inherited from java.awt.datatransfer.Clipboard:
contentsowner

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addFlavorListener(FlavorListener listener)

Overrides java.awt.datatransfer.Clipboard.addFlavorListener.

Registers the specified FlavorListener to receive FlavorEvents from this clipboard.

public boolean
protected final void
checkChange(final long[]
data formats that have just been retrieved from this clipboard
formats
)

Checks change of the DataFlavors and, if necessary, posts notifications on FlavorEvents to the EDT's.

protected abstract void
public void
protected Transferable
createLocaleTransferable(long[] formats)

The clipboard must be opened.

private static Set<DataFlavor>
public DataFlavor[]
getAvailableDataFlavors()

Overrides java.awt.datatransfer.Clipboard.getAvailableDataFlavors.

Returns an array of DataFlavors in which the current contents of this clipboard can be provided.

protected abstract byte[]
getClipboardData(long format)

protected abstract long[]
getClipboardFormats()

Returns zero-length array (not null) if the number of available formats is zero.

protected long[]
public synchronized Transferable
getContents(Object requestor)

Overrides java.awt.datatransfer.Clipboard.getContents.

Returns a transferable object representing the current contents of the clipboard.

protected synchronized Transferable
getContextContents()

Returns: the contents of this clipboard if it has been set or null otherwise

public Object
getData(DataFlavor flavor)

Overrides java.awt.datatransfer.Clipboard.getData.

Returns an object representing the current contents of this clipboard in the specified DataFlavor.

public static FlavorTable
public synchronized FlavorListener[]
getFlavorListeners()

Overrides java.awt.datatransfer.Clipboard.getFlavorListeners.

Returns an array of all the FlavorListeners currently registered on this Clipboard.

public abstract long
public boolean
isDataFlavorAvailable(DataFlavor flavor)

Overrides java.awt.datatransfer.Clipboard.isDataFlavorAvailable.

Returns whether or not the current contents of this clipboard can be provided in the specified DataFlavor.

protected void
protected void
lostOwnershipLater()

Clears the clipboard state (contents, owner and contents context) and notifies the current owner that ownership is lost.

protected void
public void
protected abstract void
public synchronized void
removeFlavorListener(FlavorListener listener)

Overrides java.awt.datatransfer.Clipboard.removeFlavorListener.

Removes the specified FlavorListener so that it no longer receives FlavorEvents from this Clipboard.

public synchronized void
setContents(Transferable contents, ClipboardOwner owner)

Overrides java.awt.datatransfer.Clipboard.setContents.

Sets the current contents of the clipboard to the specified transferable object and registers the specified clipboard owner as the owner of the new contents.

protected abstract void
protected abstract void
Inherited from java.awt.datatransfer.Clipboard:
getName

Field Detail

currentFormatsback to summary
private volatile long[] currentFormats

A set of DataFlavors that is available on this clipboard. It is used for tracking changes of DataFlavors available on this clipboard. Can be null.

flavorListenersback to summary
private static Set<FlavorListener> flavorListeners

Hides java.awt.datatransfer.Clipboard.flavorListeners.

numberOfFlavorListenersback to summary
private volatile int numberOfFlavorListeners

A number of FlavorListeners currently registered on this clipboard

Constructor Detail

SunClipboardback to summary
public SunClipboard(String name)

Method Detail

addFlavorListenerback to summary
public synchronized void addFlavorListener(FlavorListener listener)

Overrides java.awt.datatransfer.Clipboard.addFlavorListener.

Doc from java.awt.datatransfer.Clipboard.addFlavorListener.

Registers the specified FlavorListener to receive FlavorEvents from this clipboard. If listener is null, no exception is thrown and no action is performed.

areFlavorListenersRegisteredback to summary
public boolean areFlavorListenersRegistered()
checkChangeback to summary
protected final void checkChange(final long[] formats)

Checks change of the DataFlavors and, if necessary, posts notifications on FlavorEvents to the EDT's. The parameter formats is null iff we have just failed to get formats available on the clipboard.

Parameters
formats:long[]

data formats that have just been retrieved from this clipboard

clearNativeContextback to summary
protected abstract void clearNativeContext()
closeClipboardback to summary
public void closeClipboard()
createLocaleTransferableback to summary
protected Transferable createLocaleTransferable(long[] formats) throws IOException

The clipboard must be opened.

Since
1.5
formatArrayAsDataFlavorSetback to summary
private static Set<DataFlavor> formatArrayAsDataFlavorSet(long[] formats)
getAvailableDataFlavorsback to summary
public DataFlavor[] getAvailableDataFlavors()

Overrides java.awt.datatransfer.Clipboard.getAvailableDataFlavors.

Doc from java.awt.datatransfer.Clipboard.getAvailableDataFlavors.

Returns an array of DataFlavors in which the current contents of this clipboard can be provided. If there are no DataFlavors available, this method returns a zero-length array.

Since
1.5
See Also
java.awt.datatransfer.Clipboard#getAvailableDataFlavors
getClipboardDataback to summary
protected abstract byte[] getClipboardData(long format) throws IOException
getClipboardFormatsback to summary
protected abstract long[] getClipboardFormats()

Returns zero-length array (not null) if the number of available formats is zero.

Exceptions
IllegalStateException:
if formats could not be retrieved
getClipboardFormatsOpenCloseback to summary
protected long[] getClipboardFormatsOpenClose()
Since
1.5
getContentsback to summary
public synchronized Transferable getContents(Object requestor)

Overrides java.awt.datatransfer.Clipboard.getContents.

Doc from java.awt.datatransfer.Clipboard.getContents.

Returns a transferable object representing the current contents of the clipboard. If the clipboard currently has no contents, it returns null. The parameter Object requestor is not currently used. The method throws IllegalStateException if the clipboard is currently unavailable. For example, on some platforms, the system clipboard is unavailable while it is accessed by another application.

getContextContentsback to summary
protected synchronized Transferable getContextContents()
Returns:Transferable

the contents of this clipboard if it has been set or null otherwise

Since
1.5
getDataback to summary
public Object getData(DataFlavor flavor) throws UnsupportedFlavorException, IOException

Overrides java.awt.datatransfer.Clipboard.getData.

Doc from java.awt.datatransfer.Clipboard.getData.

Returns an object representing the current contents of this clipboard in the specified DataFlavor. The class of the object returned is defined by the representation class of flavor.

Exceptions
UnsupportedFlavorException:
if the requested DataFlavor is not available
IOException:
if the data in the requested DataFlavor can not be retrieved
Since
1.5
See Also
java.awt.datatransfer.Clipboard#getData
getDefaultFlavorTableback to summary
public static FlavorTable getDefaultFlavorTable()
getFlavorListenersback to summary
public synchronized FlavorListener[] getFlavorListeners()

Overrides java.awt.datatransfer.Clipboard.getFlavorListeners.

Doc from java.awt.datatransfer.Clipboard.getFlavorListeners.

Returns an array of all the FlavorListeners currently registered on this Clipboard.

getIDback to summary
public abstract long getID()
isDataFlavorAvailableback to summary
public boolean isDataFlavorAvailable(DataFlavor flavor)

Overrides java.awt.datatransfer.Clipboard.isDataFlavorAvailable.

Doc from java.awt.datatransfer.Clipboard.isDataFlavorAvailable.

Returns whether or not the current contents of this clipboard can be provided in the specified DataFlavor.

Since
1.5
See Also
java.awt.datatransfer.Clipboard#isDataFlavorAvailable
lostOwnershipImplback to summary
protected void lostOwnershipImpl()
lostOwnershipLaterback to summary
protected void lostOwnershipLater()

Clears the clipboard state (contents, owner and contents context) and notifies the current owner that ownership is lost. Does nothing if the argument is not null and is not equal to the current contents context.

lostOwnershipNowback to summary
protected void lostOwnershipNow()
openClipboardback to summary
public void openClipboard(SunClipboard newOwner)
Exceptions
IllegalStateException:
if the clipboard has not been opened
registerClipboardViewerCheckedback to summary
protected abstract void registerClipboardViewerChecked()
removeFlavorListenerback to summary
public synchronized void removeFlavorListener(FlavorListener listener)

Overrides java.awt.datatransfer.Clipboard.removeFlavorListener.

Doc from java.awt.datatransfer.Clipboard.removeFlavorListener.

Removes the specified FlavorListener so that it no longer receives FlavorEvents from this Clipboard. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this Clipboard. If listener is null, no exception is thrown and no action is performed.

setContentsback to summary
public synchronized void setContents(Transferable contents, ClipboardOwner owner)

Overrides java.awt.datatransfer.Clipboard.setContents.

Doc from java.awt.datatransfer.Clipboard.setContents.

Sets the current contents of the clipboard to the specified transferable object and registers the specified clipboard owner as the owner of the new contents.

If there is an existing owner different from the argument owner, that owner is notified that it no longer holds ownership of the clipboard contents via an invocation of ClipboardOwner.lostOwnership() on that owner. An implementation of setContents() is free not to invoke lostOwnership() directly from this method. For example, lostOwnership() may be invoked later on a different thread. The same applies to FlavorListeners registered on this clipboard.

The method throws IllegalStateException if the clipboard is currently unavailable. For example, on some platforms, the system clipboard is unavailable while it is accessed by another application.

setContentsNativeback to summary
protected abstract void setContentsNative(Transferable contents)
unregisterClipboardViewerCheckedback to summary
protected abstract void unregisterClipboardViewerChecked()