Class ScriptableActionLoader


  • public class ScriptableActionLoader
    extends java.lang.Object
    Given the name of a script action, this class searches a number of locations for a class to load with that name and returns a new instance of that class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Vector<java.lang.String> SCRIPT_ACTION_LOCATIONS
      Try MIPAV dialogs, then special script actions, then plugins (which are in the default package).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addScriptActionLocation​(java.lang.String packageString)
      Adds a new package where we should look for scriptable actions.
      protected static java.lang.Class attemptLoadFromPackage​(java.lang.String packageString, java.lang.String action)
      Trys to load a action's class, searching in a specific package.
      static ScriptableActionInterface getScriptableAction​(java.lang.String action)
      Returns a new instance of the class associated with a given script action.
      static java.util.Vector<java.lang.String> getScriptActionLocations()
      Gets the script action location vector, needed for figuring out the possible short name of a non-MIPAV scriptable tool.
      protected static java.lang.Class loadClass​(java.lang.String action)
      Trys to find and load an action's corresponding class from a list of package prefixes.
      • Methods inherited from class java.lang.Object

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

      • SCRIPT_ACTION_LOCATIONS

        private static java.util.Vector<java.lang.String> SCRIPT_ACTION_LOCATIONS
        Try MIPAV dialogs, then special script actions, then plugins (which are in the default package).
    • Constructor Detail

      • ScriptableActionLoader

        public ScriptableActionLoader()
    • Method Detail

      • getScriptableAction

        public static final ScriptableActionInterface getScriptableAction​(java.lang.String action)
                                                                   throws ParserException
        Returns a new instance of the class associated with a given script action.
        Parameters:
        action - The action to search for a class of.
        Returns:
        A new instance of a script action's class.
        Throws:
        ParserException - If an associated class was not found or could not be loaded.
      • attemptLoadFromPackage

        protected static java.lang.Class attemptLoadFromPackage​(java.lang.String packageString,
                                                                java.lang.String action)
                                                         throws ParserException
        Trys to load a action's class, searching in a specific package.
        Parameters:
        packageString - The prefix to append to the action before trying to load it (may be a package, a package and a class name prefix, or empty for the default package).
        action - The script action to search for.
        Returns:
        The action's corresponding class, from the given package prefix.
        Throws:
        ParserException - If the action's class could not be found or loaded from the given package prefix.
      • loadClass

        protected static java.lang.Class loadClass​(java.lang.String action)
                                            throws ParserException
        Trys to find and load an action's corresponding class from a list of package prefixes. The first place where a suitable class is found is the one returned.
        Parameters:
        action - The script action to search for.
        Returns:
        The action's corresponding class, found using one of the package prefixes.
        Throws:
        ParserException - If the action's class could not be found or loaded from any of the script action locations.
      • addScriptActionLocation

        public static void addScriptActionLocation​(java.lang.String packageString)
        Adds a new package where we should look for scriptable actions. To be used to register the package paths used by more complex plugins (probably called from the plugin run() method).
        Parameters:
        packageString - The java package in which to look for scriptable actions.
      • getScriptActionLocations

        public static java.util.Vector<java.lang.String> getScriptActionLocations()
        Gets the script action location vector, needed for figuring out the possible short name of a non-MIPAV scriptable tool.