public abstract class

SunClipboard

extends Clipboard
implements PropertyChangeListener
java.lang.Object
   ↳ java.awt.datatransfer.Clipboard
     ↳ sun.awt.datatransfer.SunClipboard

Class Overview

Serves as a common, helper superclass for the Win32 and X11 system Clipboards.

Summary

Fields
public static final FlavorTable flavorMap
[Expand]
Inherited Fields
From class java.awt.datatransfer.Clipboard
Public Constructors
SunClipboard(String name)
Public Methods
synchronized void addFlavorListener(FlavorListener listener)
Registers the specified FlavorListener to receive FlavorEvents from this clipboard.
boolean areFlavorListenersRegistered()
void checkChange(long[] formats)
Checks change of the DataFlavors and, if necessary, posts notifications on FlavorEvents to the AppContexts' EDTs.
void closeClipboard()
DataFlavor[] getAvailableDataFlavors()
Returns an array of DataFlavors in which the current contents of this clipboard can be provided.
synchronized Transferable getContents(Object requestor)
Returns a transferable object representing the current contents of the clipboard.
Object getData(DataFlavor flavor)
Returns an object representing the current contents of this clipboard in the specified DataFlavor.
synchronized FlavorListener[] getFlavorListeners()
Returns an array of all the FlavorListeners currently registered on this Clipboard.
abstract long getID()
boolean isDataFlavorAvailable(DataFlavor flavor)
Returns whether or not the current contents of this clipboard can be provided in the specified DataFlavor.
void openClipboard(SunClipboard newOwner)
void propertyChange(PropertyChangeEvent evt)
This method gets called when a bound property is changed.
synchronized void removeFlavorListener(FlavorListener listener)
Removes the specified FlavorListener so that it no longer receives FlavorEvents from this Clipboard.
synchronized void setContents(Transferable contents, ClipboardOwner owner)
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 Methods
abstract void clearNativeContext()
Transferable createLocaleTransferable(long[] formats)
The clipboard must be opened.
abstract byte[] getClipboardData(long format)
abstract long[] getClipboardFormats()
Returns zero-length array (not null) if the number of available formats is zero.
long[] getClipboardFormatsOpenClose()
void lostOwnershipImpl()
void lostOwnershipLater(AppContext disposedContext)
Clears the clipboard state (contents, owner and contents context) and notifies the current owner that ownership is lost.
abstract void registerClipboardViewerChecked()
abstract void setContentsNative(Transferable contents)
abstract void unregisterClipboardViewerChecked()
[Expand]
Inherited Methods
From class java.awt.datatransfer.Clipboard
From class java.lang.Object
From interface java.beans.PropertyChangeListener

Fields

public static final FlavorTable flavorMap

Public Constructors

public SunClipboard (String name)

Public Methods

public synchronized void addFlavorListener (FlavorListener listener)

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

Parameters
listener the listener to be added

public boolean areFlavorListenersRegistered ()

public void checkChange (long[] formats)

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

Parameters
formats data formats that have just been retrieved from this clipboard

public void closeClipboard ()

public DataFlavor[] 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.

Returns
  • an array of DataFlavors in which the current contents of this clipboard can be provided
See Also
  • java.awt.Clipboard#getAvailableDataFlavors

public synchronized Transferable getContents (Object requestor)

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.

Parameters
requestor the object requesting the clip data (not used)
Returns
  • the current transferable object on the clipboard

public Object getData (DataFlavor flavor)

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.

Parameters
flavor the requested DataFlavor for the contents
Returns
  • an object representing the current contents of this clipboard in the specified DataFlavor
See Also
  • java.awt.Clipboard#getData

public synchronized FlavorListener[] getFlavorListeners ()

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

Returns
  • all of this clipboard's FlavorListeners or an empty array if no listeners are currently registered

public abstract long getID ()

public boolean isDataFlavorAvailable (DataFlavor flavor)

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

Parameters
flavor the requested DataFlavor for the contents
Returns
  • true if the current contents of this clipboard can be provided in the specified DataFlavor; false otherwise
See Also
  • java.awt.Clipboard#isDataFlavorAvailable

public void openClipboard (SunClipboard newOwner)

Throws
IllegalStateException if the clipboard has not been opened

public void propertyChange (PropertyChangeEvent evt)

This method gets called when a bound property is changed.

Parameters
evt A PropertyChangeEvent object describing the event source and the property that has changed.

public synchronized void removeFlavorListener (FlavorListener listener)

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.

Parameters
listener the listener to be removed

public synchronized void setContents (Transferable contents, ClipboardOwner owner)

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.

Parameters
contents the transferable object representing the clipboard content
owner the object which owns the clipboard content

Protected Methods

protected abstract void clearNativeContext ()

protected Transferable createLocaleTransferable (long[] formats)

The clipboard must be opened.

Throws
IOException

protected abstract byte[] getClipboardData (long format)

Throws
IOException

protected abstract long[] getClipboardFormats ()

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

Throws
IllegalStateException if formats could not be retrieved

protected long[] getClipboardFormatsOpenClose ()

protected void lostOwnershipImpl ()

protected void lostOwnershipLater (AppContext disposedContext)

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.

Parameters
disposedContext the AppContext that is disposed or null if the ownership is lost because another application acquired ownership.

protected abstract void registerClipboardViewerChecked ()

protected abstract void setContentsNative (Transferable contents)

protected abstract void unregisterClipboardViewerChecked ()