Files
runelite/src/main/java/info/sigterm/deob/attributes/Attribute.java
2015-05-09 17:00:30 -04:00

50 lines
975 B
Java

package info.sigterm.deob.attributes;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public abstract class Attribute
{
private Attributes attributes;
private AttributeType type;
private int length;
Attribute(Attributes attr, AttributeType type) throws IOException
{
this.attributes = attr;
this.type = type;
DataInputStream is = attr.getStream();
this.length = is.readInt();
}
public final void write(DataOutputStream out) throws IOException
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
writeAttr(new DataOutputStream(bout));
byte[] b = bout.toByteArray();
out.writeInt(b.length);
out.write(b);
}
public abstract void writeAttr(DataOutputStream out) throws IOException;
public Attributes getAttributes()
{
return attributes;
}
public AttributeType getType()
{
return type;
}
public int getLength()
{
return length;
}
}