org.teatrove.trove.classfile.InnerClassesAttr Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of trove Show documentation
Show all versions of trove Show documentation
Utility methods in use through-out Tea development.
The newest version!
/*
* Copyright 1997-2011 teatrove.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.teatrove.trove.classfile;
import java.util.*;
import java.io.*;
/**
* This class corresponds to the InnerClasses_attribute structure introduced in
* JDK1.1. It is not defined in the first edition of
* The Java Virual Machine Specification.
*
* @author Brian S O'Neill
*/
class InnerClassesAttr extends Attribute {
private List mInnerClasses = new ArrayList();
public InnerClassesAttr(ConstantPool cp) {
super(cp, INNER_CLASSES);
}
/**
* @param inner The full inner class name
* @param outer The full outer class name
* @param name The simple name of the inner class, or null if anonymous
* @param modifiers Modifiers for the inner class
*/
public void addInnerClass(String inner,
String outer,
String name,
Modifiers modifiers) {
ConstantClassInfo innerInfo = ConstantClassInfo.make(mCp, inner);
ConstantClassInfo outerInfo;
if (outer == null) {
outerInfo = null;
}
else {
outerInfo = ConstantClassInfo.make(mCp, outer);
}
ConstantUTFInfo nameInfo;
if (name == null) {
nameInfo = null;
}
else {
nameInfo = ConstantUTFInfo.make(mCp, name);
}
mInnerClasses.add(new Info(innerInfo, outerInfo, nameInfo,
modifiers.getModifier()));
}
public Info[] getInnerClassesInfo() {
Info[] infos = new Info[mInnerClasses.size()];
return (Info[])mInnerClasses.toArray(infos);
}
public int getLength() {
return 2 + 8 * mInnerClasses.size();
}
public void writeDataTo(DataOutput dout) throws IOException {
int size = mInnerClasses.size();
dout.writeShort(size);
for (int i=0; i