View Javadoc
1 /*** 2 * Copyright (c) 2002, CodeStreet LLC. All rights reserved.<p> 3 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following 4 * conditions are met:<p> 5 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 7 * in the documentation and/or other materials provided with the distribution. Neither the name of CodeStreet LLC. nor the 8 * names of its contributors may be used to endorse or promote products derived from this software without specific prior written 9 * permission.<p> 10 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 11 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 12 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 13 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 14 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 15 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<p> 16 */ 17 18 package com.codestreet.messageforge; 19 20 /*** 21 * Field type-safe enumeration. 22 * @author Jawaid Hakim. 23 */ 24 public class RFldType 25 { 26 /*** 27 * Ctor. To prevent default being generated. 28 */ 29 private RFldType() 30 { 31 type_ = 0; 32 strType_ = String.valueOf(type_); 33 complex_ = false; 34 jmsSupport_ = false; 35 } 36 37 /*** 38 * Ctor. To prevent instantiation. 39 * @param complex <tt>true</tt> if this field cannot be directly 40 * represented by supported TibrvMsg types. Otherwise, <tt>false</tt>. 41 * @param jmsSupport <tt>true</tt> if this field can be directly 42 * represented by supported JMS types. Otherwise, <tt>false</tt>. 43 * In JMS Java primitive types and their objectified versions are 44 * supported. For example, <tt>int</tt> and <tt>Integer</tt> 45 * are supported. The only other type supported is byte arrays. 46 * @param tibrvSupport <tt>true</tt> if this field can be directly 47 * represented by supported TIBCO Rendezvous. Otherwise, <tt>false</tt>. 48 * @see #isComplex() 49 */ 50 private RFldType(boolean complex, boolean jmsSupport, boolean tibrvSupport) 51 { 52 strType_ = String.valueOf(type_); 53 complex_ = complex; 54 jmsSupport_ = jmsSupport; 55 tibrvSupport_ = tibrvSupport; 56 } 57 58 /*** 59 * Override <tt>toString()</tt>. 60 * @return String representation of object type. 61 * @see #shortValue() 62 */ 63 public final String toString() 64 { 65 return strType_; 66 } 67 68 /*** 69 * Get the field type as a <tt>short</tt>. 70 * @return Field type as a <tt>short</tt>. 71 */ 72 public final short shortValue() 73 { 74 return type_; 75 } 76 77 /*** 78 * Check if this field is a complex type that cannot be directly 79 * represented by a corresponding TibrvMsg type. To send a complex 80 * field in a TibrvMsg, the field has to be sent as a (nested) 81 * byte array or as a nested TibrvMsg. To get the byte representation 82 * of a complex field call its getAsBytes() method. 83 * @return Returns <tt>true</tt> if this field is a complex type. 84 * Otherwise, <tt>false</tt>. 85 */ 86 public final boolean isComplex() 87 { 88 return complex_; 89 } 90 91 /*** 92 * Check if this field is supported by JMS. 93 * @return Returns <tt>true</tt> if this field is a supported by JMS. 94 * Otherwise, <tt>false</tt>. The Java data types supported by JMS in 95 * a <tt>MapMessage</tt> are the following:<b> 96 * boolean, Boolean<b> 97 * byte, Byte, byte[]<b> 98 * short, Short<b> 99 * int, Integer<b> 100 * long, Long<b> 101 * float, Float<b> 102 * double, Double<b> 103 * String<b> 104 */ 105 public final boolean isJMSSupported() 106 { 107 return jmsSupport_; 108 } 109 110 /*** 111 * Check if this field is supported by TIBCO Rendezvous. 112 * @return Returns <tt>true</tt> if this field is a supported by TIBCO Rendezvous. 113 * Otherwise, <tt>false</tt>. 114 */ 115 public final boolean isTibrvSupported() 116 { 117 return tibrvSupport_; 118 } 119 120 private String strType_; 121 private boolean complex_; 122 private boolean jmsSupport_; 123 private boolean tibrvSupport_; 124 125 126 private static short INIT_TYPE = 1; 127 private short type_ = INIT_TYPE++; 128 129 /*** 130 * BigDecimal. 131 */ 132 public static final RFldType DECIMAL = new RFldType(true, false, false); 133 134 /*** 135 * RFldMoney. 136 */ 137 public static final RFldType MONEY = new RFldType(true, false, false); 138 139 140 /*** 141 * byte. 142 */ 143 public static final RFldType I8 = new RFldType(false, true, true); 144 145 /*** 146 * byte[]. 147 */ 148 public static final RFldType I8ARRAY = new RFldType(false, true, true); 149 150 /*** 151 * short. 152 */ 153 public static final RFldType I16 = new RFldType(false, true, true); 154 155 /*** 156 * short[]. 157 */ 158 public static final RFldType I16ARRAY = new RFldType(false, false, true); 159 160 /*** 161 * int. 162 */ 163 public static final RFldType I32 = new RFldType(false, true, true); 164 165 /*** 166 * int[]. 167 */ 168 public static final RFldType I32ARRAY = new RFldType(false, false, true); 169 170 /*** 171 * long. 172 */ 173 public static final RFldType I64 = new RFldType(false, true, true); 174 175 /*** 176 * long[]. 177 */ 178 public static final RFldType I64ARRAY = new RFldType(false, false, true); 179 180 /*** 181 * Unsigned byte. 182 */ 183 public static final RFldType U8 = new RFldType(false, true, true); 184 185 /*** 186 * Unsigned byte[]. 187 */ 188 public static final RFldType U8ARRAY = new RFldType(false, false, true); 189 190 /*** 191 * Unsigned short. 192 */ 193 public static final RFldType U16 = new RFldType(false, true, true); 194 195 /*** 196 * Unsigned short[] 197 */ 198 public static final RFldType U16ARRAY = new RFldType(false, false, true); 199 200 /*** 201 * Unsigned int. 202 */ 203 public static final RFldType U32 = new RFldType(false, true, true); 204 205 /*** 206 * Unsigned int[]. 207 */ 208 public static final RFldType U32ARRAY = new RFldType(false, false, true); 209 210 /*** 211 * Unsigned long. 212 */ 213 public static final RFldType U64 = new RFldType(false, true, true); 214 215 /*** 216 * Unsigned long[]. 217 */ 218 public static final RFldType U64ARRAY = new RFldType(false, false, true); 219 220 /*** 221 * float. 222 */ 223 public static final RFldType F32 = new RFldType(false, true, true); 224 225 /*** 226 * float[]. 227 */ 228 public static final RFldType F32ARRAY = new RFldType(false, false, true); 229 230 /*** 231 * double. 232 */ 233 public static final RFldType F64 = new RFldType(false, true, true); 234 235 /*** 236 * double[]. 237 */ 238 public static final RFldType F64ARRAY = new RFldType(false, false, true); 239 240 /*** 241 * TibrvMsg. 242 */ 243 public static final RFldType MSG = new RFldType(false, false, true); 244 245 /*** 246 * byte[]. 247 */ 248 public static final RFldType OPAQUE = new RFldType(false, true, true); 249 250 /*** 251 * String. 252 */ 253 public static final RFldType STRING = new RFldType(false, true, true); 254 255 /*** 256 * See TibrvMsg.XML. 257 */ 258 public static final RFldType XML = new RFldType(false, true, true); 259 260 /*** 261 * See TibrvMsg.DATETIME. 262 */ 263 public static final RFldType DATETIME = new RFldType(false, false, true); 264 265 /*** 266 * boolean. 267 */ 268 public static final RFldType BOOL = new RFldType(false, true, true); 269 270 /*** 271 * See TibrvMsg.IPADDR32 272 */ 273 public static final RFldType IPADDR32 = new RFldType(false, false, true); 274 275 /*** 276 * See TibrvMsg.IPPORT16 277 */ 278 public static final RFldType IPPORT16 = new RFldType(false, false, true); 279 280 // First we have scalar types - these are fields that can be directly 281 // represented by TibrvMsg type. For example, we have the MEMO field 282 // type that can be directly represented by a TibrvMsg.STRING. 283 284 /*** 285 * Memo. 286 */ 287 public static final RFldType MEMO = new RFldType(false, true, true); 288 289 290 // Finally we have non-scalar types - these are fields that cannot be 291 // directly represented by TibrvMsg type. 292 293 /*** 294 * TibrvMsg[] 295 */ 296 public static final RFldType MSGARRAY = new RFldType(true, false, false); 297 298 /*** 299 * Date[] 300 */ 301 public static final RFldType DATEARRAY = new RFldType(true, false, false); 302 303 /*** 304 * String[] 305 */ 306 public static final RFldType STRINGARRAY = new RFldType(true, false, false); 307 308 /*** 309 * Bean 310 */ 311 public static final RFldType BEAN = new RFldType(true, false, false); 312 313 /*** 314 * Bean list. 315 */ 316 public static final RFldType BEANLIST = new RFldType(true, false, false); 317 318 /*** 319 * RMsg. 320 */ 321 public static final RFldType MSGOBJ = new RFldType(true, false, false); 322 323 /*** 324 * RMsg[]. 325 */ 326 public static final RFldType MSGOBJARRAY = new RFldType(true, false, false); 327 328 /*** 329 * <tt>java.util.Hashtable</tt> of RMsg. 330 */ 331 public static final RFldType MSGOBJHASHTABLE = new RFldType(true, false, false); 332 333 /*** 334 * <tt>java.util.Hashtable</tt> of <tt>String</tt> - the key/value are both <tt>String</tt>. 335 */ 336 public static final RFldType STRINGHASHTABLE = new RFldType(true, false, false); 337 338 /*** 339 * <tt>java.util.List</tt> of <tt>String</tt> - the key/value are both <tt>String</tt>. 340 */ 341 public static final RFldType STRINGLIST = new RFldType(true, false, false); 342 }

This page was automatically generated by Maven