KickJava   Java API By Example, From Geeks To Geeks.

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


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

21 public class InnerClassesAttribute extends ClassFileAttribute implements IInnerClassesAttribute {
22     private static final IInnerClassesAttributeEntry[] NO_ENTRIES = new IInnerClassesAttributeEntry[0];
23
24     private int numberOfClasses;
25     private IInnerClassesAttributeEntry[] entries;
26     /**
27      * Constructor for InnerClassesAttribute.
28      * @param classFileBytes
29      * @param constantPool
30      * @param offset
31      * @throws ClassFormatException
32      */

33     public InnerClassesAttribute(
34         byte[] classFileBytes,
35         IConstantPool constantPool,
36         int offset)
37         throws ClassFormatException {
38         super(classFileBytes, constantPool, offset);
39         this.numberOfClasses = u2At(classFileBytes, 6, offset);
40         final int length = this.numberOfClasses;
41         if (length != 0) {
42             int readOffset = 8;
43             this.entries = new IInnerClassesAttributeEntry[length];
44             for (int i = 0; i < length; i++) {
45                 this.entries[i] = new InnerClassesAttributeEntry(classFileBytes, constantPool, offset + readOffset);
46                 readOffset += 8;
47             }
48         } else {
49             this.entries = NO_ENTRIES;
50         }
51     }
52
53     /**
54      * @see IInnerClassesAttribute#getInnerClassAttributesEntries()
55      */

56     public IInnerClassesAttributeEntry[] getInnerClassAttributesEntries() {
57         return this.entries;
58     }
59
60     /**
61      * @see IInnerClassesAttribute#getNumberOfClasses()
62      */

63     public int getNumberOfClasses() {
64         return this.numberOfClasses;
65     }
66
67 }
68
Popular Tags