package common.tags;

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

class TagShort extends Tag {
	private short data;

	TagShort() {
	}

	public TagShort(short data) {
		this.data = data;
	}

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

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

	TagType getType() {
		return TagType.SHORT;
	}

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

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

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

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

	public short getShort() {
		return this.data;
	}
}
