001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.internal.core.util;
011:
012: import org.eclipse.jdt.core.util.ClassFormatException;
013: import org.eclipse.jdt.core.util.IConstantPool;
014: import org.eclipse.jdt.core.util.IConstantPoolConstant;
015: import org.eclipse.jdt.core.util.IConstantPoolEntry;
016: import org.eclipse.jdt.core.util.ILocalVariableTypeTableEntry;
017:
018: /**
019: * Default implementation of ILocalVariableTypeTableEntry
020: */
021: public class LocalVariableTypeTableEntry extends ClassFileStruct
022: implements ILocalVariableTypeTableEntry {
023:
024: private int startPC;
025: private int length;
026: private int nameIndex;
027: private int signatureIndex;
028: private char[] name;
029: private char[] signature;
030: private int index;
031:
032: /**
033: * Constructor for LocalVariableTypeTableEntry.
034: *
035: * @param classFileBytes
036: * @param constantPool
037: * @param offset
038: * @throws ClassFormatException
039: */
040: public LocalVariableTypeTableEntry(byte[] classFileBytes,
041: IConstantPool constantPool, int offset)
042: throws ClassFormatException {
043: this .startPC = u2At(classFileBytes, 0, offset);
044: this .length = u2At(classFileBytes, 2, offset);
045: this .nameIndex = u2At(classFileBytes, 4, offset);
046: this .signatureIndex = u2At(classFileBytes, 6, offset);
047: this .index = u2At(classFileBytes, 8, offset);
048: IConstantPoolEntry constantPoolEntry = constantPool
049: .decodeEntry(this .nameIndex);
050: if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
051: throw new ClassFormatException(
052: ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
053: }
054: this .name = constantPoolEntry.getUtf8Value();
055: constantPoolEntry = constantPool
056: .decodeEntry(this .signatureIndex);
057: if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
058: throw new ClassFormatException(
059: ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
060: }
061: this .signature = constantPoolEntry.getUtf8Value();
062: }
063:
064: /**
065: * @see ILocalVariableTypeTableEntry#getStartPC()
066: */
067: public int getStartPC() {
068: return this .startPC;
069: }
070:
071: /**
072: * @see ILocalVariableTypeTableEntry#getLength()
073: */
074: public int getLength() {
075: return this .length;
076: }
077:
078: /**
079: * @see ILocalVariableTypeTableEntry#getNameIndex()
080: */
081: public int getNameIndex() {
082: return this .nameIndex;
083: }
084:
085: /**
086: * @see ILocalVariableTypeTableEntry#getSignatureIndex()
087: */
088: public int getSignatureIndex() {
089: return this .signatureIndex;
090: }
091:
092: /**
093: * @see ILocalVariableTypeTableEntry#getIndex()
094: */
095: public int getIndex() {
096: return this .index;
097: }
098:
099: /**
100: * @see ILocalVariableTypeTableEntry#getName()
101: */
102: public char[] getName() {
103: return this .name;
104: }
105:
106: /**
107: * @see ILocalVariableTypeTableEntry#getSignature()
108: */
109: public char[] getSignature() {
110: return this.signature;
111: }
112:
113: }
|