Protocol { public final static String getOutputCommand(ReturnObject rObject) { StringBuilder builder = new StringBuilder(); builder.append(RETURN_MESSAGE); if (rObject.isError()) { builder.append(rObject.getCommandPart()); } else { builder.append(SUCCESS); builder.append(rObject.getCommandPart()); } builder.append(END_OUTPUT); return builder.toString(); }  static String encodeBytes(byte[] bytes); final static boolean getBoolean(String commandPart); final static byte[] getBytes(String commandPart); final static BigDecimal getDecimal(String commandPart); final static double getDouble(String commandPart); final static int getInteger(String commandPart); final static long getLong(String commandPart); final static String getMemberOutputCommand(char memberType); final static String getMemberOutputCommand(char memberType, String fqn); static String getNoSuchFieldOutputCommand(); final static Object getNull(String commandPart); final static Object getObject(String commandPart, Gateway gateway); final static String getOutputCommand(ReturnObject rObject); final static String getOutputErrorCommand(); final static String getOutputErrorCommand(String errorMessage); final static String getOutputErrorCommand(Throwable throwable); final static String getOutputFatalErrorCommand(Throwable throwable); final static String getOutputVoidCommand(); final static String getAuthCommand(String authToken); static char getPrimitiveType(Object primitiveObject); static Object getPythonProxy(String commandPart, Gateway gateway); static Object getPythonProxyHandler(ClassLoader classLoader, Class[] interfacesToImplement, String objectId,
			Gateway gateway); final static Object getReference(String commandPart, Gateway gateway); final static Object getReturnValue(String returnMessage, Gateway gateway); final static Throwable getRootThrowable(Throwable throwable, boolean skipInvocation); final static String getString(String commandPart); final static String getThrowableAsString(Throwable throwable); final static boolean isBoolean(String commandPart); final static boolean isReturnMessage(String commandPart); final static boolean isBytes(String commandPart); final static boolean isDecimal(String commandPart); final static boolean isDouble(String commandPart); final static boolean isEmpty(String commandPart); final static boolean isEnd(String commandPart); final static boolean isError(String returnMessage); final static boolean isInteger(String commandPart); final static boolean isLong(String commandPart); final static boolean isNull(String commandPart); final static boolean isPythonProxy(String commandPart); final static boolean isReference(String commandPart); final static boolean isString(String commandPart); final static char BYTES_TYPE; final static char INTEGER_TYPE; final static char LONG_TYPE; final static char BOOLEAN_TYPE; final static char DOUBLE_TYPE; final static char DECIMAL_TYPE; final static char STRING_TYPE; final static char REFERENCE_TYPE; final static char LIST_TYPE; final static char SET_TYPE; final static char ARRAY_TYPE; final static char MAP_TYPE; final static char ITERATOR_TYPE; final static char NULL_TYPE; final static char PYTHON_PROXY_TYPE; final static char PACKAGE_TYPE; final static char CLASS_TYPE; final static char METHOD_TYPE; final static char NO_MEMBER; final static char VOID; final static char RETURN_MESSAGE; final static char END; final static char END_OUTPUT; final static char ERROR; final static char FATAL_ERROR; final static char SUCCESS; final static String AUTH_COMMAND_NAME; final static String ERROR_COMMAND; final static String VOID_COMMAND; final static String NO_SUCH_FIELD; final static String ENTRY_POINT_OBJECT_ID; final static String DEFAULT_JVM_OBJECT_ID; final static String GATEWAY_SERVER_ID; final static String STATIC_PREFIX; final static String PYTHON_NAN; final static String PYTHON_INFINITY; final static String PYTHON_NEGATIVE_INFINITY; }
@Test public void testGetOutputCommand() { ReturnObject rObject1 = ReturnObject.getErrorReturnObject(); ReturnObject rObject2 = ReturnObject.getPrimitiveReturnObject(2); ReturnObject rObject3 = ReturnObject.getPrimitiveReturnObject(2.2); ReturnObject rObject4 = ReturnObject.getPrimitiveReturnObject(2.2f); ReturnObject rObject5 = ReturnObject.getPrimitiveReturnObject('c'); ReturnObject rObject6 = ReturnObject.getPrimitiveReturnObject("Hello\nWorld"); ReturnObject rObject7 = ReturnObject.getPrimitiveReturnObject(5L); ReturnObject rObject8 = ReturnObject.getPrimitiveReturnObject(true); ReturnObject rObject9 = ReturnObject.getPrimitiveReturnObject(false); ReturnObject rObject10 = ReturnObject.getNullReturnObject(); ReturnObject rObject11 = ReturnObject.getReferenceReturnObject("o123"); ReturnObject rObject12 = ReturnObject.getListReturnObject("o123", 2); ReturnObject rObject13 = ReturnObject.getMapReturnObject("o124", 3); ReturnObject rObject14 = ReturnObject.getSetReturnObject("o125", 3); ReturnObject rObject15 = ReturnObject.getArrayReturnObject("o126", 3); ReturnObject rObject16 = ReturnObject.getIteratorReturnObject("o127"); ReturnObject rObject17 = ReturnObject.getDecimalReturnObject(new BigDecimal("-14.532")); assertEquals("!x\n", Protocol.getOutputCommand(rObject1)); assertEquals("!yi2\n", Protocol.getOutputCommand(rObject2)); assertEquals("!yd2.2\n", Protocol.getOutputCommand(rObject3)); assertEquals("!yd2.2\n", Protocol.getOutputCommand(rObject4)); assertEquals("!ysc\n", Protocol.getOutputCommand(rObject5)); assertEquals("!ysHello\\nWorld\n", Protocol.getOutputCommand(rObject6)); assertEquals("!yL5\n", Protocol.getOutputCommand(rObject7)); assertEquals("!ybtrue\n", Protocol.getOutputCommand(rObject8)); assertEquals("!ybfalse\n", Protocol.getOutputCommand(rObject9)); assertEquals("!yn\n", Protocol.getOutputCommand(rObject10)); assertEquals("!yro123\n", Protocol.getOutputCommand(rObject11)); assertEquals("!ylo123\n", Protocol.getOutputCommand(rObject12)); assertEquals("!yao124\n", Protocol.getOutputCommand(rObject13)); assertEquals("!yho125\n", Protocol.getOutputCommand(rObject14)); assertEquals("!yto126\n", Protocol.getOutputCommand(rObject15)); assertEquals("!ygo127\n", Protocol.getOutputCommand(rObject16)); assertEquals("!yD-14.532\n", Protocol.getOutputCommand(rObject17)); }