1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.bcel.classfile;
18
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21
22
23
24
25
26
27 public class ElementValuePair {
28
29 static final ElementValuePair[] EMPTY_ARRAY = {};
30
31 private final ElementValue elementValue;
32
33 private final ConstantPool constantPool;
34
35 private final int elementNameIndex;
36
37 public ElementValuePair(final int elementNameIndex, final ElementValue elementValue, final ConstantPool constantPool) {
38 this.elementValue = elementValue;
39 this.elementNameIndex = elementNameIndex;
40 this.constantPool = constantPool;
41 }
42
43 protected void dump(final DataOutputStream dos) throws IOException {
44 dos.writeShort(elementNameIndex);
45 elementValue.dump(dos);
46 }
47
48 public int getNameIndex() {
49 return elementNameIndex;
50 }
51
52 public String getNameString() {
53 return constantPool.getConstantUtf8(elementNameIndex).getBytes();
54 }
55
56 public final ElementValue getValue() {
57 return elementValue;
58 }
59
60 public String toShortString() {
61 final StringBuilder result = new StringBuilder();
62 result.append(getNameString()).append("=").append(getValue().toShortString());
63 return result.toString();
64 }
65 }