1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.compress.harmony.unpack200.bytecode;
18
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21
22
23
24
25 public abstract class ConstantPoolEntry extends ClassFileEntry {
26
27 public static final byte CP_Class = 7;
28
29 public static final byte CP_Double = 6;
30
31 public static final byte CP_Fieldref = 9;
32
33 public static final byte CP_Float = 4;
34
35 public static final byte CP_Integer = 3;
36
37
38
39
40
41
42 public static final byte CP_InterfaceMethodref = 11;
43
44 public static final byte CP_Long = 5;
45
46 public static final byte CP_Methodref = 10;
47
48 public static final byte CP_NameAndType = 12;
49
50 public static final byte CP_String = 8;
51
52 public static final byte CP_UTF8 = 1;
53
54 byte tag;
55
56 protected int globalIndex;
57
58 ConstantPoolEntry(final byte tag, final int globalIndex) {
59 this.tag = tag;
60 this.globalIndex = globalIndex;
61 }
62
63 @Override
64 public void doWrite(final DataOutputStream dos) throws IOException {
65 dos.writeByte(tag);
66 writeBody(dos);
67 }
68
69 @Override
70 public abstract boolean equals(Object obj);
71
72 public int getGlobalIndex() {
73 return globalIndex;
74 }
75
76 public byte getTag() {
77 return tag;
78 }
79
80 @Override
81 public abstract int hashCode();
82
83 protected abstract void writeBody(DataOutputStream dos) throws IOException;
84 }