KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > util > ConstantValueAttribute


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core.util;
12
13 import org.eclipse.jdt.core.util.ClassFormatException;
14 import org.eclipse.jdt.core.util.IConstantPool;
15 import org.eclipse.jdt.core.util.IConstantPoolEntry;
16 import org.eclipse.jdt.core.util.IConstantValueAttribute;
17
18 /**
19  * Default implementation of IConstantValueAttribute.
20  */

21 public class ConstantValueAttribute
22     extends ClassFileAttribute
23     implements IConstantValueAttribute {
24     
25     private int constantValueIndex;
26     private IConstantPoolEntry constantPoolEntry;
27
28     
29     ConstantValueAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException {
30         super(classFileBytes, constantPool, offset);
31         this.constantValueIndex = u2At(classFileBytes, 6, offset);
32         this.constantPoolEntry = constantPool.decodeEntry(this.constantValueIndex);
33     }
34     /**
35      * @see IConstantValueAttribute#getConstantValue()
36      */

37     public IConstantPoolEntry getConstantValue() {
38         return this.constantPoolEntry;
39     }
40
41     /**
42      * @see IConstantValueAttribute#getConstantValueIndex()
43      */

44     public int getConstantValueIndex() {
45         return this.constantValueIndex;
46     }
47 }
48
Popular Tags