org.eclipse.emf.edit.ui.dnd
Class LocalTransfer

java.lang.Object
  extended byorg.eclipse.swt.dnd.Transfer
      extended byorg.eclipse.swt.dnd.ByteArrayTransfer
          extended byorg.eclipse.emf.edit.ui.dnd.LocalTransfer

public class LocalTransfer
extends ByteArrayTransfer

This derived implementation of a byte array transfer short circuits the transfer process so that a local transfer does not serialize the object and hence can and will return the original object, not just a clone. You only really need ever know about LocalTransfer.getInstance(), so that you can include it in when adding drag support to a viewer. See EditingDomainViewerDropAdapter and ViewerDragAdapter for more details.

As an addded guard, the time is recorded and serialized in javaToNative to that navive to java can ensure that it's returns the value that was really to have been transferred.


Field Summary
protected static LocalTransfer instance
          This is initialized and returned by getInstance().
protected  Object object
          This records the data being transferred.
protected  long startTime
          This records the time at which the transfer data was recorded.
protected static int TYPE_ID
          This is the ID that is registered to the name.
protected static String TYPE_NAME
          This is the register transfer type name.
 
Constructor Summary
protected LocalTransfer()
          This creates an instance; typically you get one from getInstance().
 
Method Summary
static LocalTransfer getInstance()
          This returns the one instance of this transfer agent.
protected  int[] getTypeIds()
          This returns the transfer ids that this agent supports.
 String[] getTypeNames()
          This returns the transfer names that this agent supports.
 void javaToNative(Object object, TransferData transferData)
          This records the object and current time and encodes only the current time into the transfer data.
 Object nativeToJava(TransferData transferData)
          This decodes the time of the transfer and returns the recorded the object if the recorded time and the decoded time match.
 
Methods inherited from class org.eclipse.swt.dnd.ByteArrayTransfer
getSupportedTypes, isSupportedType
 
Methods inherited from class org.eclipse.swt.dnd.Transfer
registerType, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_NAME

protected static final String TYPE_NAME
This is the register transfer type name.

See Also:
Constant Field Values

TYPE_ID

protected static final int TYPE_ID
This is the ID that is registered to the name.


instance

protected static LocalTransfer instance
This is initialized and returned by getInstance().


startTime

protected long startTime
This records the time at which the transfer data was recorded.


object

protected Object object
This records the data being transferred.

Constructor Detail

LocalTransfer

protected LocalTransfer()
This creates an instance; typically you get one from getInstance().

Method Detail

getInstance

public static LocalTransfer getInstance()
This returns the one instance of this transfer agent.


getTypeIds

protected int[] getTypeIds()
This returns the transfer ids that this agent supports.


getTypeNames

public String[] getTypeNames()
This returns the transfer names that this agent supports.


javaToNative

public void javaToNative(Object object,
                         TransferData transferData)
This records the object and current time and encodes only the current time into the transfer data.


nativeToJava

public Object nativeToJava(TransferData transferData)
This decodes the time of the transfer and returns the recorded the object if the recorded time and the decoded time match.


Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.