|
|
@ -28,25 +28,31 @@ public class AttributeInfo { |
|
|
|
String name; |
|
|
|
String name; |
|
|
|
byte[] data; |
|
|
|
byte[] data; |
|
|
|
|
|
|
|
|
|
|
|
public AttributeInfo() { |
|
|
|
public AttributeInfo(String name) { |
|
|
|
|
|
|
|
this.name = name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AttributeInfo(String name, byte[] data) { |
|
|
|
|
|
|
|
this.name = name; |
|
|
|
|
|
|
|
this.data = data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void read(ConstantPool constantPool, |
|
|
|
public void read(ConstantPool constantPool, |
|
|
|
DataInputStream input, int howMuch) throws IOException { |
|
|
|
DataInputStream input, int howMuch) throws IOException { |
|
|
|
String attrName = constantPool.getUTF8(input.readUnsignedShort()); |
|
|
|
|
|
|
|
int length = input.readInt(); |
|
|
|
int length = input.readInt(); |
|
|
|
if ((howMuch & ClassInfo.ALL_ATTRIBUTES) != 0) { |
|
|
|
data = new byte[length]; |
|
|
|
name = attrName; |
|
|
|
input.readFully(data); |
|
|
|
data = new byte[length]; |
|
|
|
} |
|
|
|
input.readFully(data); |
|
|
|
|
|
|
|
} else { |
|
|
|
public void prepareWriting(GrowableConstantPool gcp) { |
|
|
|
while (length > 0) { |
|
|
|
gcp.putUTF8(name); |
|
|
|
int skipped = (int) input.skip(length); |
|
|
|
} |
|
|
|
if (skipped == 0) |
|
|
|
|
|
|
|
throw new EOFException("Can't skip. EOF?"); |
|
|
|
public void write(GrowableConstantPool constantPool, |
|
|
|
length -= skipped; |
|
|
|
DataOutputStream output) throws IOException { |
|
|
|
} |
|
|
|
output.writeShort(constantPool.putUTF8(name)); |
|
|
|
} |
|
|
|
output.writeInt(data.length); |
|
|
|
|
|
|
|
output.write(data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getName() { |
|
|
|
public String getName() { |
|
|
@ -86,4 +92,13 @@ public class AttributeInfo { |
|
|
|
writer.println("*/"); |
|
|
|
writer.println("*/"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean equals(Object o) { |
|
|
|
|
|
|
|
return (o instanceof AttributeInfo |
|
|
|
|
|
|
|
&& ((AttributeInfo) o).name.equals(name)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int hashCode() { |
|
|
|
|
|
|
|
return name.hashCode(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|