Top Description Constructors Methods
org.eclipse.swt.dnd

public abstract Class Transfer

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.swt.dnd.ByteArrayTransfer
Imports
org.eclipse.swt.internal.*, org.eclipse.swt.internal.gtk.*

Transfer provides a mechanism for converting between a java representation of data and a platform specific representation of data and vice versa. It is used in data transfer operations such as drag and drop and clipboard copy/paste.

You should only need to become familiar with this class if you are implementing a Transfer subclass and you are unable to subclass the ByteArrayTransfer class.

See Also
ByteArrayTransfer, Drag and Drop snippets, SWT Example: DNDExample, Sample code and further information

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract TransferData[]

Returns:

a list of the data types that can be converted using this transfer agent
getSupportedTypes
()

Returns a list of the platform specific data types that can be converted using this transfer agent.

protected abstract int[]

Returns:

the platform specific ids of the data types that can be converted using this transfer agent
getTypeIds
()

Returns the platform specific ids of the data types that can be converted using this transfer agent.

protected abstract String[]

Returns:

the platform specific names of the data types that can be converted using this transfer agent.
getTypeNames
()

Returns the platform specific names of the data types that can be converted using this transfer agent.

public abstract boolean

Returns:

true if the transferData data type can be converted using this transfer agent
isSupportedType
(TransferData
a platform specific description of a data type; only the data type fields of the TransferData object need to be filled in
transferData
)

Returns true if the TransferData data type can be converted using this transfer agent, or false otherwise (including if transferData is null).

protected abstract void
javaToNative(Object
a java representation of the data to be converted; the type of Object that is passed in is dependent on the Transfer subclass.
object
,
TransferData
an empty TransferData object; this object will be filled in on return with the platform specific representation of the data
transferData
)

Converts a java representation of data to a platform specific representation of the data.

protected abstract Object

Returns:

a java representation of the converted data if the conversion was successful; otherwise null. If transferData is null then null is returned. The type of Object that is returned is dependent on the Transfer subclass.
nativeToJava
(TransferData
the platform specific representation of the data to be converted
transferData
)

Converts a platform specific representation of data to a java representation.

public static int

Returns:

the unique identifier associated with this data type
registerType
(String
the name of a data type
formatName
)

Registers a name for a data type and returns the associated unique identifier.

protected boolean

Returns:

true if object is of the correct form for this transfer type
validate
(Object
a java representation of the data to be converted
object
)

Test that the object is of the correct format for this Transfer class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Transferback to summary
public Transfer()

Method Detail

getSupportedTypesback to summary
public abstract TransferData[] getSupportedTypes()

Returns a list of the platform specific data types that can be converted using this transfer agent.

Only the data type fields of the TransferData objects are filled in.

Returns:TransferData[]

a list of the data types that can be converted using this transfer agent

getTypeIdsback to summary
protected abstract int[] getTypeIds()

Returns the platform specific ids of the data types that can be converted using this transfer agent.

Returns:int[]

the platform specific ids of the data types that can be converted using this transfer agent

getTypeNamesback to summary
protected abstract String[] getTypeNames()

Returns the platform specific names of the data types that can be converted using this transfer agent.

Returns:String[]

the platform specific names of the data types that can be converted using this transfer agent.

isSupportedTypeback to summary
public abstract boolean isSupportedType(TransferData transferData)

Returns true if the TransferData data type can be converted using this transfer agent, or false otherwise (including if transferData is null).

Parameters
transferData:TransferData

a platform specific description of a data type; only the data type fields of the TransferData object need to be filled in

Returns:boolean

true if the transferData data type can be converted using this transfer agent

javaToNativeback to summary
protected abstract void javaToNative(Object object, TransferData transferData)

Converts a java representation of data to a platform specific representation of the data.

On a successful conversion, the transferData.result field will be set as follows:

  • Windows: COM.S_OK
  • GTK: 1

If this transfer agent is unable to perform the conversion, the transferData.result field will be set to a failure value as follows:

  • Windows: COM.DV_E_TYMED or COM.E_FAIL
  • GTK: 0
Parameters
object:Object

a java representation of the data to be converted; the type of Object that is passed in is dependent on the Transfer subclass.

transferData:TransferData

an empty TransferData object; this object will be filled in on return with the platform specific representation of the data

Exceptions
SWTException:
  • ERROR_INVALID_DATA - if object does not contain data in a valid format or is null
nativeToJavaback to summary
protected abstract Object nativeToJava(TransferData transferData)

Converts a platform specific representation of data to a java representation.

Parameters
transferData:TransferData

the platform specific representation of the data to be converted

Returns:Object

a java representation of the converted data if the conversion was successful; otherwise null. If transferData is null then null is returned. The type of Object that is returned is dependent on the Transfer subclass.

registerTypeback to summary
public static int registerType(String formatName)

Registers a name for a data type and returns the associated unique identifier.

You may register the same type more than once, the same unique identifier will be returned if the type has been previously registered.

Note

On windows, do not call this method with pre-defined Clipboard Format types such as CF_TEXT or CF_BITMAP because the pre-defined identifier will not be returned

Parameters
formatName:String

the name of a data type

Returns:int

the unique identifier associated with this data type

validateback to summary
protected boolean validate(Object object)

Test that the object is of the correct format for this Transfer class.

Parameters
object:Object

a java representation of the data to be converted

Returns:boolean

true if object is of the correct form for this transfer type

Since
3.1