package common.tags;

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

class TagInt extends Tag {
	private int data;

	TagInt() {
	}

	public TagInt(int data) {
		this.data = data;
	}

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

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

	TagType getType() {
		return TagType.INT;
	}

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

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

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

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

	public int getInt() {
		return this.data;
	}
}
