46174
|
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 |
* an annotation's element value pair
|
|
31 |
*
|
|
32 |
* @version $Id: ElementValuePair
|
|
33 |
* @since 6.0
|
|
34 |
*/
|
|
35 |
public class ElementValuePair
|
|
36 |
{
|
|
37 |
private final ElementValue elementValue;
|
|
38 |
|
|
39 |
private final ConstantPool constantPool;
|
|
40 |
|
|
41 |
private final int elementNameIndex;
|
|
42 |
|
|
43 |
public ElementValuePair(final int elementNameIndex, final ElementValue elementValue,
|
|
44 |
final ConstantPool constantPool)
|
|
45 |
{
|
|
46 |
this.elementValue = elementValue;
|
|
47 |
this.elementNameIndex = elementNameIndex;
|
|
48 |
this.constantPool = constantPool;
|
|
49 |
}
|
|
50 |
|
|
51 |
public String getNameString()
|
|
52 |
{
|
|
53 |
final ConstantUtf8 c = (ConstantUtf8) constantPool.getConstant(
|
|
54 |
elementNameIndex, Const.CONSTANT_Utf8);
|
|
55 |
return c.getBytes();
|
|
56 |
}
|
|
57 |
|
|
58 |
public final ElementValue getValue()
|
|
59 |
{
|
|
60 |
return elementValue;
|
|
61 |
}
|
|
62 |
|
|
63 |
public int getNameIndex()
|
|
64 |
{
|
|
65 |
return elementNameIndex;
|
|
66 |
}
|
|
67 |
|
|
68 |
public String toShortString()
|
|
69 |
{
|
|
70 |
final StringBuilder result = new StringBuilder();
|
|
71 |
result.append(getNameString()).append("=").append(
|
|
72 |
getValue().toShortString());
|
|
73 |
return result.toString();
|
|
74 |
}
|
|
75 |
|
|
76 |
protected void dump(final DataOutputStream dos) throws IOException {
|
|
77 |
dos.writeShort(elementNameIndex); // u2 name of the element
|
|
78 |
elementValue.dump(dos);
|
|
79 |
}
|
|
80 |
}
|