01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.core.util;
11:
12: import org.eclipse.jdt.core.util.ClassFormatException;
13: import org.eclipse.jdt.core.util.IConstantPool;
14: import org.eclipse.jdt.core.util.IConstantPoolEntry;
15: import org.eclipse.jdt.core.util.IConstantValueAttribute;
16:
17: /**
18: * Default implementation of IConstantValueAttribute.
19: */
20: public class ConstantValueAttribute extends ClassFileAttribute
21: implements IConstantValueAttribute {
22:
23: private int constantValueIndex;
24: private IConstantPoolEntry constantPoolEntry;
25:
26: ConstantValueAttribute(byte[] classFileBytes,
27: IConstantPool constantPool, int offset)
28: throws ClassFormatException {
29: super (classFileBytes, constantPool, offset);
30: this .constantValueIndex = u2At(classFileBytes, 6, offset);
31: this .constantPoolEntry = constantPool
32: .decodeEntry(this .constantValueIndex);
33: }
34:
35: /**
36: * @see IConstantValueAttribute#getConstantValue()
37: */
38: public IConstantPoolEntry getConstantValue() {
39: return this .constantPoolEntry;
40: }
41:
42: /**
43: * @see IConstantValueAttribute#getConstantValueIndex()
44: */
45: public int getConstantValueIndex() {
46: return this.constantValueIndex;
47: }
48: }
|