KickJava   Java API By Example, From Geeks To Geeks.

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


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.IConstantPoolConstant;
16 import org.eclipse.jdt.core.util.IConstantPoolEntry;
17 import org.eclipse.jdt.core.util.ILocalVariableTableEntry;
18
19 /**
20  * Default implementation of ILocalVariableTableEntry
21  */

22 public class LocalVariableTableEntry extends ClassFileStruct implements ILocalVariableTableEntry {
23
24     private int startPC;
25     private int length;
26     private int nameIndex;
27     private int descriptorIndex;
28     private char[] name;
29     private char[] descriptor;
30     private int index;
31     
32     /**
33      * Constructor for LocalVariableTableEntry.
34      *
35      * @param classFileBytes
36      * @param constantPool
37      * @param offset
38      * @throws ClassFormatException
39      */

40     public LocalVariableTableEntry(
41         byte[] classFileBytes,
42         IConstantPool constantPool,
43         int offset) throws ClassFormatException {
44             this.startPC = u2At(classFileBytes, 0, offset);
45             this.length = u2At(classFileBytes, 2, offset);
46             this.nameIndex = u2At(classFileBytes, 4, offset);
47             this.descriptorIndex = u2At(classFileBytes, 6, offset);
48             this.index = u2At(classFileBytes, 8, offset);
49             IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(this.nameIndex);
50             if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
51                 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
52             }
53             this.name = constantPoolEntry.getUtf8Value();
54             constantPoolEntry = constantPool.decodeEntry(this.descriptorIndex);
55             if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
56                 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
57             }
58             this.descriptor = constantPoolEntry.getUtf8Value();
59         }
60         
61     /**
62      * @see ILocalVariableTableEntry#getStartPC()
63      */

64     public int getStartPC() {
65         return this.startPC;
66     }
67
68     /**
69      * @see ILocalVariableTableEntry#getLength()
70      */

71     public int getLength() {
72         return this.length;
73     }
74
75     /**
76      * @see ILocalVariableTableEntry#getNameIndex()
77      */

78     public int getNameIndex() {
79         return this.nameIndex;
80     }
81
82     /**
83      * @see ILocalVariableTableEntry#getDescriptorIndex()
84      */

85     public int getDescriptorIndex() {
86         return this.descriptorIndex;
87     }
88
89     /**
90      * @see ILocalVariableTableEntry#getIndex()
91      */

92     public int getIndex() {
93         return this.index;
94     }
95
96     /**
97      * @see ILocalVariableTableEntry#getName()
98      */

99     public char[] getName() {
100         return this.name;
101     }
102
103     /**
104      * @see ILocalVariableTableEntry#getDescriptor()
105      */

106     public char[] getDescriptor() {
107         return this.descriptor;
108     }
109
110 }
111
Popular Tags