package common.tags;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

class TagByte extends Tag {
	private byte data;

	TagByte() {
	}

	public TagByte(byte data) {
		this.data = data;
	}

	void write(DataOutput output) throws IOException {
		output.writeByte(this.data);
	}

	void read(DataInput input, int depth, SizeTracker tracker) throws IOException {
		tracker.read(9);
		this.data = input.readByte();
	}

	TagType getType() {
		return TagType.BYTE;
	}

	public String toString() {
		return "" + this.data + "b";
	}

	public Tag copy() {
		return new TagByte(this.data);
	}

	public boolean equals(Object other) {
		return super.equals(other) && this.data == ((TagByte)other).data;
	}

	public int hashCode() {
		return super.hashCode() ^ this.data;
	}

	public byte getByte() {
		return this.data;
	}
}
