4 * This class contains some global variables used in various parts of
6 * @author Anthony Molinaro
7 * @author Michael P. Lum
12 * The token used for <tt>undefined</tt> types in LWES
14 public final static byte UNDEFINED_TOKEN
= (byte)0xff;
17 * The token used by <tt>uint16</tt> in the Event Serialization Protocol
19 public final static byte UINT16_TOKEN
= (byte)0x01;
22 * The token used by <tt>int16</tt> in the Event Serialization Protocol
24 public final static byte INT16_TOKEN
= (byte)0x02;
26 * The token used by <tt>uint32</tt> in the Event Serialization Protocol
28 public final static byte UINT32_TOKEN
= (byte)0x03;
30 * The token used by <tt>int32</tt> in the Event Serialization Protocol
32 public final static byte INT32_TOKEN
= (byte)0x04;
34 * The token used by <tt>string</tt> in the Event Serialization Protocol
36 public final static byte STRING_TOKEN
= (byte)0x05;
38 * The token used by <tt>ip_addr</tt> in the Event Serialization Protocol
40 public final static byte IPADDR_TOKEN
= (byte)0x06;
42 * The token used by <tt>int64</tt> in the Event Serialization Protocol
44 public final static byte INT64_TOKEN
= (byte)0x07;
46 * The token used by <tt>uint64</tt> in the Event Serialization Protocol
48 public final static byte UINT64_TOKEN
= (byte)0x08;
50 * The token used by <tt>boolean</tt> in the Event Serialization Protocol
52 public final static byte BOOLEAN_TOKEN
= (byte)0x09;
55 * The string used by <tt>uint16</tt> in the Event Serialization Protocol
57 public final static String UINT16_STRING
= "uint16";
59 * The string used by <tt>int16</tt> in the Event Serialization Protocol
61 public final static String INT16_STRING
= "int16";
63 * The string used by <tt>uint32</tt> in the Event Serialization Protocol
65 public final static String UINT32_STRING
= "uint32";
67 * The string used by <tt>int32</tt> in the Event Serialization Protocol
69 public final static String INT32_STRING
= "int32";
71 * The string used by <tt>string</tt> in the Event Serialization Protocol
73 public final static String STRING_STRING
= "string";
75 * The string used by <tt>ip_addr</tt> in the Event Serialization Protocol
77 public final static String IPADDR_STRING
= "ip_addr";
79 * The string used by <tt>int64</tt> in the Event Serialization Protocol
81 public final static String INT64_STRING
= "int64";
83 * The string used by <tt>uint64</tt> in the Event Serialization Protocol
85 public final static String UINT64_STRING
= "uint64";
87 * The string used by <tt>boolean</tt> in the Event Serialization Protocol
89 public final static String BOOLEAN_STRING
= "boolean";
92 * This is a regular expression for parsing an integer number from a string
94 public final static String SIGNED_INTEGER_REGEX
= "-?\\d+";
96 * This is a regular expression for parsing an unsigned integer number
99 public final static String UNSIGNED_INTEGER_REGEX
= "\\d+(?=\\s|$)";
101 * This is a regular expression for matching a hexidecimal short from a string
103 public final static String HEX_SHORT_REGEX
= "0x[0-9a-fA-F]{1,4}(?=\\s|$)";
105 * This is a regular expression for matching a hexidecimal int from a string
107 public final static String HEX_INT_REGEX
= "0x[0-9a-fA-F]{5,8}(?=\\s|$)";
109 * This is a regular expression for matching a hexidecimal long from a string
111 public final static String HEX_LONG_REGEX
= "0x[0-9a-fA-F]{9,16}(?=\\s|$)";
113 * This is a regular expression for matching an ip address from a string
115 public final static String IP_ADDR_REGEX
116 = "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b";
118 * This is a regular expression for matching a boolean from a string
120 public final static String BOOLEAN_REGEX
= "true|false";
123 * Simple conversion utility
125 public static String
byteIDToString(byte id
)
130 return UINT16_STRING
;
134 return UINT32_STRING
;
138 return STRING_STRING
;
140 return IPADDR_STRING
;
144 return UINT64_STRING
;
146 return BOOLEAN_STRING
;
153 * Another conversion utility
155 public static byte stringToByteID(String id
)
157 if ( id
.equals(UINT16_STRING
) )
159 else if ( id
.equals(INT16_STRING
) )
161 else if ( id
.equals(UINT32_STRING
) )
163 else if ( id
.equals(INT32_STRING
) )
165 else if ( id
.equals(STRING_STRING
) )
167 else if ( id
.equals(IPADDR_STRING
) )
169 else if ( id
.equals(INT64_STRING
) )
171 else if ( id
.equals(UINT64_STRING
) )
173 else if ( id
.equals(BOOLEAN_STRING
) )
174 return BOOLEAN_TOKEN
;
176 return UNDEFINED_TOKEN
;