1 2 17 18 package org.apache.poi.hpsf; 19 20 import java.util.Collections ; 21 import java.util.HashMap ; 22 import java.util.Map ; 23 24 40 public class Variant 41 { 42 43 46 public static final int VT_EMPTY = 0; 47 48 51 public static final int VT_NULL = 1; 52 53 56 public static final int VT_I2 = 2; 57 58 61 public static final int VT_I4 = 3; 62 63 66 public static final int VT_R4 = 4; 67 68 71 public static final int VT_R8 = 5; 72 73 78 public static final int VT_CY = 6; 79 80 85 public static final int VT_DATE = 7; 86 87 92 public static final int VT_BSTR = 8; 93 94 99 public static final int VT_DISPATCH = 9; 100 101 105 public static final int VT_ERROR = 10; 106 107 110 public static final int VT_BOOL = 11; 111 112 117 public static final int VT_VARIANT = 12; 118 119 124 public static final int VT_UNKNOWN = 13; 125 126 129 public static final int VT_DECIMAL = 14; 130 131 134 public static final int VT_I1 = 16; 135 136 139 public static final int VT_UI1 = 17; 140 141 144 public static final int VT_UI2 = 18; 145 146 149 public static final int VT_UI4 = 19; 150 151 154 public static final int VT_I8 = 20; 155 156 159 public static final int VT_UI8 = 21; 160 161 164 public static final int VT_INT = 22; 165 166 169 public static final int VT_UINT = 23; 170 171 174 public static final int VT_VOID = 24; 175 176 181 public static final int VT_HRESULT = 25; 182 183 188 public static final int VT_PTR = 26; 189 190 193 public static final int VT_SAFEARRAY = 27; 194 195 200 public static final int VT_CARRAY = 28; 201 202 207 public static final int VT_USERDEFINED = 29; 208 209 212 public static final int VT_LPSTR = 30; 213 214 217 public static final int VT_LPWSTR = 31; 218 219 226 public static final int VT_FILETIME = 64; 227 228 231 public static final int VT_BLOB = 65; 232 233 236 public static final int VT_STREAM = 66; 237 238 241 public static final int VT_STORAGE = 67; 242 243 248 public static final int VT_STREAMED_OBJECT = 68; 249 250 255 public static final int VT_STORED_OBJECT = 69; 256 257 262 public static final int VT_BLOB_OBJECT = 70; 263 264 269 public static final int VT_CF = 71; 270 271 301 public static final int VT_CLSID = 72; 302 303 308 public static final int VT_VECTOR = 0x1000; 309 310 314 public static final int VT_ARRAY = 0x2000; 315 316 321 public static final int VT_BYREF = 0x4000; 322 323 326 public static final int VT_RESERVED = 0x8000; 327 328 331 public static final int VT_ILLEGAL = 0xFFFF; 332 333 336 public static final int VT_ILLEGALMASKED = 0xFFF; 337 338 341 public static final int VT_TYPEMASK = 0xFFF; 342 343 344 345 349 private static Map numberToName; 350 351 private static Map numberToLength; 352 353 356 public static final Integer LENGTH_UNKNOWN = new Integer (-2); 357 358 361 public static final Integer LENGTH_VARIABLE = new Integer (-1); 362 363 366 public static final Integer LENGTH_0 = new Integer (0); 367 368 371 public static final Integer LENGTH_2 = new Integer (2); 372 373 376 public static final Integer LENGTH_4 = new Integer (4); 377 378 381 public static final Integer LENGTH_8 = new Integer (8); 382 383 384 385 static 386 { 387 388 Map tm1 = new HashMap (); 389 tm1.put(new Long (0), "VT_EMPTY"); 390 tm1.put(new Long (1), "VT_NULL"); 391 tm1.put(new Long (2), "VT_I2"); 392 tm1.put(new Long (3), "VT_I4"); 393 tm1.put(new Long (4), "VT_R4"); 394 tm1.put(new Long (5), "VT_R8"); 395 tm1.put(new Long (6), "VT_CY"); 396 tm1.put(new Long (7), "VT_DATE"); 397 tm1.put(new Long (8), "VT_BSTR"); 398 tm1.put(new Long (9), "VT_DISPATCH"); 399 tm1.put(new Long (10), "VT_ERROR"); 400 tm1.put(new Long (11), "VT_BOOL"); 401 tm1.put(new Long (12), "VT_VARIANT"); 402 tm1.put(new Long (13), "VT_UNKNOWN"); 403 tm1.put(new Long (14), "VT_DECIMAL"); 404 tm1.put(new Long (16), "VT_I1"); 405 tm1.put(new Long (17), "VT_UI1"); 406 tm1.put(new Long (18), "VT_UI2"); 407 tm1.put(new Long (19), "VT_UI4"); 408 tm1.put(new Long (20), "VT_I8"); 409 tm1.put(new Long (21), "VT_UI8"); 410 tm1.put(new Long (22), "VT_INT"); 411 tm1.put(new Long (23), "VT_UINT"); 412 tm1.put(new Long (24), "VT_VOID"); 413 tm1.put(new Long (25), "VT_HRESULT"); 414 tm1.put(new Long (26), "VT_PTR"); 415 tm1.put(new Long (27), "VT_SAFEARRAY"); 416 tm1.put(new Long (28), "VT_CARRAY"); 417 tm1.put(new Long (29), "VT_USERDEFINED"); 418 tm1.put(new Long (30), "VT_LPSTR"); 419 tm1.put(new Long (31), "VT_LPWSTR"); 420 tm1.put(new Long (64), "VT_FILETIME"); 421 tm1.put(new Long (65), "VT_BLOB"); 422 tm1.put(new Long (66), "VT_STREAM"); 423 tm1.put(new Long (67), "VT_STORAGE"); 424 tm1.put(new Long (68), "VT_STREAMED_OBJECT"); 425 tm1.put(new Long (69), "VT_STORED_OBJECT"); 426 tm1.put(new Long (70), "VT_BLOB_OBJECT"); 427 tm1.put(new Long (71), "VT_CF"); 428 tm1.put(new Long (72), "VT_CLSID"); 429 Map tm2 = new HashMap (tm1.size(), 1.0F); 430 tm2.putAll(tm1); 431 numberToName = Collections.unmodifiableMap(tm2); 432 433 434 tm1.clear(); 435 tm1.put(new Long (0), LENGTH_0); 436 tm1.put(new Long (1), LENGTH_UNKNOWN); 437 tm1.put(new Long (2), LENGTH_2); 438 tm1.put(new Long (3), LENGTH_4); 439 tm1.put(new Long (4), LENGTH_4); 440 tm1.put(new Long (5), LENGTH_8); 441 tm1.put(new Long (6), LENGTH_UNKNOWN); 442 tm1.put(new Long (7), LENGTH_UNKNOWN); 443 tm1.put(new Long (8), LENGTH_UNKNOWN); 444 tm1.put(new Long (9), LENGTH_UNKNOWN); 445 tm1.put(new Long (10), LENGTH_UNKNOWN); 446 tm1.put(new Long (11), LENGTH_UNKNOWN); 447 tm1.put(new Long (12), LENGTH_UNKNOWN); 448 tm1.put(new Long (13), LENGTH_UNKNOWN); 449 tm1.put(new Long (14), LENGTH_UNKNOWN); 450 tm1.put(new Long (16), LENGTH_UNKNOWN); 451 tm1.put(new Long (17), LENGTH_UNKNOWN); 452 tm1.put(new Long (18), LENGTH_UNKNOWN); 453 tm1.put(new Long (19), LENGTH_UNKNOWN); 454 tm1.put(new Long (20), LENGTH_UNKNOWN); 455 tm1.put(new Long (21), LENGTH_UNKNOWN); 456 tm1.put(new Long (22), LENGTH_UNKNOWN); 457 tm1.put(new Long (23), LENGTH_UNKNOWN); 458 tm1.put(new Long (24), LENGTH_UNKNOWN); 459 tm1.put(new Long (25), LENGTH_UNKNOWN); 460 tm1.put(new Long (26), LENGTH_UNKNOWN); 461 tm1.put(new Long (27), LENGTH_UNKNOWN); 462 tm1.put(new Long (28), LENGTH_UNKNOWN); 463 tm1.put(new Long (29), LENGTH_UNKNOWN); 464 tm1.put(new Long (30), LENGTH_VARIABLE); 465 tm1.put(new Long (31), LENGTH_UNKNOWN); 466 tm1.put(new Long (64), LENGTH_8); 467 tm1.put(new Long (65), LENGTH_UNKNOWN); 468 tm1.put(new Long (66), LENGTH_UNKNOWN); 469 tm1.put(new Long (67), LENGTH_UNKNOWN); 470 tm1.put(new Long (68), LENGTH_UNKNOWN); 471 tm1.put(new Long (69), LENGTH_UNKNOWN); 472 tm1.put(new Long (70), LENGTH_UNKNOWN); 473 tm1.put(new Long (71), LENGTH_UNKNOWN); 474 tm1.put(new Long (72), LENGTH_UNKNOWN); 475 tm2 = new HashMap (tm1.size(), 1.0F); 476 tm2.putAll(tm1); 477 numberToLength = Collections.unmodifiableMap(tm2); 478 } 479 480 481 482 489 public static String getVariantName(final long variantType) 490 { 491 final String name = (String ) numberToName.get(new Long (variantType)); 492 return name != null ? name : "unknown variant type"; 493 } 494 495 504 public static int getVariantLength(final long variantType) 505 { 506 final Long key = new Long ((int) variantType); 507 final Long length = (Long ) numberToLength.get(key); 508 if (length == null) 509 return -2; 510 return length.intValue(); 511 } 512 513 } 514 | Popular Tags |