package common.tags;

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

class TagBool extends Tag {
	private boolean data;

	TagBool() {
	}

	public TagBool(boolean data) {
		this.data = data;
	}

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

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

	TagType getType() {
		return TagType.BOOLEAN;
	}

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

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

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

	public int hashCode() {
		return super.hashCode() ^ (this.data ? 1 : 0);
	}

	public boolean getBool() {
		return this.data;
	}
}
