javax.swing.plaf.basic
Class BasicTextUI.TextTransferHandler.TextTransferable

java.lang.Object
  extended byjavax.swing.plaf.basic.BasicTransferable
      extended byjavax.swing.plaf.basic.BasicTextUI.TextTransferHandler.TextTransferable
All Implemented Interfaces:
Transferable, UIResource
Enclosing class:
BasicTextUI.TextTransferHandler

static class BasicTextUI.TextTransferHandler.TextTransferable
extends BasicTransferable

A possible implementation of the Transferable interface for text components. For a JEditorPane with a rich set of EditorKit implementations, conversions could be made giving a wider set of formats. This is implemented to offer up only the active content type and text/plain (if that is not the active format) since that can be extracted from other formats.


Field Summary
(package private)  JTextComponent c
           
protected  String htmlData
           
(package private)  String mimeType
           
(package private)  Position p0
           
(package private)  Position p1
           
protected  String plainData
           
(package private)  String richText
           
 
Constructor Summary
(package private) BasicTextUI.TextTransferHandler.TextTransferable(JTextComponent c, int start, int end)
           
 
Method Summary
protected  String getHTMLData()
          Fetch the data in a text/html format
protected  String getPlainData()
          Fetch the data in a text/plain format.
protected  Object getRicherData(DataFlavor flavor)
          The only richer format supported is the file list flavor
protected  DataFlavor[] getRicherFlavors()
          If the EditorKit is not for text/plain or text/html, that format is supported through the "richer flavors" part of BasicTransferable.
 Object getTransferData(DataFlavor flavor)
          Returns an object which represents the data to be transferred.
 DataFlavor[] getTransferDataFlavors()
          Returns an array of DataFlavor objects indicating the flavors the data can be provided in.
 boolean isDataFlavorSupported(DataFlavor flavor)
          Returns whether or not the specified data flavor is supported for this object.
protected  boolean isHTMLFlavor(DataFlavor flavor)
          Returns whether or not the specified data flavor is an HTML flavor that is supported.
protected  boolean isHTMLSupported()
          Should the HTML flavors be offered?
protected  boolean isPlainFlavor(DataFlavor flavor)
          Returns whether or not the specified data flavor is an plain flavor that is supported.
protected  boolean isPlainSupported()
          Should the plain text flavors be offered?
protected  boolean isRicherFlavor(DataFlavor flavor)
           
protected  boolean isStringFlavor(DataFlavor flavor)
          Returns whether or not the specified data flavor is a String flavor that is supported.
(package private)  void removeText()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

p0

Position p0

p1

Position p1

mimeType

String mimeType

richText

String richText

c

JTextComponent c

plainData

protected String plainData

htmlData

protected String htmlData
Constructor Detail

BasicTextUI.TextTransferHandler.TextTransferable

BasicTextUI.TextTransferHandler.TextTransferable(JTextComponent c,
                                                 int start,
                                                 int end)
Method Detail

removeText

void removeText()

getRicherFlavors

protected DataFlavor[] getRicherFlavors()
If the EditorKit is not for text/plain or text/html, that format is supported through the "richer flavors" part of BasicTransferable.

Overrides:
getRicherFlavors in class BasicTransferable

getRicherData

protected Object getRicherData(DataFlavor flavor)
                        throws UnsupportedFlavorException
The only richer format supported is the file list flavor

Overrides:
getRicherData in class BasicTransferable
Throws:
UnsupportedFlavorException

getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be ordered according to preference for providing the data (from most richly descriptive to least descriptive).

Specified by:
getTransferDataFlavors in interface Transferable
Returns:
an array of data flavors in which this data can be transferred

isDataFlavorSupported

public boolean isDataFlavorSupported(DataFlavor flavor)
Returns whether or not the specified data flavor is supported for this object.

Specified by:
isDataFlavorSupported in interface Transferable
Parameters:
flavor - the requested flavor for the data
Returns:
boolean indicating whether or not the data flavor is supported

getTransferData

public Object getTransferData(DataFlavor flavor)
                       throws UnsupportedFlavorException,
                              IOException
Returns an object which represents the data to be transferred. The class of the object returned is defined by the representation class of the flavor.

Specified by:
getTransferData in interface Transferable
Parameters:
flavor - the requested flavor for the data
Throws:
IOException - if the data is no longer available in the requested flavor.
UnsupportedFlavorException - if the requested data flavor is not supported.
See Also:
DataFlavor.getRepresentationClass()

isRicherFlavor

protected boolean isRicherFlavor(DataFlavor flavor)

isHTMLFlavor

protected boolean isHTMLFlavor(DataFlavor flavor)
Returns whether or not the specified data flavor is an HTML flavor that is supported.

Parameters:
flavor - the requested flavor for the data
Returns:
boolean indicating whether or not the data flavor is supported

isHTMLSupported

protected boolean isHTMLSupported()
Should the HTML flavors be offered? If so, the method getHTMLData should be implemented to provide something reasonable.


getHTMLData

protected String getHTMLData()
Fetch the data in a text/html format


isPlainFlavor

protected boolean isPlainFlavor(DataFlavor flavor)
Returns whether or not the specified data flavor is an plain flavor that is supported.

Parameters:
flavor - the requested flavor for the data
Returns:
boolean indicating whether or not the data flavor is supported

isPlainSupported

protected boolean isPlainSupported()
Should the plain text flavors be offered? If so, the method getPlainData should be implemented to provide something reasonable.


getPlainData

protected String getPlainData()
Fetch the data in a text/plain format.


isStringFlavor

protected boolean isStringFlavor(DataFlavor flavor)
Returns whether or not the specified data flavor is a String flavor that is supported.

Parameters:
flavor - the requested flavor for the data
Returns:
boolean indicating whether or not the data flavor is supported