Cleaning up code for runtime, installer, RMI, compiler for the Java side
[iot2.git] / iotjava / iotrmi / Java / IoTRMITypes.java
1 package iotrmi.Java;
2
3 /** Class IoTRMITypes is a class that provides type translations.
4  *  <p>
5  *  It stores C++ and Java types.
6  *
7  * @author      Rahmadi Trimananda <rtrimana @ uci.edu>
8  * @version     1.0
9  * @since       2016-10-03
10  */
11
12 import java.util.HashMap;
13 import java.util.Map;
14
15 public final class IoTRMITypes {
16
17         /**
18          * Primitive data types in Java
19          */
20         public final static String[] primitivesJava = new String[] {
21
22                 "byte",                 // 1 byte
23                 "Byte",                 // 1 byte
24                 "short",                // 2 bytes
25                 "Short",                // 2 bytes
26                 "int",                  // 4 bytes
27                 "Integer",              // 4 bytes
28                 "long",                 // 8 bytes
29                 "Long",                 // 8 bytes
30                 "float",                // 4 bytes
31                 "Float",                // 4 bytes
32                 "double",               // 8 bytes
33                 "Double",               // 8 bytes
34                 "boolean",              // 1 bytes
35                 "Boolean",              // 1 bytes
36                 "char",                 // 2 bytes
37                 "Character",    // 2 bytes
38                 "string",               // indefinite
39                 "String",               // indefinite
40                 "void"                  // 0 byte
41         };
42
43
44         /**
45          * Primitive data types in C++ to map the primitives list
46          */
47         public final static String[] primitivesCplus = new String[] {
48
49                 "char",                 // 1 byte
50                 "char",                 // 1 byte
51                 "short",                // 2 bytes
52                 "short",                // 2 bytes
53                 "int",                  // 4 bytes
54                 "int",                  // 4 bytes
55                 "int64_t",              // 8 bytes
56                 "int64_t",              // 8 bytes
57                 "float",                // 4 bytes
58                 "float",                // 4 bytes
59                 "double",               // 8 bytes
60                 "double",               // 8 bytes
61                 "bool",                 // 1 byte
62                 "bool",                 // 1 byte
63                 "char",                 // 2 bytes - C++ is made to follow Java convention
64                 "char",                 // 2 bytes -    i.e. 2 bytes for a char
65                 "string",               // indefinite
66                 "string",               // indefinite
67                 "void"                  // 0 byte
68         };
69
70
71         /**
72          * Primitive sizes in Java - Long is 8 bytes and char is 2 bytes
73          */
74         public final static Integer[] primitivesSizes = new Integer[] {
75
76                 1, 1, 2, 2, 4, 4, 8, 8, 4, 4, 8, 8, 1, 1, 2, 2, -1, -1, 0
77         };
78
79
80         /**
81          * Non-primitive Java data types
82          */
83         public final static String[] nonPrimitivesJava = new String[] {
84
85                 "List",
86                 "ArrayList"
87         };
88
89
90         /**
91          * Non-primitive Java libraries based on the list above
92          */
93         public final static String[] nonPrimitiveJavaLibs = new String[] {
94
95                 "java.util.List",
96                 "java.util.ArrayList"
97         };
98
99
100         /**
101          * Non-primitive C++ data types
102          */
103         public final static String[] nonPrimitivesCplus = new String[] {
104
105                 "vector",
106                 "vector"
107         };
108
109
110         /**================
111          * Helper functions
112          **================
113          */
114         // Inserting array members into a Map object
115         // that maps arrKey to arrVal objects
116         public static void arraysToMap(Map<String,String> map, String[] arrKey, String[] arrVal) {
117
118                 for(int i = 0; i < arrKey.length; i++) {
119
120                         map.put(arrKey[i], arrVal[i]);
121                 }
122         }
123
124         // Inserting array members into a Map object
125         // that maps arrKey to arrVal objects
126         public static void arraysToMap(Map<String,Integer> map, String[] arrKey, Integer[] arrVal) {
127
128                 for(int i = 0; i < arrKey.length; i++) {
129
130                         map.put(arrKey[i], arrVal[i]);
131                 }
132         }
133
134         // Inserting array members into a Map object
135         // that maps arrKey to arrVal objects
136         public static void arraysToMap(Map<Object,Object> map, Object[] arrKey, Object[] arrVal) {
137
138                 for(int i = 0; i < arrKey.length; i++) {
139
140                         map.put(arrKey[i], arrVal[i]);
141                 }
142         }
143 }