KickJava   Java API By Example, From Geeks To Geeks.

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


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.IInnerClassesAttributeEntry;
18
19 /**
20  * Default implementation of IInnerClassesAttributeEntry
21  */

22 public class InnerClassesAttributeEntry
23     extends ClassFileStruct
24     implements IInnerClassesAttributeEntry {
25
26     private int innerClassNameIndex;
27     private int outerClassNameIndex;
28     private int innerNameIndex;
29     private char[] innerClassName;
30     private char[] outerClassName;
31     private char[] innerName;
32     private int accessFlags;
33
34     public InnerClassesAttributeEntry(byte classFileBytes[], IConstantPool constantPool, int offset)
35         throws ClassFormatException {
36         this.innerClassNameIndex = u2At(classFileBytes, 0, offset);
37         this.outerClassNameIndex = u2At(classFileBytes, 2, offset);
38         this.innerNameIndex = u2At(classFileBytes, 4, offset);
39         this.accessFlags = u2At(classFileBytes, 6, offset);
40         IConstantPoolEntry constantPoolEntry;
41         if (this.innerClassNameIndex != 0) {
42             constantPoolEntry = constantPool.decodeEntry(this.innerClassNameIndex);
43             if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
44                 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
45             }
46             this.innerClassName = constantPoolEntry.getClassInfoName();
47         }
48         if (outerClassNameIndex != 0) {
49             constantPoolEntry = constantPool.decodeEntry(this.outerClassNameIndex);
50             if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
51                 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
52             }
53             this.outerClassName = constantPoolEntry.getClassInfoName();
54         }
55         if (innerNameIndex != 0) {
56             constantPoolEntry = constantPool.decodeEntry(this.innerNameIndex);
57             if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
58                 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
59             }
60             this.innerName = constantPoolEntry.getUtf8Value();
61         }
62     }
63
64     /**
65      * @see IInnerClassesAttributeEntry#getAccessFlags()
66      */

67     public int getAccessFlags() {
68         return this.accessFlags;
69     }
70
71     /**
72      * @see IInnerClassesAttributeEntry#getInnerClassName()
73      */

74     public char[] getInnerClassName() {
75         return this.innerClassName;
76     }
77
78     /**
79      * @see IInnerClassesAttributeEntry#getInnerClassNameIndex()
80      */

81     public int getInnerClassNameIndex() {
82         return this.innerClassNameIndex;
83     }
84
85     /**
86      * @see IInnerClassesAttributeEntry#getInnerName()
87      */

88     public char[] getInnerName() {
89         return this.innerName;
90     }
91
92     /**
93      * @see IInnerClassesAttributeEntry#getInnerNameIndex()
94      */

95     public int getInnerNameIndex() {
96         return this.innerNameIndex;
97     }
98
99     /**
100      * @see IInnerClassesAttributeEntry#getOuterClassName()
101      */

102     public char[] getOuterClassName() {
103         return this.outerClassName;
104     }
105
106     /**
107      * @see IInnerClassesAttributeEntry#getOuterClassNameIndex()
108      */

109     public int getOuterClassNameIndex() {
110         return this.outerClassNameIndex;
111     }
112 }
113
Popular Tags