public abstract class AbstractCommand extends java.lang.Object implements Command
Abstract base class for commands. Provides useful methods allowing the parsing of command arguments.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
commandName |
protected Py4JServerConnection |
connection |
protected Gateway |
gateway |
Constructor and Description |
---|
AbstractCommand() |
Modifier and Type | Method and Description |
---|---|
abstract void |
execute(java.lang.String commandName,
java.io.BufferedReader reader,
java.io.BufferedWriter writer) |
protected java.util.List<java.lang.Object> |
getArguments(java.io.BufferedReader reader) |
java.lang.String |
getCommandName() |
protected java.util.List<java.lang.String> |
getStringArguments(java.io.BufferedReader reader) |
void |
init(Gateway gateway,
Py4JServerConnection connection)
Called when a command instance is created and assigned to a connection.
|
protected ReturnObject |
invokeMethod(java.lang.String methodName,
java.lang.String targetObjectId,
java.util.List<java.lang.Object> arguments)
Convenient shortcut to invoke a method dynamically.
|
protected Gateway gateway
protected java.lang.String commandName
protected Py4JServerConnection connection
public abstract void execute(java.lang.String commandName, java.io.BufferedReader reader, java.io.BufferedWriter writer) throws Py4JException, java.io.IOException
execute
in interface Command
commandName
- The command name that was extracted of the command.reader
- The reader from which to read the command parts. Each command
part are expected to be on a separate line and readable
through BufferedReader.readLine()
.writer
- The writer to which the return value should be written.Py4JException
- If an error occurs while executing the command. All
exceptions except IOException caused by the reader and the
writer should be wrapper in a Py4JException
instance.java.io.IOException
- If an error occurs while using the reader or the writer.protected java.util.List<java.lang.Object> getArguments(java.io.BufferedReader reader) throws java.io.IOException
reader
- java.io.IOException
public java.lang.String getCommandName()
getCommandName
in interface Command
protected java.util.List<java.lang.String> getStringArguments(java.io.BufferedReader reader) throws java.io.IOException
reader
- java.io.IOException
public void init(Gateway gateway, Py4JServerConnection connection)
Command
Called when a command instance is created and assigned to a connection.
init
in interface Command
connection
- the Py4JServerConnection
this socket is assigned toprotected ReturnObject invokeMethod(java.lang.String methodName, java.lang.String targetObjectId, java.util.List<java.lang.Object> arguments)
Convenient shortcut to invoke a method dynamically.
methodName
- targetObjectId
- arguments
-