1 /*******************************************************************************
2  * Copyright (c) 2000, 2018 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.jdt.core.util;
15 
16 /**
17  * Description of a constant pool entry as described in the JVM specifications.
18  * Its contents is initialized according to its kind.
19  *
20  * This interface may be implemented by clients. Because of that questionable choice,
21  * clients may have to cast to {@link IConstantPoolEntry3} to get access to the relevant content.
22  *
23  * @see IConstantPoolEntry2
24  * @see IConstantPoolEntry3
25  * @since 2.0
26  */
27 public interface IConstantPoolEntry {
28 
29 	/**
30 	 * Returns the type of this entry.
31 	 *
32 	 * @return the type of this entry
33 	 */
getKind()34 	int getKind();
35 
36 	/**
37 	 * Returns the name index for a CONSTANT_Class type entry.
38 	 * The value is unspecified otherwise.
39 	 *
40 	 * @return the name index for a CONSTANT_Class type entry
41 	 * @see IConstantPoolConstant#CONSTANT_Class
42 	 */
getClassInfoNameIndex()43 	int getClassInfoNameIndex();
44 
45 	/**
46 	 * Returns the class index for a CONSTANT_Fieldref,
47 	 * CONSTANT_Methodref, CONSTANT_InterfaceMethodref type entry.
48 	 * The value is unspecified otherwise.
49 	 *
50 	 * @return the class index for a CONSTANT_Fieldref,
51 	 * CONSTANT_Methodref, CONSTANT_InterfaceMethodref type entry
52 	 * @see IConstantPoolConstant#CONSTANT_Fieldref
53 	 * @see IConstantPoolConstant#CONSTANT_Methodref
54 	 * @see IConstantPoolConstant#CONSTANT_InterfaceMethodref
55 	 */
getClassIndex()56 	int getClassIndex();
57 
58 	/**
59 	 * Returns the nameAndType index for a CONSTANT_Fieldref,
60 	 * CONSTANT_Methodref, CONSTANT_InterfaceMethodref,
61 	 * CONSTANT_InvokeDynamic type entry.
62 	 * The value is unspecified otherwise.
63 	 *
64 	 * @return the nameAndType index for a CONSTANT_Fieldref,
65 	 * CONSTANT_Methodref, CONSTANT_InterfaceMethodref,
66 	 * CONSTANT_InvokeDynamic type entry
67 	 * @see IConstantPoolConstant#CONSTANT_Fieldref
68 	 * @see IConstantPoolConstant#CONSTANT_Methodref
69 	 * @see IConstantPoolConstant#CONSTANT_InterfaceMethodref
70 	 * @see IConstantPoolConstant#CONSTANT_InvokeDynamic
71 	 * @see IConstantPoolConstant#CONSTANT_Dynamic
72 	 */
getNameAndTypeIndex()73 	int getNameAndTypeIndex();
74 
75 	/**
76 	 * Returns the string index for a CONSTANT_String type entry.
77 	 * The value is unspecified otherwise.
78 	 *
79 	 * @return the string index for a CONSTANT_String type entry
80 	 * @see IConstantPoolConstant#CONSTANT_String
81 	 */
getStringIndex()82 	int getStringIndex();
83 
84 	/**
85 	 * Returns the string value for a CONSTANT_String type entry.
86 	 * Returns null otherwise.
87 	 *
88 	 * @return the string value for a CONSTANT_String type entry
89 	 * @see IConstantPoolConstant#CONSTANT_String
90 	 */
getStringValue()91 	String getStringValue();
92 
93 	/**
94 	 * Returns the integer value for a CONSTANT_Integer type entry.
95 	 * The value is unspecified otherwise.
96 	 *
97 	 * @return the integer value for a CONSTANT_Integer type entry
98 	 * @see IConstantPoolConstant#CONSTANT_Integer
99 	 */
getIntegerValue()100 	int getIntegerValue();
101 
102 	/**
103 	 * Returns the float value for a CONSTANT_Float type entry.
104 	 * The value is unspecified otherwise.
105 	 *
106 	 * @return the float value for a CONSTANT_Float type entry
107 	 * @see IConstantPoolConstant#CONSTANT_Float
108 	 */
getFloatValue()109 	float getFloatValue();
110 
111 	/**
112 	 * Returns the double value for a CONSTANT_Double type entry.
113 	 * The value is unspecified otherwise.
114 	 *
115 	 * @return the double value for a CONSTANT_Double type entry
116 	 * @see IConstantPoolConstant#CONSTANT_Double
117 	 */
getDoubleValue()118 	double getDoubleValue();
119 
120 	/**
121 	 * Returns the long value for a CONSTANT_Long type entry.
122 	 * The value is unspecified otherwise.
123 	 *
124 	 * @return the long value for a CONSTANT_Long type entry
125 	 * @see IConstantPoolConstant#CONSTANT_Long
126 	 */
getLongValue()127 	long getLongValue();
128 
129 	/**
130 	 * Returns the descriptor index for a CONSTANT_NameAndType type entry.
131 	 * The value is unspecified otherwise.
132 	 *
133 	 * @return the descriptor index for a CONSTANT_NameAndType type entry
134 	 * @see IConstantPoolConstant#CONSTANT_NameAndType
135 	 */
getNameAndTypeInfoDescriptorIndex()136 	int getNameAndTypeInfoDescriptorIndex();
137 
138 	/**
139 	 * Returns the name index for a CONSTANT_NameAndType type entry.
140 	 * The value is unspecified otherwise.
141 	 *
142 	 * @return the name index for a CONSTANT_NameAndType type entry
143 	 * @see IConstantPoolConstant#CONSTANT_NameAndType
144 	 */
getNameAndTypeInfoNameIndex()145 	int getNameAndTypeInfoNameIndex();
146 
147 	/**
148 	 * Returns the class name for a CONSTANT_Class type entry.
149 	 * Returns null otherwise.
150 	 *
151 	 * @return the class name for a CONSTANT_Class type entry
152 	 * @see IConstantPoolConstant#CONSTANT_Class
153 	 */
getClassInfoName()154 	char[] getClassInfoName();
155 
156 	/**
157 	 * Returns the class name for a CONSTANT_Fieldref,
158 	 * CONSTANT_Methodref, CONSTANT_InterfaceMethodref type entry.
159 	 * Returns null otherwise.
160 	 *
161 	 * @return the class name for a CONSTANT_Fieldref,
162 	 * CONSTANT_Methodref, CONSTANT_InterfaceMethodref type entry
163 	 * @see IConstantPoolConstant#CONSTANT_Fieldref
164 	 * @see IConstantPoolConstant#CONSTANT_Methodref
165 	 * @see IConstantPoolConstant#CONSTANT_InterfaceMethodref
166 	 */
getClassName()167 	char[] getClassName();
168 
169 	/**
170 	 * Returns the field name for a CONSTANT_Fieldref type entry.
171 	 * Returns null otherwise.
172 	 *
173 	 * @return the field name for a CONSTANT_Fieldref type entry
174 	 * @see IConstantPoolConstant#CONSTANT_Fieldref
175 	 */
getFieldName()176 	char[] getFieldName();
177 
178 	/**
179 	 * Returns the method name for a CONSTANT_Methodref, CONSTANT_InterfaceMethodref
180 	 * or CONSTANT_InvokeDynamic type entry.
181 	 * Returns null otherwise.
182 	 *
183 	 * @return the method name for a CONSTANT_Methodref, CONSTANT_InterfaceMethodref
184 	 * or CONSTANT_InvokeDynamic type entry
185 	 * @see IConstantPoolConstant#CONSTANT_Methodref
186 	 * @see IConstantPoolConstant#CONSTANT_InterfaceMethodref
187 	 * @see IConstantPoolConstant#CONSTANT_InvokeDynamic
188 	 * @see IConstantPoolConstant#CONSTANT_Dynamic
189 	 */
getMethodName()190 	char[] getMethodName();
191 
192 	/**
193 	 * Returns the field descriptor value for a CONSTANT_Fieldref type entry. This value
194 	 * is set only when decoding the CONSTANT_Fieldref entry.
195 	 * Returns null otherwise.
196 	 *
197 	 * @return the field descriptor value for a CONSTANT_Fieldref type entry. This value
198 	 * is set only when decoding the CONSTANT_Fieldref entry
199 	 * @see IConstantPoolConstant#CONSTANT_Fieldref
200 	 */
getFieldDescriptor()201 	char[] getFieldDescriptor();
202 
203 	/**
204 	 * Returns the method descriptor value for a CONSTANT_Methodref or
205 	 * CONSTANT_InterfaceMethodref type entry. This value is set only when decoding the
206 	 * CONSTANT_Methodref, CONSTANT_InterfaceMethodref, CONSTANT_MethodType
207 	 * or CONSTANT_InvokeDynamic entry.
208 	 *
209 	 * Returns null otherwise.
210 	 *
211 	 * @return the method descriptor value for a CONSTANT_Methodref,
212 	 * CONSTANT_InterfaceMethodref type entry. This value is set only when decoding the
213 	 * CONSTANT_Methodref, CONSTANT_InterfaceMethodref, CONSTANT_MethodType
214 	 * or CONSTANT_InvokeDynamic entry
215 	 *
216 	 * @see IConstantPoolConstant#CONSTANT_Methodref
217 	 * @see IConstantPoolConstant#CONSTANT_InterfaceMethodref
218 	 * @see IConstantPoolConstant#CONSTANT_MethodType
219 	 * @see IConstantPoolConstant#CONSTANT_InvokeDynamic
220 	 * @see IConstantPoolConstant#CONSTANT_Dynamic
221 	 */
getMethodDescriptor()222 	char[] getMethodDescriptor();
223 
224 	/**
225 	 * Returns the utf8 value for a CONSTANT_Utf8 type entry. This value is set only when
226 	 * decoding a UTF8 entry.
227 	 * Returns null otherwise.
228 	 *
229 	 * @return the utf8 value for a CONSTANT_Utf8 type entry. This value is set only when
230 	 * decoding a UTF8 entry
231 	 * @see IConstantPoolConstant#CONSTANT_Utf8
232 	 */
getUtf8Value()233 	char[] getUtf8Value();
234 
235 	/**
236 	 * Returns the utf8 length for a CONSTANT_Utf8 type entry. This value is set only when
237 	 * decoding a UTF8 entry.
238 	 * Returns null otherwise.
239 	 *
240 	 * @return the utf8 length for a CONSTANT_Utf8 type entry. This value is set only when
241 	 * decoding a UTF8 entry
242 	 * @see IConstantPoolConstant#CONSTANT_Utf8
243 	 */
getUtf8Length()244 	int getUtf8Length();
245 }
246