Package com.j3d.engine.interact.cmd
Class Invoker
java.lang.Object
com.j3d.engine.interact.cmd.Invoker
Represents the source or context from which a command was invoked.
A command can be invoked by their following classifications:
-
User: The user explicitly typed this command out in the command line (or it has been pasted) and they hit enter in the command lin and it executed. Can only setCommandParser#run() -
Engine: Anything else the user does, but does not have to go through the command line text input. So clicking a button or a keyboard shortcut, all count as engine invocations. set withinCommandParser.run(Command, ArrayList, ArrayList)overload -
fromParent: This specific command was invoked as a result of a parent command calling it. This specifically indicates that this was invoked as a Subcommand of the stored parent. This is set only byCommand#dispatchToSubcommands(String, SafeJLabel, Object[], ArrayList) -
fromCall: If another command call specifically calls some other command. The command has to use theCommandParser.run(Command, ArrayList, ArrayList, Command)overload.
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanIndicates if the invocation originated from the engine itself.private final CommandThe command that called this command if this invoker represents a direct command call.private final CommandThe parent command that invoked this command as a subcommand of itself, if applicable.private final booleanIndicates if the invocation originated from a macro.private final booleanIndicates if the invocation originated from a user action. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InvokerbyCommandCall(Command command) Creates an Invoker instance indicating the command was invoked directly through a command different call.static InvokerbyEngine()Creates an Invoker instance indicating the invocation originated from the engine.static InvokerbyMacro()Creates an Invoker instance indicating the invocation originated from a macrostatic InvokerbyParentCommand(Command command) Creates an Invoker instance indicating the command was invoked as a subcommand by another parent command.static InvokerbyUser()Creates an Invoker instance indicating the invocation originated from the command line input (the user hit enter)Returns the command that was called, if this invoker represents a direct command call.Returns the parent command that invoked this command, if applicable.Returns a descriptive string indicating the source of the invocation.booleanisEngine()Checks if the invocation originated from the engine itself.booleanisUser()Checks if the invocation originated from a user action.
-
Field Details
-
user
private final boolean userIndicates if the invocation originated from a user action. -
engine
private final boolean engineIndicates if the invocation originated from the engine itself. -
macro
private final boolean macroIndicates if the invocation originated from a macro. -
invokedFromParent
The parent command that invoked this command as a subcommand of itself, if applicable. -
invokedFromCall
The command that called this command if this invoker represents a direct command call.
-
-
Constructor Details
-
Invoker
-
-
Method Details
-
byUser
Creates an Invoker instance indicating the invocation originated from the command line input (the user hit enter)- Returns:
- An Invoker instance representing a user invocation.
-
byMacro
Creates an Invoker instance indicating the invocation originated from a macro- Returns:
- An Invoker instance representing a macro invocation.
-
byEngine
Creates an Invoker instance indicating the invocation originated from the engine. (anything else)- Returns:
- An Invoker instance representing an engine invocation.
-
byParentCommand
Creates an Invoker instance indicating the command was invoked as a subcommand by another parent command.- Parameters:
command- The parent command.- Returns:
- An Invoker instance.
-
byCommandCall
Creates an Invoker instance indicating the command was invoked directly through a command different call.- Parameters:
command- The command that was called.- Returns:
- An Invoker instance.
-
isUser
public boolean isUser()Checks if the invocation originated from a user action.- Returns:
- True if invoked by user, false otherwise.
-
isEngine
public boolean isEngine()Checks if the invocation originated from the engine itself.- Returns:
- True if invoked by engine, false otherwise.
-
getInvokedFromParent
Returns the parent command that invoked this command, if applicable.- Returns:
- The parent Command, or null if not invoked as a subcommand.
-
getInvokedFromCall
Returns the command that was called, if this invoker represents a direct command call.- Returns:
- The Command that was called, or null if not a direct call.
-
getString
Returns a descriptive string indicating the source of the invocation. This will be "USER", "ENGINE", or the simple class name of the invoking command with an indication of whether it was a subcommand or a direct call.- Returns:
- A string representing the invoker.
-