Class Utilities

java.lang.Object
edu.tufts.hrilab.action.util.Utilities

public class Utilities extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    convertToType(Class<?> clazz, Object value)
    Attempt to convert value to specified type.
    static Symbol
    Deprecated.
    static Class<?>
    Attempt to infer argument types in action scripts when values are used directly in scripts without explicitly defining the argument type.
    static Class<?>
    Returns the Class object associated with the class or interface with the given string name.
    static boolean
    isAssignable(Class<?> fromClazz, Class<?> toClazz)
    Checks if a class can be assigned to another class
    static boolean
    Checks if value's toString is a valid boolean value (i.e., "true" or "false").
    static boolean
    isBooleanType(Class<?> clazz)
    Check is Class is a boolean type (primitive or non-primitive).
    static boolean
    isFloat(Object value)
    Checks if value's toString is a float that ends "f" or "F" (e.g., 0.3f, 0.3F).
    static boolean
    Checks if value's toString is an integer with no decimal place.
    static boolean
     
    static boolean
    Checks if a Symbol is an action script local variable
    static boolean
    Checks if a string is an action script local variable
    static boolean
    isLong(Object value)
    Checks if value's toString is a long that ends "l" or "L" (e.g., 3l, or 3L).
    static boolean
    Checks if value's toString is an integer, long, float, or double.
    static boolean
    isNumericType(Class<?> clazz)
    Check is Class is a numeric type (primitive or non-primitive).
    static boolean
    Checks if a Symbol is an action script variable (of type Variable or starts with ! or ?) TODO: all Symbols that start with ! or ? and aren't of type Variable are being constructed incorrectly.
    static boolean
    Checks if a string is an action script variable
    static <T extends Enum<?>>
    T
    strToEnum(Class<T> enumeration, String str)
    Convert string to enum type

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • log

      protected static final org.slf4j.Logger log
  • Constructor Details

    • Utilities

      public Utilities()
  • Method Details

    • getClass

      public static Class<?> getClass(String type)
      Returns the Class object associated with the class or interface with the given string name. This is the same as Class.forName(), but with added support for Java primitives.
      Parameters:
      type -
      Returns:
    • isNumericType

      public static boolean isNumericType(Class<?> clazz)
      Check is Class is a numeric type (primitive or non-primitive).
      Parameters:
      clazz -
      Returns:
    • isBooleanType

      public static boolean isBooleanType(Class<?> clazz)
      Check is Class is a boolean type (primitive or non-primitive).
      Parameters:
      clazz -
      Returns:
    • isNumeric

      public static boolean isNumeric(Object value)
      Checks if value's toString is an integer, long, float, or double.
      Parameters:
      value -
      Returns:
    • isBoolean

      public static boolean isBoolean(Object value)
      Checks if value's toString is a valid boolean value (i.e., "true" or "false").
      Parameters:
      value -
      Returns:
    • isInteger

      public static boolean isInteger(Object value)
      Checks if value's toString is an integer with no decimal place.
      Parameters:
      value -
      Returns:
    • isLong

      public static boolean isLong(Object value)
      Checks if value's toString is a long that ends "l" or "L" (e.g., 3l, or 3L).
      Parameters:
      value -
      Returns:
    • isFloat

      public static boolean isFloat(Object value)
      Checks if value's toString is a float that ends "f" or "F" (e.g., 0.3f, 0.3F).
      Parameters:
      value -
      Returns:
    • isScriptVariable

      public static boolean isScriptVariable(String value)
      Checks if a string is an action script variable
      Parameters:
      value - variable name
      Returns:
      true if string is variable (starts with ? or !)
    • isScriptVariable

      public static boolean isScriptVariable(Symbol value)
      Checks if a Symbol is an action script variable (of type Variable or starts with ! or ?) TODO: all Symbols that start with ! or ? and aren't of type Variable are being constructed incorrectly. those instances should be fixed and this method removed.
      Parameters:
      value - symbol to check
      Returns:
      true if string is variable (starts with ? or !)
    • isLocalVariable

      public static boolean isLocalVariable(Symbol value)
      Checks if a Symbol is an action script local variable
      Parameters:
      value - Symbol
      Returns:
      true if string is local variable (starts with !)
    • isLocalVariable

      public static boolean isLocalVariable(String value)
      Checks if a string is an action script local variable
      Parameters:
      value - variable name
      Returns:
      true if string is local variable (starts with !)
    • isIntegerType

      public static boolean isIntegerType(Class<?> cls)
      Returns:
      true if class if of integer type
    • strToEnum

      public static <T extends Enum<?>> T strToEnum(Class<T> enumeration, String str)
      Convert string to enum type
      Parameters:
      enumeration - enum
      str - string to convert to enum type
      Returns:
    • convertToType

      public static Object convertToType(Class<?> clazz, Object value)
      Attempt to convert value to specified type.
      Parameters:
      clazz - a Java class (for the time being at least)
      value -
      Returns:
    • isAssignable

      public static boolean isAssignable(Class<?> fromClazz, Class<?> toClazz)
      Checks if a class can be assigned to another class
      Parameters:
      fromClazz -
      toClazz -
      Returns:
      true if clazz can be assigned to toClazz
    • getArgumentType

      public static Class<?> getArgumentType(String value)
      Attempt to infer argument types in action scripts when values are used directly in scripts without explicitly defining the argument type.
      Parameters:
      value -
      Returns:
    • createFOL

      @Deprecated public static Symbol createFOL(ActionBinding input)
      Deprecated.
      Create FOL instance from an ActionBinding's underlying value. Will return null if the ActionBinding's value is null. TODO: this functionality should probably be moved convertToType
      Parameters:
      input -
      Returns: