net.refractions.udig.ui
Class AbstractStrategizedTransfer

java.lang.Object
  extended by ByteArrayTransfer
      extended by net.refractions.udig.ui.AbstractStrategizedTransfer
Direct Known Subclasses:
AbstractTextStrategizedTransfer

public abstract class AbstractStrategizedTransfer
extends ByteArrayTransfer

This class provides the framework for a transfer to have different behaviours depending on the strategy that is set.

For example:

A GeometryTextTransfer can encode the geometry as a GML string or a WKT string (as created by JTS WKTWriter). The GeometryTextTransfer class subclasses AbstractStrategizedTransfer and only needs to provide the current strategy and the set of possible strategies. The AbstractStrategizedTransfer will first try to use the current strategy for encoding the geometry then all the rest if the current strategy fails. Similarly for decoding an input(nativeToJava) the current strategy will be tried first then the rest of the known strategies will be used until an object is obtained.

Author:
jeichar
See Also:
net.refractions.udig.internal.ui.TransferStrategy

Constructor Summary
AbstractStrategizedTransfer()
           
 
Method Summary
 void addStrategy(TransferStrategy newStrategy)
          Adds a new strategy the list of known strategies.
abstract  TransferStrategy[] getAllStrategies()
          This method is only called once during construction to get the list of strategies known by the implementation.
 TransferStrategy getCurrentStrategy()
          Returns the current strategy as indicated by the pereferences
abstract  TransferStrategy getDefaultStrategy()
          Returns the default strategy that is used to encode the java objects.
abstract  java.lang.String[] getStrategyNames()
          Returns the names for the strategies returned by getAllStrategies().
abstract  java.lang.String getTransferName()
          Returns a name for the Transfer.
 void javaToNative(java.lang.Object object, TransferData transferData)
           
 java.lang.Object nativeToJava(TransferData transferData)
           
abstract  boolean validate(java.lang.Object object)
          Returns true if the transfer can transfer to and from the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractStrategizedTransfer

public AbstractStrategizedTransfer()
Method Detail

javaToNative

public void javaToNative(java.lang.Object object,
                         TransferData transferData)

nativeToJava

public java.lang.Object nativeToJava(TransferData transferData)

getCurrentStrategy

public TransferStrategy getCurrentStrategy()
Returns the current strategy as indicated by the pereferences

Returns:
the current strategy as indicated by the pereferences

getDefaultStrategy

public abstract TransferStrategy getDefaultStrategy()
Returns the default strategy that is used to encode the java objects.

Returns:
the strategy to use for encoding the java object.

getAllStrategies

public abstract TransferStrategy[] getAllStrategies()
This method is only called once during construction to get the list of strategies known by the implementation.

Returns:

getStrategyNames

public abstract java.lang.String[] getStrategyNames()
Returns the names for the strategies returned by getAllStrategies(). The ith name must correspond to the ith strategy.

Returns:
the names for the strategies returned by getAllStrategies()

validate

public abstract boolean validate(java.lang.Object object)
Returns true if the transfer can transfer to and from the object.

Returns:
true if the transfer can transfer to and from the object.

addStrategy

public void addStrategy(TransferStrategy newStrategy)
Adds a new strategy the list of known strategies.


getTransferName

public abstract java.lang.String getTransferName()
Returns a name for the Transfer.

Returns:
name for the Transfer