KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.ILocalVariableTypeTableAttribute;
16 import org.eclipse.jdt.core.util.ILocalVariableTypeTableEntry;
17
18 /**
19  * Default implementation of ILocalVariableTypeAttribute.
20  */

21 public class LocalVariableTypeAttribute
22     extends ClassFileAttribute
23     implements ILocalVariableTypeTableAttribute {
24
25     private static final ILocalVariableTypeTableEntry[] NO_ENTRIES = new ILocalVariableTypeTableEntry[0];
26     private int localVariableTypeTableLength;
27     private ILocalVariableTypeTableEntry[] localVariableTypeTableEntries;
28     
29     /**
30      * Constructor for LocalVariableTypeAttribute.
31      * @param classFileBytes
32      * @param constantPool
33      * @param offset
34      * @throws ClassFormatException
35      */

36     public LocalVariableTypeAttribute(
37         byte[] classFileBytes,
38         IConstantPool constantPool,
39         int offset)
40         throws ClassFormatException {
41         super(classFileBytes, constantPool, offset);
42         final int length = u2At(classFileBytes, 6, offset);
43         this.localVariableTypeTableLength = length;
44         if (length != 0) {
45             int readOffset = 8;
46             this.localVariableTypeTableEntries = new ILocalVariableTypeTableEntry[length];
47             for (int i = 0; i < length; i++) {
48                 this.localVariableTypeTableEntries[i] = new LocalVariableTypeTableEntry(classFileBytes, constantPool, offset + readOffset);
49                 readOffset += 10;
50             }
51         } else {
52             this.localVariableTypeTableEntries = NO_ENTRIES;
53         }
54     }
55     /**
56      * @see ILocalVariableTypeTableAttribute#getLocalVariableTypeTable()
57      */

58     public ILocalVariableTypeTableEntry[] getLocalVariableTypeTable() {
59         return this.localVariableTypeTableEntries;
60     }
61
62     /**
63      * @see ILocalVariableTypeTableAttribute#getLocalVariableTypeTableLength()
64      */

65     public int getLocalVariableTypeTableLength() {
66         return this.localVariableTypeTableLength;
67     }
68 }
69
Popular Tags