|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mycore.frontend.cli.MCRCommand
public class MCRCommand
Represents a command understood by the command line interface. A command has an external input syntax that the user uses to invoke the command and points to a method in a class that implements the command.
MCRCommandLineInterface| Field Summary | |
|---|---|
protected String |
className
The class providing the implementation method |
protected String |
help
The help text String |
protected MessageFormat |
messageFormat
The input format used for invoking this command |
protected Method |
method
The java method that implements this command |
protected String |
methodName
The method implementing this command |
protected int |
numParameters
The number of invocation parameters |
protected Class[] |
parameterTypes
The types of the invocation parameters |
protected String |
suffix
The beginning of the message format up to the first parameter |
| Constructor Summary | |
|---|---|
MCRCommand(String format,
String methodSignature,
String helpText)
Creates a new MCRCommand. |
|
| Method Summary | |
|---|---|
protected Object[] |
buildInvocationParameters(Object[] commandParameters)
Transforms the parameters found by the MessageFormat parse method into such that can be used to invoke the method implementing this command |
protected String |
getHelpText()
The method return the helpt text of this command. |
protected Method |
getMethod(ClassLoader classLoader)
Returns the method implementing the command behavior. |
List<String> |
invoke(String input)
Tries to invoke the method that implements the behavior of this command given the user input from the command line. |
List<String> |
invoke(String input,
ClassLoader classLoader)
|
protected Object[] |
parseCommandLine(String commandLine)
Parses an input string and tries to match it with the message format used to invoke this command. |
String |
showSyntax()
Returns the input syntax to be used for invoking this command from the command prompt. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected MessageFormat messageFormat
protected Method method
protected Class[] parameterTypes
protected int numParameters
protected String className
protected String methodName
protected String suffix
protected String help
| Constructor Detail |
|---|
public MCRCommand(String format,
String methodSignature,
String helpText)
format - the command syntax, e.g. "save document {0} to directory {1}"methodSignature - the method to invoke, e.g.
"miless.commandline.DocumentCommands.saveDoc int String"helpText - the helpt text for this command| Method Detail |
|---|
protected Method getMethod(ClassLoader classLoader)
throws ClassNotFoundException,
NoSuchMethodException
ClassNotFoundException - when the class that implements the method was not found
NoSuchMethodException - When the method specified in the constructor was not foundprotected String getHelpText()
protected Object[] parseCommandLine(String commandLine)
commandLine - The input from the command line
protected Object[] buildInvocationParameters(Object[] commandParameters)
commandParameters - The parameters as returned by the
parseCommandLine method
public List<String> invoke(String input)
throws IllegalAccessException,
InvocationTargetException,
ClassNotFoundException,
NoSuchMethodException
input - The command entered by the user at the command prompt
IllegalAccessException - when the method can not be invoked
InvocationTargetException - when an exception is thrown by the invoked method
ClassNotFoundException - when the class providing the method could not be found
NoSuchMethodException - when the method specified does not exist
public List<String> invoke(String input,
ClassLoader classLoader)
throws IllegalAccessException,
InvocationTargetException,
ClassNotFoundException,
NoSuchMethodException
IllegalAccessException
InvocationTargetException
ClassNotFoundException
NoSuchMethodExceptionpublic final String showSyntax()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||