Class AdapterUtil

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

public class AdapterUtil extends Object
Utilities for using adapters, particularly against selections.
  • Constructor Details

    • AdapterUtil

      public AdapterUtil()
  • Method Details

    • getAdaptableTypes

      public static String[] getAdaptableTypes(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, 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 Object convert(Object obj, 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