org.csstudio.ui.util
Class AdapterUtil

java.lang.Object
  extended by org.csstudio.ui.util.AdapterUtil

public class AdapterUtil
extends java.lang.Object

Utilities for using adapters, particularly against selections.

Author:
Gabriele Carcassi, Kay Kasemir

Constructor Summary
AdapterUtil()
           
 
Method Summary
static
<T> T[]
convert(ISelection selection, java.lang.Class<T> clazz)
          Returns the current selection converted to an array of the desired type, or to an empty array if not possible.
static java.lang.Object convert(java.lang.Object obj, java.lang.String targetClass)
          Adapts an object to the desired type.
static java.lang.String[] getAdaptableTypes(java.lang.Class<?> clazz)
          Returns all class names that an object of that class can be converted to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdapterUtil

public AdapterUtil()
Method Detail

getAdaptableTypes

public static java.lang.String[] getAdaptableTypes(java.lang.Class<?> clazz)
Returns all class names that an object of that class can be converted to.

Parameters:
clazz - a class
Returns:
all the class names with registered adapterFactories

convert

public static <T> T[] convert(ISelection selection,
                              java.lang.Class<T> clazz)
Returns the current selection converted to an array of the desired type, or to an empty array if not possible.

Type Parameters:
T - requested type
Parameters:
selection - a selection
clazz - the desired type
Returns:
an array of the desired type

convert

public static java.lang.Object convert(java.lang.Object obj,
                                       java.lang.String targetClass)
Adapts an object to the desired type. This method, on top of the standard adapter facility, adds support for arrays. If any of the arguments represents an array, it will use object to object adaptation to create it.

Parameters:
obj - Object to adapt
targetClass - Desired class name
Returns:
Object that matches the targetClass or null