Revision 10054 trunk/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/DwgUtil.java
DwgUtil.java | ||
---|---|---|
57 | 57 |
* |
58 | 58 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
59 | 59 |
* @param offset The current bit offset where the value begins |
60 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
60 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
61 | 61 |
* when we are looking for LwPolylines. |
62 | 62 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
63 | 63 |
* the new offset, and second is the extended data of a DWG object |
64 | 64 |
*/ |
65 |
public static ArrayList readExtendedData(int[] data, int offset) throws Exception { |
|
65 |
public static ArrayList readExtendedData(int[] data, int offset) throws RuntimeException {
|
|
66 | 66 |
int bitPos = offset; |
67 | 67 |
ArrayList extData = new ArrayList(); |
68 | 68 |
while (true) { |
... | ... | |
186 | 186 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
187 | 187 |
* @param offset The current bit offset where the value begins |
188 | 188 |
* @param defVal Default double value |
189 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
189 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
190 | 190 |
* when we are looking for LwPolylines. |
191 | 191 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
192 | 192 |
* the new offset, and second is the double value |
193 | 193 |
*/ |
194 |
public static ArrayList getDefaultDouble(int[] data, int offset, double defVal) throws Exception { |
|
194 |
public static ArrayList getDefaultDouble(int[] data, int offset, double defVal) throws RuntimeException {
|
|
195 | 195 |
int flags = ((Integer)getBits(data, 2, offset)).intValue(); |
196 | 196 |
int read = 2; |
197 | 197 |
double val; |
... | ... | |
258 | 258 |
* |
259 | 259 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
260 | 260 |
* @param offset The current bit offset where the value begins |
261 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
261 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
262 | 262 |
* when we are looking for LwPolylines. |
263 | 263 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
264 | 264 |
* the new offset, and second is the double value |
265 | 265 |
*/ |
266 |
public static ArrayList getBitDouble(int[] data, int offset) throws Exception { |
|
266 |
public static ArrayList getBitDouble(int[] data, int offset) throws RuntimeException {
|
|
267 | 267 |
ArrayList v = new ArrayList(); |
268 | 268 |
int type = ((Integer)getBits(data, 2, offset)).intValue(); |
269 | 269 |
int read = 2; |
... | ... | |
290 | 290 |
* |
291 | 291 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
292 | 292 |
* @param offset The current bit offset where the value begins |
293 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
293 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
294 | 294 |
* when we are looking for LwPolylines. |
295 | 295 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
296 | 296 |
* the new offset, and second is the double value |
297 | 297 |
*/ |
298 |
public static ArrayList getRawDouble(int[] data, int offset) throws Exception { |
|
298 |
public static ArrayList getRawDouble(int[] data, int offset) throws RuntimeException {
|
|
299 | 299 |
byte[] bytes = (byte[])getBits(data, 64, offset); |
300 | 300 |
ByteBuffer bb = ByteBuffer.wrap(bytes); |
301 | 301 |
bb.order(ByteOrder.LITTLE_ENDIAN); |
... | ... | |
310 | 310 |
* |
311 | 311 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
312 | 312 |
* @param offset The current bit offset where the value begins |
313 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
313 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
314 | 314 |
* when we are looking for LwPolylines. |
315 | 315 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
316 | 316 |
* the new offset, and second is the short value |
317 | 317 |
*/ |
318 |
public static ArrayList getBitShort(int[] data, int offset) throws Exception { |
|
318 |
public static ArrayList getBitShort(int[] data, int offset) throws RuntimeException {
|
|
319 | 319 |
ArrayList v = new ArrayList(); |
320 | 320 |
int type = ((Integer)getBits(data, 2, offset)).intValue(); |
321 | 321 |
int read = 2; |
... | ... | |
343 | 343 |
* |
344 | 344 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
345 | 345 |
* @param offset The current bit offset where the value begins |
346 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
346 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
347 | 347 |
* when we are looking for LwPolylines. |
348 | 348 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
349 | 349 |
* the new offset, and second is the short value |
350 | 350 |
*/ |
351 |
public static ArrayList getRawShort(int[] data, int offset) throws Exception { |
|
351 |
public static ArrayList getRawShort(int[] data, int offset) throws RuntimeException {
|
|
352 | 352 |
byte[] bytes = (byte[])getBits(data, 16, offset); |
353 | 353 |
ByteBuffer bb = ByteBuffer.wrap(bytes); |
354 | 354 |
bb.order(ByteOrder.LITTLE_ENDIAN); |
... | ... | |
363 | 363 |
* |
364 | 364 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
365 | 365 |
* @param offset The current bit offset where the value begins |
366 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
366 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
367 | 367 |
* when we are looking for LwPolylines. |
368 | 368 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
369 | 369 |
* the new offset, and second is the long value |
370 | 370 |
*/ |
371 |
public static ArrayList getBitLong(int[] data, int offset) throws Exception { |
|
371 |
public static ArrayList getBitLong(int[] data, int offset) throws RuntimeException {
|
|
372 | 372 |
int type = ((Integer)getBits(data, 2, offset)).intValue(); |
373 | 373 |
int read = 2; |
374 | 374 |
int val = 0; |
... | ... | |
396 | 396 |
* |
397 | 397 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
398 | 398 |
* @param offset The current bit offset where the value begins |
399 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
399 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
400 | 400 |
* when we are looking for LwPolylines. |
401 | 401 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
402 | 402 |
* the new offset, and second is the long value |
403 |
* @throws Exception |
|
403 |
* @throws RuntimeException
|
|
404 | 404 |
*/ |
405 |
public static ArrayList getRawLong(int[] data, int offset) throws Exception { |
|
405 |
public static ArrayList getRawLong(int[] data, int offset) throws RuntimeException {
|
|
406 | 406 |
ArrayList v = new ArrayList(); |
407 | 407 |
// _val = struct.unpack('<l', _long)[0] |
408 | 408 |
byte[] bytes = (byte[])getBits(data, 32, offset); |
... | ... | |
418 | 418 |
* |
419 | 419 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
420 | 420 |
* @param offset The current bit offset where the value begins |
421 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
421 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
422 | 422 |
* when we are looking for LwPolylines. |
423 | 423 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
424 | 424 |
* the new offset, and second is the char value |
425 | 425 |
*/ |
426 |
public static ArrayList getRawChar(int[] data, int offset) throws Exception { |
|
426 |
public static ArrayList getRawChar(int[] data, int offset) throws RuntimeException {
|
|
427 | 427 |
int charr = ((Integer)getBits(data, 8, offset)).intValue(); |
428 | 428 |
ArrayList v = new ArrayList(); |
429 | 429 |
v.add(new Integer(offset+8)); |
... | ... | |
435 | 435 |
* |
436 | 436 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
437 | 437 |
* @param offset The current bit offset where the value begins |
438 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
438 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
439 | 439 |
* when we are looking for LwPolylines. |
440 | 440 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
441 | 441 |
* the new offset, and second is the char value |
442 | 442 |
*/ |
443 |
public static ArrayList getModularChar(int[] data, int offset) throws Exception { |
|
443 |
public static ArrayList getModularChar(int[] data, int offset) throws RuntimeException {
|
|
444 | 444 |
int val=0; |
445 | 445 |
ArrayList bytes = new ArrayList(); |
446 | 446 |
boolean read = true; |
... | ... | |
473 | 473 |
* |
474 | 474 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
475 | 475 |
* @param offset The current bit offset where the value begins |
476 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
476 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
477 | 477 |
* when we are looking for LwPolylines. |
478 | 478 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
479 | 479 |
* the new offset, and second is the String |
480 | 480 |
*/ |
481 |
public static ArrayList getTextString(int[] data, int offset) throws Exception { |
|
481 |
public static ArrayList getTextString(int[] data, int offset) throws RuntimeException {
|
|
482 | 482 |
int bitPos = offset; |
483 | 483 |
ArrayList bitShort = DwgUtil.getBitShort(data, bitPos); |
484 | 484 |
int newBitPos = ((Integer)bitShort.get(0)).intValue(); |
... | ... | |
505 | 505 |
* |
506 | 506 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
507 | 507 |
* @param offset The current bit offset where the value begins |
508 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
508 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
509 | 509 |
* when we are looking for LwPolylines. |
510 | 510 |
* @return ArrayList This ArrayList has two parts. First is an int value that represents |
511 | 511 |
* the new offset, and second is the int value (handle of a DWG object) |
512 | 512 |
*/ |
513 |
public static ArrayList getHandle(int[] data, int offset) throws Exception { |
|
513 |
public static ArrayList getHandle(int[] data, int offset) throws RuntimeException {
|
|
514 | 514 |
ArrayList v = new ArrayList(); |
515 | 515 |
int code = ((Integer)DwgUtil.getBits(data, 4, offset)).intValue(); |
516 | 516 |
int counter = ((Integer)DwgUtil.getBits(data, 4, (offset + 4))).intValue(); |
... | ... | |
581 | 581 |
* @param data Array of unsigned bytes obtained from the DWG binary file |
582 | 582 |
* @param count Bit counter |
583 | 583 |
* @param offset The current bit offset where the value begins |
584 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs |
|
584 |
* @throws RuntimeException If an unexpected bit value is found in the DWG file. Occurs
|
|
585 | 585 |
* when we are looking for LwPolylines. |
586 | 586 |
* @return This method returns an array of bytes or an int value |
587 | 587 |
*/ |
588 |
public static Object getBits(int[] data, int count, int offset) throws Exception { |
|
588 |
public static Object getBits(int[] data, int count, int offset) throws RuntimeException {
|
|
589 | 589 |
int idx = offset/8; |
590 | 590 |
int bitidx = offset%8; |
591 | 591 |
/** |
Also available in: Unified diff