package org.eclipse.jdt.internal.compiler.classfmt;
import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
public class InnerClassInfo extends ClassFileStruct implements IBinaryNestedType {
int innerClassNameIndex = -1;
int outerClassNameIndex = -1;
int innerNameIndex = -1;
private char[] innerClassName;
private char[] outerClassName;
private char[] innerName;
private int accessFlags = -1;
private boolean readInnerClassName;
private boolean readOuterClassName;
private boolean readInnerName;
public InnerClassInfo(byte classFileBytes[], int offsets[], int offset) {
super(classFileBytes, offsets, offset);
this.innerClassNameIndex = u2At(0);
this.outerClassNameIndex = u2At(2);
this.innerNameIndex = u2At(4);
}
@Override
public char[] getEnclosingTypeName() {
if (!this.readOuterClassName) {
if (this.outerClassNameIndex != 0) {
int utf8Offset =
this.constantPoolOffsets[u2At(
this.constantPoolOffsets[this.outerClassNameIndex] - this.structOffset + 1)]
- this.structOffset;
this.outerClassName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
}
this.readOuterClassName = true;
}
return this.outerClassName;
}
@Override
public int getModifiers() {
if (this.accessFlags == -1) {
this.accessFlags = u2At(6);
}
return this.accessFlags;
}
@Override
public char[] getName() {
if (!this.readInnerClassName) {
if (this.innerClassNameIndex != 0) {
int classOffset = this.constantPoolOffsets[this.innerClassNameIndex] - this.structOffset;
int utf8Offset = this.constantPoolOffsets[u2At(classOffset + 1)] - this.structOffset;
this.innerClassName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
}
this.readInnerClassName = true;
}
return this.innerClassName;
}
public char[] getSourceName() {
if (!this.readInnerName) {
if (this.innerNameIndex != 0) {
int utf8Offset = this.constantPoolOffsets[this.innerNameIndex] - this.structOffset;
this.innerName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
}
this.readInnerName = true;
}
return this.innerName;
}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
if (getName() != null) {
buffer.append(getName());
}
buffer.append("\n");
if (getEnclosingTypeName() != null) {
buffer.append(getEnclosingTypeName());
}
buffer.append("\n");
if (getSourceName() != null) {
buffer.append(getSourceName());
}
return buffer.toString();
}
void initialize() {
getModifiers();
getName();
getSourceName();
getEnclosingTypeName();
reset();
}
}