01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.harmony.pack200.bytecode;
18:
19: import java.io.DataOutputStream;
20: import java.io.IOException;
21:
22: /**
23: *
24: */
25: public abstract class ConstantPoolEntry extends ClassFileEntry {
26: public static final byte CP_Class = 7;
27:
28: public static final byte CP_Double = 6;
29:
30: public static final byte CP_Fieldref = 9;
31:
32: public static final byte CP_Float = 4;
33:
34: public static final byte CP_Integer = 3;
35:
36: /*
37: * class MemberRef extends ConstantPoolEntry { private int index;
38: *
39: * Class(String name) { super(CP_Class); index = pool.indexOf(name); }
40: *
41: * void writeBody(DataOutputStream dos) throws IOException {
42: * dos.writeShort(index); } }
43: */
44:
45: public static final byte CP_InterfaceMethodref = 11;
46:
47: public static final byte CP_Long = 5;
48:
49: public static final byte CP_Methodref = 10;
50:
51: public static final byte CP_NameAndType = 12;
52:
53: public static final byte CP_String = 8;
54:
55: public static final byte CP_UTF8 = 1;
56:
57: byte tag;
58:
59: protected int domain = ClassConstantPool.DOMAIN_UNDEFINED;
60: public static int creationOrderCount = 100;
61:
62: public String comparisonString() {
63: return toString();
64: }
65:
66: public int creationOrder = -1;
67:
68: ConstantPoolEntry(byte tag) {
69: this .tag = tag;
70: this .creationOrder = creationOrderCount++;
71: }
72:
73: public abstract boolean equals(Object obj);
74:
75: public byte getTag() {
76: return tag;
77: }
78:
79: public int getDomain() {
80: return domain;
81: }
82:
83: public void setDomain(int newDomain) {
84: this .domain = newDomain;
85: }
86:
87: public abstract int hashCode();
88:
89: public void doWrite(DataOutputStream dos) throws IOException {
90: dos.writeByte(tag);
91: writeBody(dos);
92: }
93:
94: protected abstract void writeBody(DataOutputStream dos)
95: throws IOException;
96: }
|