Package adams.flow.core
Class ActorUtils
- java.lang.Object
-
- adams.flow.core.ActorUtils
-
public class ActorUtils extends Object
Helper class for actors.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static String
ENV_INVALID_VARIABLES_LENIENT
the environment variable to enable lenient checking for invalid variables.static String
FLOW_DIR
the variable for the directory the flow is located in.static String
FLOW_FILENAME_LONG
the variable for the full flow filename.static String
FLOW_FILENAME_RESTORE
the variable for the flow restoration filename (long filename, but with .props extension).static String
FLOW_FILENAME_SHORT
the variable for the short flow filename.static String
FLOW_ID
the variable for the flow ID.static String
FLOW_START_TIMESTAMP
the variable for the start timestamp of the flow.static String
FUNCTIONAL_HANDLER
functional type: handler.static String
FUNCTIONAL_PRIMITIVE
functional type: primitive.static String
HAS_GUI
the variable for the gui flag.static String
IS_HEADLESS
the variable for the headless flag.protected static Boolean
m_InvalidVariablesLenient
whether to be lenient with invalid variables.static String
PROCEDURAL_SINK
procedural type: sink.static String
PROCEDURAL_SOURCE
procedural type: source.static String
PROCEDURAL_STANDALONE
procedural type: standalone.static String
PROCEDURAL_TRANSFORMER
procedural type: transformer.static String[]
PROGRAMMATIC_VARIABLES
programmatically set variables.static Map<String,String>
PROGRAMMATIC_VARIABLES_HELP
programmatically set variables.static String
PROJECT_HOME
the variable for the project home.static String
PROJECT_MODULES
the variable for the project modules (comma-separated list).static String
PROJECT_NAME
the variable for the project name.
-
Constructor Summary
Constructors Constructor Description ActorUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
checkFlow(Actor actor, boolean variables, boolean storage, File file)
Checks the flow.static String
checkFlow(Actor actor, File file)
Checks the flow.static boolean
checkForCallableActorUser(Actor actor)
Checks whether a callable actor user is present in this sub-tree.static boolean
checkForExternalActor(Actor actor)
Checks whether an external actor is present in this sub-tree.static String
checkForSource(Actor actor)
Checks whether the actor has a source as first actor (can be nested).static String
checkForSource(Actor[] actors)
Checks whether the actors have a source as first actor (can be nested).protected static boolean
checkInvalidVariablesLenient()
Returns whether invalid variables are to be treated lenient (ie no error, just warning).static Actor
cleanUpFlow(Actor actor)
Cleans up the flow, e.g., removing disabled actors, unused callable actors.static Actor
createExternalActor(Actor[] actors, ActorHandler suggestion)
Ensures that the actors are enclosed in an "instantiable" wrapper.static Point
determineLocation(GraphicsConfiguration gc, Dimension size, int x, int y)
Determines the initial location of the window.static Point
determineLocation(Window window, int x, int y)
Determines the initial location of the window.static int
determineNumActors(Actor flow)
Returns how many actors this flow is made of.static Dimension
determineSize(Window window, int x, int y, int width, int height)
Determines the height of the window.static String
ensureValidVariables(Actor actor)
Ensures that the variables within this actor are valid.static List<Actor>
enumerate(Actor actor)
Enumerates all children of the given actor (depth-first search).static List<Actor>
enumerate(Actor actor, ActorFilter filter)
Enumerates all children of the given actor (depth-first search).static List<Actor>
enumerate(Actor actor, Class[] filter)
Enumerates all children of the given actor (depth-first search).protected static void
enumerate(Actor actor, List<Actor> children, ActorFilter filter)
Enumerates all children of the given actor (depth-first search).static List<String>
extractActorNames(Actor current, String text)
Extracts all the valid actor names from the given text fragment that exist within the specified flow.static List<ActorHandler>
findActorHandlers(Actor actor)
Returns a list of actor handlers, starting from the current note (excluded).static List<ActorHandler>
findActorHandlers(Actor actor, boolean mustAllowStandalones)
Returns a list of actor handlers, starting from the current note (excluded).static List<ActorHandler>
findActorHandlers(Actor actor, boolean mustAllowStandalones, boolean includeSameLevel)
Returns a list of actor handlers, starting from the current note (excluded).static Hashtable<String,Integer>
findCallableTransformers(Actor actor)
Locates callable transformers.protected static Actor
findClosestType(ActorHandler handler, Class type)
Checks an actor handler's children whether they contain the actor type we're looking for.static Actor
findClosestType(Actor actor, Class type)
Tries to find the closest type in the actor tree, starting with the current actor.static Actor
findClosestType(Actor actor, Class type, boolean includeSameLevel)
Tries to find the closest type in the actor tree, starting with the current actor.protected static List<Actor>
findClosestTypes(ActorHandler handler, Class type)
Checks an actor handler's children whether they contain the actor type we're looking for.static List<Actor>
findClosestTypes(Actor actor, Class type)
Tries to find the closest types in the actor tree, starting with the current actor.static List<Actor>
findClosestTypes(Actor actor, Class type, boolean includeSameLevel)
Tries to find the closest types in the actor tree, starting with the current actor.static String
forceVariables(Actor actor, Variables vars)
Forces the update of the variables of this actor.static AbstractDatabaseConnection
getDatabaseConnection(Actor actor, Class cls, AbstractDatabaseConnection defCon)
Returns the database connection object to use.static int
getFlowID(Actor source)
Returns the flow ID (if possible) for the given actor.static String
getFunctionalAspect(Actor actor)
Determines the functional aspect of an actor.static String
getProceduralAspect(Actor actor)
Determines the procedural aspect of an actor.static boolean
isActorHandler(Actor actor)
Checks whether this actor is an actor handler.static boolean
isControlActor(Actor actor)
Checks whether this actor is a control actor.static boolean
isInteractive(Actor actor)
Checks whether the actor or its sub-actors are interactive ones.protected static boolean
isLoggingEnabled()
Returns whether logging is enabled.static boolean
isSink(Actor actor)
Checks whether this actor is a sink (input).static boolean
isSource(Actor actor)
Checks whether this actor is a source (output).static boolean
isStandalone(Actor actor)
Checks whether this actor is a standalone.static boolean
isTransformer(Actor actor)
Checks whether this actor is a transformer (input/output).static Actor
locate(ActorPath path, Actor parent)
Tries to locate the actor specified by the path parts.static Actor
locate(ActorPath path, Actor parent, boolean included, boolean quiet)
Tries to locate the actor specified by the path parts.static Actor
locate(String path, Actor root)
Locates the actor in the actor tree based on the specified path.static Actor
locate(String path, Actor root, boolean included, boolean quiet)
Locates the actor in the actor tree based on the specified path.static BasePassword
promptPassword(Actor context)
Performs the interaction with the user.static BasePassword
promptPassword(Actor context, String labelText)
Performs the interaction with the user.static Actor
read(String filename)
Reads an actor from a file.static Actor
read(String filename, MessageCollection errors)
Reads an actor from a file.static Actor
read(String filename, MessageCollection errors, MessageCollection warnings)
Reads an actor from a file.static Actor
removeDisabledActors(Actor actor)
Removes all disabled actors (recursively) from the actor.static int
replace(OptionHandler handler, Comparable find, Comparable replace, boolean recursive)
Replaces any occurrence of the object to find with the replacement.static int
replace(OptionHandler handler, Comparable find, Comparable replace, boolean recursive, HashSet<Class> excluded)
Replaces any occurrence of the object to find with the replacement.protected static String
setActors(ActorHandler handler, Actor[] actors)
Sets the actors in the handler.static boolean
sort(SortableActorHandler handler, ActorComparator comp)
Sorts the child-actors using the supplied comparator.static Actor
strip(Actor actor)
Returns a stripped down version of the actor, i.e., for ActorHandlers, a copy of the actor without any sub-actors gets returned.static List
transform(Actor transformer, Object input)
Processes the data using the specified transformer.static boolean
uniqueName(Actor actor, ActorHandler handler, int index)
Updates the name of the actor to make it unique among all the other actors of the given handler.static boolean
uniqueName(Actor actor, Set<String> names)
Updates the name of the actor to make it unique among all the other specified names.static boolean
uniqueName(Actor actor, Set<String> names, boolean tailRemoval)
Updates the name of the actor to make it unique among all the other specified names.static boolean
uniqueNames(Actor[] actors)
Updates the names of the actors to make then unique among all of them.static void
updateErrorHandler(Actor actor, ErrorHandler handler, boolean trace)
Updates the error handler.static void
updateFlowAwarePaintlet(Paintlet paintlet, Actor actor)
Updates a "flow-aware" paintlet with the specified actor.static void
updateFlowAwarePaintlets(PaintablePanel panel, Actor actor)
Updates all the "flow-aware" paintlets of the panel with the specified actor.static void
updateProgrammaticVariables(VariablesHandler handler, Actor context, File flow)
Adds some programmatic variables.static <T extends Actor & VariablesHandler>
voidupdateProgrammaticVariables(T context, File flow)
Adds some programmatic variables.static boolean
write(String filename, Actor actor)
Writes the actor to a file.
-
-
-
Field Detail
-
FLOW_FILENAME_LONG
public static final String FLOW_FILENAME_LONG
the variable for the full flow filename.- See Also:
- Constant Field Values
-
FLOW_FILENAME_SHORT
public static final String FLOW_FILENAME_SHORT
the variable for the short flow filename.- See Also:
- Constant Field Values
-
FLOW_FILENAME_RESTORE
public static final String FLOW_FILENAME_RESTORE
the variable for the flow restoration filename (long filename, but with .props extension).- See Also:
- Constant Field Values
-
FLOW_DIR
public static final String FLOW_DIR
the variable for the directory the flow is located in.- See Also:
- Constant Field Values
-
FLOW_ID
public static final String FLOW_ID
the variable for the flow ID.- See Also:
- Constant Field Values
-
FLOW_START_TIMESTAMP
public static final String FLOW_START_TIMESTAMP
the variable for the start timestamp of the flow.- See Also:
- Constant Field Values
-
IS_HEADLESS
public static final String IS_HEADLESS
the variable for the headless flag.- See Also:
- Constant Field Values
-
HAS_GUI
public static final String HAS_GUI
the variable for the gui flag.- See Also:
- Constant Field Values
-
PROJECT_NAME
public static final String PROJECT_NAME
the variable for the project name.- See Also:
- Constant Field Values
-
PROJECT_HOME
public static final String PROJECT_HOME
the variable for the project home.- See Also:
- Constant Field Values
-
PROJECT_MODULES
public static final String PROJECT_MODULES
the variable for the project modules (comma-separated list).- See Also:
- Constant Field Values
-
PROGRAMMATIC_VARIABLES
public static final String[] PROGRAMMATIC_VARIABLES
programmatically set variables.
-
PROGRAMMATIC_VARIABLES_HELP
public static final Map<String,String> PROGRAMMATIC_VARIABLES_HELP
programmatically set variables.
-
FUNCTIONAL_PRIMITIVE
public static final String FUNCTIONAL_PRIMITIVE
functional type: primitive.- See Also:
- Constant Field Values
-
FUNCTIONAL_HANDLER
public static final String FUNCTIONAL_HANDLER
functional type: handler.- See Also:
- Constant Field Values
-
PROCEDURAL_STANDALONE
public static final String PROCEDURAL_STANDALONE
procedural type: standalone.- See Also:
- Constant Field Values
-
PROCEDURAL_SOURCE
public static final String PROCEDURAL_SOURCE
procedural type: source.- See Also:
- Constant Field Values
-
PROCEDURAL_TRANSFORMER
public static final String PROCEDURAL_TRANSFORMER
procedural type: transformer.- See Also:
- Constant Field Values
-
PROCEDURAL_SINK
public static final String PROCEDURAL_SINK
procedural type: sink.- See Also:
- Constant Field Values
-
ENV_INVALID_VARIABLES_LENIENT
public static final String ENV_INVALID_VARIABLES_LENIENT
the environment variable to enable lenient checking for invalid variables.- See Also:
- Constant Field Values
-
m_InvalidVariablesLenient
protected static Boolean m_InvalidVariablesLenient
whether to be lenient with invalid variables.
-
-
Method Detail
-
isLoggingEnabled
protected static boolean isLoggingEnabled()
Returns whether logging is enabled.- Returns:
- true if enabled
-
enumerate
protected static void enumerate(Actor actor, List<Actor> children, ActorFilter filter)
Enumerates all children of the given actor (depth-first search).- Parameters:
actor
- the actor to obtain all children fromchildren
- for collecting the childrenfilter
- for filtering the classes
-
enumerate
public static List<Actor> enumerate(Actor actor)
Enumerates all children of the given actor (depth-first search).- Parameters:
actor
- the actor to obtain all children from- Returns:
- all the children (if any)
-
enumerate
public static List<Actor> enumerate(Actor actor, Class[] filter)
Enumerates all children of the given actor (depth-first search).- Parameters:
actor
- the actor to obtain all children fromfilter
- the classes of actors to only enumerate, null for no filtering- Returns:
- all the children (if any)
-
enumerate
public static List<Actor> enumerate(Actor actor, ActorFilter filter)
Enumerates all children of the given actor (depth-first search).- Parameters:
actor
- the actor to obtain all children fromfilter
- the filter to use- Returns:
- all the children (if any)
-
replace
public static int replace(OptionHandler handler, Comparable find, Comparable replace, boolean recursive)
Replaces any occurrence of the object to find with the replacement. Can be done recursive. Performs the replacement also in arrays and nested OptionHandlers.- Parameters:
handler
- the OptionHandler to processfind
- the object to look forreplace
- the replacementrecursive
- if true then all children (if any) of the actor will be processed as well- Returns:
- the number of replacements
-
replace
public static int replace(OptionHandler handler, Comparable find, Comparable replace, boolean recursive, HashSet<Class> excluded)
Replaces any occurrence of the object to find with the replacement. Can be done recursive. Performs the replacement also in arrays and nested OptionHandlers.- Parameters:
handler
- the OptionHandler to processfind
- the object to look forreplace
- the replacementrecursive
- if true then all children (if any) of the actor will be processed as wellexcluded
- the base classes to skip- Returns:
- the number of replacements
-
uniqueName
public static boolean uniqueName(Actor actor, ActorHandler handler, int index)
Updates the name of the actor to make it unique among all the other actors of the given handler.- Parameters:
actor
- the actor which name needs to be made uniquehandler
- the handler to take into accountindex
- the index that this actor will be placed- Returns:
- true if the name was updated
-
uniqueName
public static boolean uniqueName(Actor actor, Set<String> names)
Updates the name of the actor to make it unique among all the other specified names.- Parameters:
actor
- the actor which name needs to be made uniquenames
- the existing names- Returns:
- true if the name was updated
-
uniqueName
public static boolean uniqueName(Actor actor, Set<String> names, boolean tailRemoval)
Updates the name of the actor to make it unique among all the other specified names.- Parameters:
actor
- the actor which name needs to be made uniquenames
- the existing namestailRemoval
- whether the "tail" (eg ' (2)') can be removed to determine basename- Returns:
- true if the name was updated
-
uniqueNames
public static boolean uniqueNames(Actor[] actors)
Updates the names of the actors to make then unique among all of them. NB: any suffix matching "-XYZ" gets stripped first.- Parameters:
actors
- the actors which names need to be made unique- Returns:
- true if at least one name was updated
-
findActorHandlers
public static List<ActorHandler> findActorHandlers(Actor actor)
Returns a list of actor handlers, starting from the current note (excluded). The search goes up in the actor hierarchy, up to the root (i.e., the last item in the returned list will be most likely a "Flow" actor).- Parameters:
actor
- the actor to start the search from- Returns:
- the list of actor handlers found along the path to the root actor
-
findActorHandlers
public static List<ActorHandler> findActorHandlers(Actor actor, boolean mustAllowStandalones)
Returns a list of actor handlers, starting from the current note (excluded). The search goes up in the actor hierarchy, up to the root (i.e., the last item in the returned list will be most likely a "Flow" actor).- Parameters:
actor
- the actor to start the search frommustAllowStandalones
- whether the handler must allow standalones- Returns:
- the list of actor handlers found along the path to the root actor
-
findActorHandlers
public static List<ActorHandler> findActorHandlers(Actor actor, boolean mustAllowStandalones, boolean includeSameLevel)
Returns a list of actor handlers, starting from the current note (excluded). The search goes up in the actor hierarchy, up to the root (i.e., the last item in the returned list will be most likely a "Flow" actor).- Parameters:
actor
- the actor to start the search frommustAllowStandalones
- whether the handler must allow standalonesincludeSameLevel
- allows adding of actor handlers that are on the same level as the current actor, but have a lower index in the parent- Returns:
- the list of actor handlers found along the path to the root actor
-
isStandalone
public static boolean isStandalone(Actor actor)
Checks whether this actor is a standalone.- Parameters:
actor
- the actor to check- Returns:
- true if standalone
-
isSource
public static boolean isSource(Actor actor)
Checks whether this actor is a source (output).- Parameters:
actor
- the actor to check- Returns:
- true if source
-
isSink
public static boolean isSink(Actor actor)
Checks whether this actor is a sink (input).- Parameters:
actor
- the actor to check- Returns:
- true if sink
-
isTransformer
public static boolean isTransformer(Actor actor)
Checks whether this actor is a transformer (input/output).- Parameters:
actor
- the actor to check- Returns:
- true if transformer
-
isControlActor
public static boolean isControlActor(Actor actor)
Checks whether this actor is a control actor.- Parameters:
actor
- the actor to check- Returns:
- true if control actor
-
isActorHandler
public static boolean isActorHandler(Actor actor)
Checks whether this actor is an actor handler.- Parameters:
actor
- the actor to check- Returns:
- true if actor handler
-
isInteractive
public static boolean isInteractive(Actor actor)
Checks whether the actor or its sub-actors are interactive ones. Does not check any callable actors. Cannot check any internally used actors if they are either not exposed (like ExternalActorHandler) or not yet executed/generated, so no guaranteed outcome.- Parameters:
actor
- the actor to check- Returns:
- true if at least one (active) interactive actor detected
-
write
public static boolean write(String filename, Actor actor)
Writes the actor to a file.- Parameters:
filename
- the file to write toactor
- the actor to write- Returns:
- true if successfully written
-
read
public static Actor read(String filename)
Reads an actor from a file.- Parameters:
filename
- the file to read the actor- Returns:
- the actor or null in case of an error
-
read
public static Actor read(String filename, MessageCollection errors)
Reads an actor from a file.- Parameters:
filename
- the file to read the actorerrors
- for storing (potential) errors, ignored if null- Returns:
- the actor or null in case of an error
-
read
public static Actor read(String filename, MessageCollection errors, MessageCollection warnings)
Reads an actor from a file.- Parameters:
filename
- the file to read the actorerrors
- for storing (potential) errors, ignored if nullwarnings
- for storing (potential) warnings, ignored if null- Returns:
- the actor or null in case of an error
-
findCallableTransformers
public static Hashtable<String,Integer> findCallableTransformers(Actor actor)
Locates callable transformers.- Parameters:
actor
- the actor (and its sub-actors) to check- Returns:
- the names of the callable actors referenced and how often they were referenced
-
findClosestType
protected static Actor findClosestType(ActorHandler handler, Class type)
Checks an actor handler's children whether they contain the actor type we're looking for.- Parameters:
handler
- the actor handler to checktype
- the type of actor to find the closest for- Returns:
- the closest actor or null if not found
-
findClosestType
public static Actor findClosestType(Actor actor, Class type)
Tries to find the closest type in the actor tree, starting with the current actor.- Parameters:
actor
- the actor to start fromtype
- the type of actor to find the closest for- Returns:
- the closest actor or null if not found
-
findClosestType
public static Actor findClosestType(Actor actor, Class type, boolean includeSameLevel)
Tries to find the closest type in the actor tree, starting with the current actor.- Parameters:
actor
- the actor to start fromtype
- the type of actor to find the closest forincludeSameLevel
- whether to include actor handlers that are on the same level as the actor, but with a lower index in the parent- Returns:
- the closest actor or null if not found
-
findClosestTypes
protected static List<Actor> findClosestTypes(ActorHandler handler, Class type)
Checks an actor handler's children whether they contain the actor type we're looking for.- Parameters:
handler
- the actor handler to checktype
- the type of actor to find the closest for- Returns:
- the closest actors, empty list if none found
-
findClosestTypes
public static List<Actor> findClosestTypes(Actor actor, Class type)
Tries to find the closest types in the actor tree, starting with the current actor.- Parameters:
actor
- the actor to start fromtype
- the type of actor to find the closest for- Returns:
- the closest actors or empty list if not found
-
findClosestTypes
public static List<Actor> findClosestTypes(Actor actor, Class type, boolean includeSameLevel)
Tries to find the closest types in the actor tree, starting with the current actor.- Parameters:
actor
- the actor to start fromtype
- the type of actor to find the closest forincludeSameLevel
- whether to include actor handlers that are on the same level as the actor, but with a lower index in the parent- Returns:
- the closest actors or empty list if not found
-
determineLocation
public static Point determineLocation(Window window, int x, int y)
Determines the initial location of the window.- Parameters:
window
- the window to determine the location forx
- the position (-1: left, -2: middle, -3: right)y
- the position (-1: top, -2: middle, -3: bottom)- Returns:
- the position
-
determineLocation
public static Point determineLocation(GraphicsConfiguration gc, Dimension size, int x, int y)
Determines the initial location of the window.- Parameters:
gc
- the graphics configurationsize
- the size of the windowx
- the position (-1: left, -2: middle, -3: right)y
- the position (-1: top, -2: middle, -3: bottom)- Returns:
- the position
-
determineSize
public static Dimension determineSize(Window window, int x, int y, int width, int height)
Determines the height of the window.- Parameters:
window
- the frame/dialog to determine the location forx
- the position (-1: left, -2: middle, -3: right)y
- the position (-1: top, -2: middle, -3: bottom)width
- the width (0: as is, -1: maximum width)height
- the width (0: as is, -1: maximum height)- Returns:
- the size
-
getDatabaseConnection
public static AbstractDatabaseConnection getDatabaseConnection(Actor actor, Class cls, AbstractDatabaseConnection defCon)
Returns the database connection object to use.- Parameters:
actor
- the actor start the search from (towards the root)cls
- the DatabaseConnection actor class to look fordefCon
- the default database connection, in case none is found in the flow- Returns:
- the connection object to use
-
removeDisabledActors
public static Actor removeDisabledActors(Actor actor)
Removes all disabled actors (recursively) from the actor.
NB: creates a copy of the actor first before removing the disabled actors.- Parameters:
actor
- the actor to process- Returns:
- the cleaned up actor (or original, if nothing changed)
-
setActors
protected static String setActors(ActorHandler handler, Actor[] actors)
Sets the actors in the handler.- Parameters:
handler
- the handler to updateactors
- the actors to set- Returns:
- null if successful, otherwise error message
-
createExternalActor
public static Actor createExternalActor(Actor[] actors, ActorHandler suggestion)
Ensures that the actors are enclosed in an "instantiable" wrapper.- Parameters:
actors
- the actors to enclosesuggestion
- the suggested actor handler, can be null- Returns:
- the processed actor
-
locate
public static Actor locate(ActorPath path, Actor parent)
Tries to locate the actor specified by the path parts.- Parameters:
parent
- the parent to start withpath
- the path elements to traverse (below the parent)- Returns:
- the located actor or null if none found
-
locate
public static Actor locate(ActorPath path, Actor parent, boolean included, boolean quiet)
Tries to locate the actor specified by the path parts.- Parameters:
parent
- the parent to start withpath
- the path elements to traverse (below the parent)included
- whether the actor should be included in the search, rather than searching only belowquiet
- whether to suppress any error messages- Returns:
- the located actor or null if none found
-
locate
public static Actor locate(String path, Actor root)
Locates the actor in the actor tree based on the specified path.- Parameters:
path
- the path of the node to locateroot
- the root actor start the search- Returns:
- the located actor or null if none found
-
locate
public static Actor locate(String path, Actor root, boolean included, boolean quiet)
Locates the actor in the actor tree based on the specified path.- Parameters:
path
- the path of the node to locateroot
- the root actor start the searchincluded
- whether the actor should be included in the search, rather than searching only belowquiet
- whether to suppress any error messages- Returns:
- the located actor or null if none found
-
checkForSource
public static String checkForSource(Actor actor)
Checks whether the actor has a source as first actor (can be nested).- Parameters:
actor
- the actor to analyze- Returns:
- null if ok, otherwise error message
-
checkForSource
public static String checkForSource(Actor[] actors)
Checks whether the actors have a source as first actor (can be nested).- Parameters:
actors
- the actors to analyze- Returns:
- null if ok, otherwise error message
-
checkForExternalActor
public static boolean checkForExternalActor(Actor actor)
Checks whether an external actor is present in this sub-tree.- Parameters:
actor
- the actor to analyze- Returns:
- true if external actor present
-
checkForCallableActorUser
public static boolean checkForCallableActorUser(Actor actor)
Checks whether a callable actor user is present in this sub-tree.- Parameters:
actor
- the actor to analyze- Returns:
- true if callable actor user present
-
cleanUpFlow
public static Actor cleanUpFlow(Actor actor)
Cleans up the flow, e.g., removing disabled actors, unused callable actors.- Parameters:
actor
- the flow to clean up- Returns:
- null if nothing changed, otherwise the updated flow
- See Also:
CleanUpProcessor
-
checkFlow
public static String checkFlow(Actor actor, File file)
Checks the flow.- Parameters:
actor
- the flow to checkfile
- the actor file to use- Returns:
- null if all checks passed, otherwise the warnings
- See Also:
CheckProcessor
-
checkFlow
public static String checkFlow(Actor actor, boolean variables, boolean storage, File file)
Checks the flow.- Parameters:
actor
- the flow to checkvariables
- whether the check variable usagestorage
- whether to check storage usagefile
- the actor file to use- Returns:
- null if all checks passed, otherwise the warnings
- See Also:
CheckProcessor
-
updateProgrammaticVariables
public static <T extends Actor & VariablesHandler> void updateProgrammaticVariables(T context, File flow)
Adds some programmatic variables.- Parameters:
context
- the actor, must be aflow
- the flow file name- See Also:
FLOW_FILENAME_LONG
,FLOW_FILENAME_SHORT
,FLOW_DIR
,FLOW_ID
,HAS_GUI
,IS_HEADLESS
,PROJECT_NAME
,PROJECT_HOME
,PROJECT_MODULES
,PROGRAMMATIC_VARIABLES
-
updateProgrammaticVariables
public static void updateProgrammaticVariables(VariablesHandler handler, Actor context, File flow)
Adds some programmatic variables.- Parameters:
handler
- the handler to add the filenames toflow
- the flow file name- See Also:
FLOW_FILENAME_LONG
,FLOW_FILENAME_SHORT
,FLOW_FILENAME_RESTORE
,FLOW_DIR
,FLOW_ID
,HAS_GUI
,IS_HEADLESS
,PROJECT_NAME
,PROJECT_HOME
,PROJECT_MODULES
,PROGRAMMATIC_VARIABLES
-
transform
public static List transform(Actor transformer, Object input) throws Exception
Processes the data using the specified transformer. Automatically sets up, executes, wraps up and cleans up the actor.- Parameters:
transformer
- the transformer to useinput
- the input data- Returns:
- the generated output data as list, null if none produced.
- Throws:
Exception
- if actor is not a transformer or transformation fails
-
updateErrorHandler
public static void updateErrorHandler(Actor actor, ErrorHandler handler, boolean trace)
Updates the error handler.- Parameters:
actor
- the actor to update the error handler forhandler
- the handler to usetrace
- whether to output the names of the actors that were updated
-
getFunctionalAspect
public static String getFunctionalAspect(Actor actor)
Determines the functional aspect of an actor.- Parameters:
actor
- the actor to investigate- Returns:
- the functional description
-
getProceduralAspect
public static String getProceduralAspect(Actor actor)
Determines the procedural aspect of an actor.- Parameters:
actor
- the actor to investigate- Returns:
- the procedural description
-
updateFlowAwarePaintlets
public static void updateFlowAwarePaintlets(PaintablePanel panel, Actor actor)
Updates all the "flow-aware" paintlets of the panel with the specified actor.- Parameters:
panel
- this panel's paintlets get updatedactor
- the actor to set
-
updateFlowAwarePaintlet
public static void updateFlowAwarePaintlet(Paintlet paintlet, Actor actor)
Updates a "flow-aware" paintlet with the specified actor.- Parameters:
paintlet
- the paintlet to update, if necessaryactor
- the actor to set
-
extractActorNames
public static List<String> extractActorNames(Actor current, String text)
Extracts all the valid actor names from the given text fragment that exist within the specified flow.- Parameters:
current
- the flow to verify the actor paths withtext
- the text to extract the names from- Returns:
- the full names of the located actors
-
forceVariables
public static String forceVariables(Actor actor, Variables vars)
Forces the update of the variables of this actor.- Parameters:
actor
- the actor to updatevars
- the variables to propagate- Returns:
- null if successful, otherwise error message
-
sort
public static boolean sort(SortableActorHandler handler, ActorComparator comp)
Sorts the child-actors using the supplied comparator.- Parameters:
handler
- the handler to sort the children forcomp
- the comparator to use- Returns:
- if the order was modified
-
determineNumActors
public static int determineNumActors(Actor flow)
Returns how many actors this flow is made of.- Parameters:
flow
- the flow to check- Returns:
- the number of actors
-
strip
public static Actor strip(Actor actor)
Returns a stripped down version of the actor, i.e., for ActorHandlers, a copy of the actor without any sub-actors gets returned.- Parameters:
actor
- the actor to strip down- Returns:
- the stripped down actor
- See Also:
ActorHandler
-
ensureValidVariables
public static String ensureValidVariables(Actor actor)
Ensures that the variables within this actor are valid.- Parameters:
actor
- the actor to check- Returns:
- null if all variables are valid
-
checkInvalidVariablesLenient
protected static boolean checkInvalidVariablesLenient()
Returns whether invalid variables are to be treated lenient (ie no error, just warning).- Returns:
- true if to treat lenient
- See Also:
ENV_INVALID_VARIABLES_LENIENT
-
getFlowID
public static int getFlowID(Actor source)
Returns the flow ID (if possible) for the given actor.- Parameters:
source
- the actor to get the flow ID for- Returns:
- the ID, -1 if unable to obtain
-
promptPassword
public static BasePassword promptPassword(Actor context)
Performs the interaction with the user.- Parameters:
context
- the context to use- Returns:
- null if successfully interacted, otherwise error message
-
promptPassword
public static BasePassword promptPassword(Actor context, String labelText)
Performs the interaction with the user.- Parameters:
context
- the context to uselabelText
- the text for the label, ignored if null- Returns:
- null if successfully interacted, otherwise error message
-
-