Abstract Interface Transferable in Java

0
48
digitization, transformation, binary
Spread the love

Abstract Interface Transferable in Java

The transferable interface defines the methods that a class must define if it is to act as the source object in a data transfer operation. getTransferDataFlavors() should return an array of DataFlavor objects that specify the data types or formats in which the object can provide its data.

The DataFlavor objects should be ordered from the best format (most richly descriptive) to the worst format. isDataFlavorSupported() must return a boolean value indicating whether it can transfer data using a specified DataFlavor.

Finally, getTransferData() must return an object that represents the data formatted as required by the specified DataFlavor. StringSelection is a pre-defined class that implements the Transferable interface for the transfer of string data.

In short, the Transferable interface is implemented by objects that can be placed on Clipboards.

The structure of interface Transferable is given as

public abstract interface Transferable {
// Public Instance Methods
public abstract Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException;
public abstract DataFlavor[] getTransferDataFlavors();
public abstract boolean isDataFlavorSupported(DataFlavor flavor);
}

The details of the class structure are given as follows:

public abstract Object getTransferData (DataFlavor flavor);

public abstract Object getTransferData (DataFlavor flavor) method returns the data this Transferable object represents. The class of object returned depends on the flavor requested.

This method returns the data represented by this Transferable object, in the requested flavor

Parameter
flavor – The requested flavor for the returned data.

public abstract DataFlavor[] getTransferDataFlavors();

public abstract DataFlavor[] getTransferDataFlavors() method returns the data flavors, sorted from most to least descriptive.

READ  Class Long in Java

This method returns an array of supported data flavors.

public abstract boolean isDataFlavorSupported (DataFlavor flavor);

public abstract boolean isDataFlavorSupported (DataFlavor flavor) method returns true if flavor is supported; false otherwise.

This method returns true if the flavor is supported; false otherwise.

Parameter
flavor – The flavor in question.


Spread the love
I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on ani01104@gamil.com

LEAVE A REPLY

Please enter your comment!
Please enter your name here