org.eclipse.actf.core.adapt
Interface IAdaptor

All Known Implementing Classes:
AccessibilityAdaptor, IA2AccessibilityAdaptor, MozillaDomAccessibilityAdaptor, MsaaAccessibilityAdaptor, SwingAccessibilityAdaptor, SwtAccessibilityAdaptor

public interface IAdaptor

provides a way to transform or "morph" objects of one type to another type. The simplest form of adaptation is a simple cast, which, of course, could be done without this interface. More interesting uses of this interface provide a way to capture a subset of properties of the adaptable object or to convertthe an adaptable object to a class that is similar to the original class of the object but has a different public interface (e.g. the java.io.File class and org.eclipse.core.runtime.IPath interface).

Author:
Mike Squillace

Method Summary
 Object adapt(Object o, Class newType)
          adapts the object to the given type.
 Class[] getSupportedTypes()
          returns the types to which given objects may be adapted by this adaptor.
 

Method Detail

getSupportedTypes

Class[] getSupportedTypes()
returns the types to which given objects may be adapted by this adaptor. One of these types should be used when calling the adapt method.

Returns:
list of types to which objects can be adapted by this adaptor
See Also:
adapt(Object, Class)

adapt

Object adapt(Object o,
             Class newType)
             throws Exception
adapts the object to the given type. This method is responsible for casting or transforming or somehow producing an object of the specified type that represents a set of properties of or directly corresponds to the specified object. The type to which the object is to be adapted should be one of those returned by getSupportedTypes.

All attempts should be made to insure that this method is symmetric. That is, if object o is of type B, then:

 adapt(adapt(o, A.class), B.class) = o
 

Also note that both types A and B should be returned by getSupportedTypes.

Parameters:
o - - object to be adapted
newType - - the type to which the object is to be adapted
Returns:
an instance of the specified type or null if the object could not be adapted to the given type
Throws:
Exception
See Also:
getSupportedTypes()