projects
/
iot2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Testing more complex struct and enum declarations; fixing subtle bugs
[iot2.git]
/
iotjava
/
iotrmi
/
Java
/
IoTRMIUtil.java
diff --git
a/iotjava/iotrmi/Java/IoTRMIUtil.java
b/iotjava/iotrmi/Java/IoTRMIUtil.java
index e1c1be8cc40c58db06f370d693e545b88b3f9157..23385ba5199947039f7d68d398cb95fc4c02b063 100644
(file)
--- a/
iotjava/iotrmi/Java/IoTRMIUtil.java
+++ b/
iotjava/iotrmi/Java/IoTRMIUtil.java
@@
-40,6
+40,7
@@
public class IoTRMIUtil {
public final static int OBJECT_ID_LEN = 4; // 4 bytes = 32 bits
public final static int METHOD_ID_LEN = 4; // 4 bytes = 32 bits
public final static int PARAM_LEN = 4; // 4 bytes = 32 bits (4-byte field that stores the length of the param)
public final static int OBJECT_ID_LEN = 4; // 4 bytes = 32 bits
public final static int METHOD_ID_LEN = 4; // 4 bytes = 32 bits
public final static int PARAM_LEN = 4; // 4 bytes = 32 bits (4-byte field that stores the length of the param)
+ public final static int RETURN_LEN = 4; // 4 bytes = 32 bits (4-byte field that stores the length of the return object)
public final static int SHT_LEN = 2;
public final static int INT_LEN = 4;
public final static int SHT_LEN = 2;
public final static int INT_LEN = 4;
@@
-162,7
+163,7
@@
public class IoTRMIUtil {
/**
* getParamObject() converts byte array of certain object type into Object
*/
/**
* getParamObject() converts byte array of certain object type into Object
*/
- public static Object getParamObject(Class<?> type, Class<?> genType
Key, Class<?> genType
Val, byte[] paramBytes) {
+ public static Object getParamObject(Class<?> type, Class<?> genTypeVal, byte[] paramBytes) {
Object retObj = null;
if (type == byte.class ||
Object retObj = null;
if (type == byte.class ||
@@
-194,17
+195,9
@@
public class IoTRMIUtil {
// Array
} else if (type.isArray()) {
retObj = getParamObjectArray(type, paramBytes);
// Array
} else if (type.isArray()) {
retObj = getParamObjectArray(type, paramBytes);
- // Set
- // e.g. Set<String> - type = Set.class, genTypeVal = String.class
- /*} else if (type == Set.class) {
- retObj = getParamSetObject(genTypeVal, paramBytes);*/
// List
} else if (type == List.class) {
retObj = getParamListObject(genTypeVal, paramBytes);
// List
} else if (type == List.class) {
retObj = getParamListObject(genTypeVal, paramBytes);
- // Map
- // e.g. Map<String,Integer> - type = Map.class, genTypeKey = String.class, genTypeVal = Integer.class
- /*} else if (type == Map.class) {
- retObj = getParamMapObject(genTypeKey, genTypeVal, paramBytes);*/
} else
throw new Error("IoTRMIUtil: Unrecognizable type: " + type.getName());
} else
throw new Error("IoTRMIUtil: Unrecognizable type: " + type.getName());
@@
-269,7
+262,7
@@
public class IoTRMIUtil {
} else if ( (type == String[].class) ||
(type == String.class)) {
retObj = (Object) byteArrayToStringArray(paramBytes);
} else if ( (type == String[].class) ||
(type == String.class)) {
retObj = (Object) byteArrayToStringArray(paramBytes);
- } else if (type.isArray()) {
+
//
} else if (type.isArray()) {
// This is an array but it's more than 1 dimension, e.g. 2-dimensional,
// 3-dimensional, etc.
// for loop to check inner array perhaps using object
// This is an array but it's more than 1 dimension, e.g. 2-dimensional,
// 3-dimensional, etc.
// for loop to check inner array perhaps using object
@@
-290,7
+283,7
@@
public class IoTRMIUtil {
byte[] retObjBytes = null;
if (obj instanceof Byte) {
byte[] retObjBytes = null;
if (obj instanceof Byte) {
- retObjBytes =
(byte[]) obj
;
+ retObjBytes =
new byte[] { (byte) obj }
;
} else if (obj instanceof Short) {
retObjBytes = shortToByteArray((short) obj);
} else if (obj instanceof Integer) {
} else if (obj instanceof Short) {
retObjBytes = shortToByteArray((short) obj);
} else if (obj instanceof Integer) {