|
1 /* |
|
2 * reserved comment block |
|
3 * DO NOT REMOVE OR ALTER! |
|
4 */ |
|
5 /* |
|
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
7 * contributor license agreements. See the NOTICE file distributed with |
|
8 * this work for additional information regarding copyright ownership. |
|
9 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
10 * (the "License"); you may not use this file except in compliance with |
|
11 * the License. You may obtain a copy of the License at |
|
12 * |
|
13 * http://www.apache.org/licenses/LICENSE-2.0 |
|
14 * |
|
15 * Unless required by applicable law or agreed to in writing, software |
|
16 * distributed under the License is distributed on an "AS IS" BASIS, |
|
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 * See the License for the specific language governing permissions and |
|
19 * limitations under the License. |
|
20 */ |
|
21 |
|
22 package com.sun.org.apache.bcel.internal.classfile; |
|
23 |
|
24 import java.io.DataOutputStream; |
|
25 import java.io.IOException; |
|
26 |
|
27 import com.sun.org.apache.bcel.internal.Const; |
|
28 |
|
29 /** |
|
30 * @since 6.0 |
|
31 */ |
|
32 public class ClassElementValue extends ElementValue |
|
33 { |
|
34 // For primitive types and string type, this points to the value entry in |
|
35 // the cpool |
|
36 // For 'class' this points to the class entry in the cpool |
|
37 private final int idx; |
|
38 |
|
39 public ClassElementValue(final int type, final int idx, final ConstantPool cpool) |
|
40 { |
|
41 super(type, cpool); |
|
42 this.idx = idx; |
|
43 } |
|
44 |
|
45 public int getIndex() |
|
46 { |
|
47 return idx; |
|
48 } |
|
49 |
|
50 public String getClassString() |
|
51 { |
|
52 final ConstantUtf8 c = (ConstantUtf8) super.getConstantPool().getConstant(idx, |
|
53 Const.CONSTANT_Utf8); |
|
54 return c.getBytes(); |
|
55 } |
|
56 |
|
57 @Override |
|
58 public String stringifyValue() |
|
59 { |
|
60 final ConstantUtf8 cu8 = (ConstantUtf8) super.getConstantPool().getConstant(idx, |
|
61 Const.CONSTANT_Utf8); |
|
62 return cu8.getBytes(); |
|
63 } |
|
64 |
|
65 @Override |
|
66 public void dump(final DataOutputStream dos) throws IOException |
|
67 { |
|
68 dos.writeByte(super.getType()); // u1 kind of value |
|
69 dos.writeShort(idx); |
|
70 } |
|
71 } |