Class BasicTransferable

  • All Implemented Interfaces:
    java.awt.datatransfer.Transferable, javax.swing.plaf.UIResource

    public class BasicTransferable
    extends java.lang.Object
    implements java.awt.datatransfer.Transferable, javax.swing.plaf.UIResource
    A transferable implementation for the default data transfer of some Swing components.
    Version:
    1.10 11/17/05
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String htmlData  
      private static java.awt.datatransfer.DataFlavor[] htmlFlavors  
      protected java.lang.String plainData  
      private static java.awt.datatransfer.DataFlavor[] plainFlavors  
      private static java.awt.datatransfer.DataFlavor[] stringFlavors  
    • Constructor Summary

      Constructors 
      Constructor Description
      BasicTransferable​(java.lang.String plainData, java.lang.String htmlData)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String getHTMLData()
      Fetch the data in a text/html format
      protected java.lang.String getPlainData()
      Fetch the data in a text/plain format.
      protected java.lang.Object getRicherData​(java.awt.datatransfer.DataFlavor flavor)  
      protected java.awt.datatransfer.DataFlavor[] getRicherFlavors()
      Some subclasses will have flavors that are more descriptive than HTML or plain text.
      java.lang.Object getTransferData​(java.awt.datatransfer.DataFlavor flavor)
      Returns an object which represents the data to be transferred.
      java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
      Returns an array of DataFlavor objects indicating the flavors the data can be provided in.
      boolean isDataFlavorSupported​(java.awt.datatransfer.DataFlavor flavor)
      Returns whether or not the specified data flavor is supported for this object.
      protected boolean isHTMLFlavor​(java.awt.datatransfer.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? If so, the method getHTMLData should be implemented to provide something reasonable.
      protected boolean isPlainFlavor​(java.awt.datatransfer.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? If so, the method getPlainData should be implemented to provide something reasonable.
      protected boolean isRicherFlavor​(java.awt.datatransfer.DataFlavor flavor)  
      protected boolean isStringFlavor​(java.awt.datatransfer.DataFlavor flavor)
      Returns whether or not the specified data flavor is a String flavor that is supported.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • plainData

        protected java.lang.String plainData
      • htmlData

        protected java.lang.String htmlData
      • htmlFlavors

        private static java.awt.datatransfer.DataFlavor[] htmlFlavors
      • stringFlavors

        private static java.awt.datatransfer.DataFlavor[] stringFlavors
      • plainFlavors

        private static java.awt.datatransfer.DataFlavor[] plainFlavors
    • Constructor Detail

      • BasicTransferable

        public BasicTransferable​(java.lang.String plainData,
                                 java.lang.String htmlData)
    • Method Detail

      • getTransferDataFlavors

        public java.awt.datatransfer.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 java.awt.datatransfer.Transferable
        Returns:
        an array of data flavors in which this data can be transferred
      • isDataFlavorSupported

        public boolean isDataFlavorSupported​(java.awt.datatransfer.DataFlavor flavor)
        Returns whether or not the specified data flavor is supported for this object.
        Specified by:
        isDataFlavorSupported in interface java.awt.datatransfer.Transferable
        Parameters:
        flavor - the requested flavor for the data
        Returns:
        boolean indicating whether or not the data flavor is supported
      • getTransferData

        public java.lang.Object getTransferData​(java.awt.datatransfer.DataFlavor flavor)
                                         throws java.awt.datatransfer.UnsupportedFlavorException,
                                                java.io.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 java.awt.datatransfer.Transferable
        Parameters:
        flavor - the requested flavor for the data
        Throws:
        java.io.IOException - if the data is no longer available in the requested flavor.
        java.awt.datatransfer.UnsupportedFlavorException - if the requested data flavor is not supported.
        See Also:
        DataFlavor.getRepresentationClass()
      • isRicherFlavor

        protected boolean isRicherFlavor​(java.awt.datatransfer.DataFlavor flavor)
      • getRicherFlavors

        protected java.awt.datatransfer.DataFlavor[] getRicherFlavors()
        Some subclasses will have flavors that are more descriptive than HTML or plain text. If this method returns a non-null value, it will be placed at the start of the array of supported flavors.
      • getRicherData

        protected java.lang.Object getRicherData​(java.awt.datatransfer.DataFlavor flavor)
                                          throws java.awt.datatransfer.UnsupportedFlavorException
        Throws:
        java.awt.datatransfer.UnsupportedFlavorException
      • isHTMLFlavor

        protected boolean isHTMLFlavor​(java.awt.datatransfer.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 java.lang.String getHTMLData()
        Fetch the data in a text/html format
      • isPlainFlavor

        protected boolean isPlainFlavor​(java.awt.datatransfer.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 java.lang.String getPlainData()
        Fetch the data in a text/plain format.
      • isStringFlavor

        protected boolean isStringFlavor​(java.awt.datatransfer.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