|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpy4j.Protocol
public class Protocol
This class defines the protocol used to communicate between two virtual machines (e.g., Python and Java).
Currently, the protocol requires type information (e.g., is this string an integer, an object reference or a boolean?) to be embedded within a command. The rational is that the source virtual machine is usually better at determining the type of objects it sends.
There are two protocols defined in this class. The input protocol defines the command parts expected to be received by the Java gateway. The output protocol adds the command parts that can be sent to the source virtual machine (e.g., an error has occurred while executing a command).
TODO:Implement a protocol that discovers the type of parameters in a command. This might be more efficient if the protocol is ever used by weakly typed languages.
Field Summary | |
---|---|
static char |
BOOLEAN_TYPE
|
static char |
DOUBLE_TYPE
|
static char |
END
|
static char |
ERROR
|
static String |
ERROR_COMMAND
|
static char |
INTEGER_TYPE
|
static char |
LIST_TYPE
|
static char |
NULL_TYPE
|
static char |
REFERENCE_TYPE
|
static char |
STRING_TYPE
|
static char |
SUCCESS
|
static char |
VOID
|
Constructor Summary | |
---|---|
Protocol()
|
Method Summary | |
---|---|
static boolean |
getBoolean(String commandPart)
Assumes that commandPart is not empty. |
static double |
getDouble(String commandPart)
Assumes that commandPart is not empty. |
static int |
getInteger(String commandPart)
Assumes that commandPart is not empty. |
static Object |
getNull(String commandPart)
Method provided for consistency. |
static Object |
getObject(String commandPart)
|
static Object |
getObject(String commandPart,
Gateway gateway)
|
static String |
getOutputCommand(ReturnObject rObject)
|
static String |
getOutputErrorCommand()
|
static String |
getReference(String commandPart)
Assumes that commandPart is not empty. |
static String |
getString(String commandPart)
Assumes that commandPart is not empty. |
static boolean |
isBoolean(String commandPart)
Assumes that commandPart is not empty. |
static boolean |
isDouble(String commandPart)
Assumes that commandPart is not empty. |
static boolean |
isEmpty(String commandPart)
|
static boolean |
isEnd(String commandPart)
Assumes that commandPart is not empty. |
static boolean |
isInteger(String commandPart)
Assumes that commandPart is not empty. |
static boolean |
isNull(String commandPart)
Assumes that commandPart is not empty. |
static boolean |
isReference(String commandPart)
Assumes that commandPart is not empty. |
static boolean |
isString(String commandPart)
Assumes that commandPart is not empty. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char INTEGER_TYPE
public static final char BOOLEAN_TYPE
public static final char DOUBLE_TYPE
public static final char STRING_TYPE
public static final char REFERENCE_TYPE
public static final char LIST_TYPE
public static final char NULL_TYPE
public static final char END
public static final char ERROR
public static final char SUCCESS
public static final char VOID
public static final String ERROR_COMMAND
Constructor Detail |
---|
public Protocol()
Method Detail |
---|
public static final boolean isEmpty(String commandPart)
public static final boolean isEnd(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final boolean isInteger(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final int getInteger(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final boolean isBoolean(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final boolean getBoolean(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final boolean isDouble(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final double getDouble(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final boolean isReference(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final String getReference(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final boolean isString(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final String getString(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final boolean isNull(String commandPart)
Assumes that commandPart is not empty.
commandPart
-
public static final Object getNull(String commandPart)
Method provided for consistency. Just returns null.
commandPart
-
public static final Object getObject(String commandPart, Gateway gateway)
public static final Object getObject(String commandPart)
public static final String getOutputErrorCommand()
public static final String getOutputCommand(ReturnObject rObject)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |