KickJava   Java API By Example, From Geeks To Geeks.

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


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.ISignatureAttribute;
18
19 /**
20  * @since 3.0
21  */

22 public class SignatureAttribute extends ClassFileAttribute implements ISignatureAttribute {
23     
24     private int signatureIndex;
25     private char[] signature;
26     
27     SignatureAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException {
28         super(classFileBytes, constantPool, offset);
29         final int index = u2At(classFileBytes, 6, offset);
30         this.signatureIndex = index;
31         IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(index);
32         if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
33             throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
34         }
35         this.signature = constantPoolEntry.getUtf8Value();
36     }
37     /* (non-Javadoc)
38      * @see org.eclipse.jdt.core.util.ISignatureAttribute#getSignatureIndex()
39      */

40     public int getSignatureIndex() {
41         return this.signatureIndex;
42     }
43     /* (non-Javadoc)
44      * @see org.eclipse.jdt.core.util.ISignatureAttribute#getSignature()
45      */

46     public char[] getSignature() {
47         return this.signature;
48     }
49 }
50
Popular Tags