forked from geodmms/xdgnjobs

?? ?
2010-04-22 6523c1f6534042d89ff8a07d4e7c06050276521e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.ximple.io.dgn7;
 
import org.apache.log4j.Logger;
 
/**
 * TcbElement
 *
 * @author Ulysses
 * @version 0.1
 * @since 2006/5/18 �U�� 05:03:46
 */
public class TcbElement extends Element {
    private static final Logger logger = Logger.getLogger(TcbElement.class);
 
    TcbElement(byte[] raw) {
        super(raw);
    }
 
    public boolean is2D() {
        int dimension = (int) (raw[607] & 0x00000004);
 
        if (dimension == 0) {
            return true;
        } else {
            return false;
        }
    }
 
    public String getMasterUnitName() {
        byte[] master = new byte[1];
 
        master[0] = (byte) (raw[560] & 0x00ff);
        java.nio.charset.Charset.forName("US-ASCII");
 
        // ASCIIEncoding encode = new ASCIIEncoding();
        StringBuilder sb = new StringBuilder();
 
        sb.append((char) master[0]);
 
        // return encode.GetString(master);
        return sb.toString();
    }
 
    public String getSubUnitName() {
        byte[] sub = new byte[2];
 
        sub[0] = (byte) (raw[561] & 0x00ff);
        sub[1] = (byte) (raw[561] >> 8 & 0x00ff);
 
        StringBuilder sb = new StringBuilder();
 
        sb.append((char) sub[0]);
        sb.append((char) sub[0]);
 
        return sb.toString();
    }
 
    public int getGraphicGroup() {
        return (int) (raw[594] & 0x0000ffff);
    }
 
    public static class ElementHandler extends Element.ElementHandler {
        private static ElementHandler instance = null;
 
        public ElementHandler() {
            super(ElementType.TCB);
        }
 
        public static IElementHandler getInstance() {
            if (instance == null) {
                instance = new ElementHandler();
            }
 
            return instance;
        }
 
        protected Element createElement(byte[] raw) {
            return new TcbElement(raw);
        }
    }
}