1 7 8 package org.gjt.jclasslib.structures.attributes; 9 10 import org.gjt.jclasslib.structures.*; 11 12 import java.io.*; 13 14 20 public class InnerClassesEntry extends AbstractStructure 21 implements AccessFlags { 22 23 26 public static final int LENGTH = 8; 27 28 private int innerClassInfoIndex; 29 private int outerClassInfoIndex; 30 private int innerNameIndex; 31 private int innerClassAccessFlags; 32 33 43 public static InnerClassesEntry create(DataInput in, ClassFile classFile) 44 throws InvalidByteCodeException, IOException { 45 46 InnerClassesEntry innerClassesEntry = new InnerClassesEntry(); 47 innerClassesEntry.setClassFile(classFile); 48 innerClassesEntry.read(in); 49 50 return innerClassesEntry; 51 } 52 53 59 public int getInnerClassInfoIndex() { 60 return innerClassInfoIndex; 61 } 62 63 69 public void setInnerClassInfoIndex(int innerClassInfoIndex) { 70 this.innerClassInfoIndex = innerClassInfoIndex; 71 } 72 73 79 public int getOuterClassInfoIndex() { 80 return outerClassInfoIndex; 81 } 82 83 89 public void setOuterClassInfoIndex(int outerClassInfoIndex) { 90 this.outerClassInfoIndex = outerClassInfoIndex; 91 } 92 93 99 public int getInnerNameIndex() { 100 return innerNameIndex; 101 } 102 103 109 public void setInnerNameIndex(int innerNameIndex) { 110 this.innerNameIndex = innerNameIndex; 111 } 112 113 118 public int getInnerClassAccessFlags() { 119 return innerClassAccessFlags; 120 } 121 122 127 public void setInnerClassAccessFlags(int innerClassAccessFlags) { 128 this.innerClassAccessFlags = innerClassAccessFlags; 129 } 130 131 136 public String getInnerClassFormattedAccessFlags() { 137 return printAccessFlags(innerClassAccessFlags); 138 } 139 140 145 public String getInnerClassAccessFlagsVerbose() { 146 return printAccessFlagsVerbose(innerClassAccessFlags); 147 } 148 149 public void read(DataInput in) 150 throws InvalidByteCodeException, IOException { 151 152 innerClassInfoIndex = in.readUnsignedShort(); 153 outerClassInfoIndex = in.readUnsignedShort(); 154 innerNameIndex = in.readUnsignedShort(); 155 innerClassAccessFlags = in.readUnsignedShort(); 156 157 if (debug) debug("read "); 158 } 159 160 public void write(DataOutput out) 161 throws InvalidByteCodeException, IOException { 162 163 super.write(out); 164 out.writeShort(innerClassInfoIndex); 165 out.writeShort(outerClassInfoIndex); 166 out.writeShort(innerNameIndex); 167 out.writeShort(innerClassAccessFlags); 168 if (debug) debug("wrote "); 169 } 170 171 protected void debug(String message) { 172 super.debug(message + "InnerClasses entry with inner_class_info_index " + innerClassInfoIndex + 173 ", outer_class_info_index " + outerClassInfoIndex + ", inner_name_index " + innerNameIndex + 174 ", access flags " + printAccessFlags(innerClassAccessFlags)); 175 } 176 177 protected String printAccessFlagsVerbose(int accessFlags) { 178 return printAccessFlagsVerbose(AccessFlags.INNER_CLASS_ACCESS_FLAGS, 179 AccessFlags.INNER_CLASS_ACCESS_FLAGS_VERBOSE, accessFlags); 180 } 181 182 } 183 | Popular Tags |