package common.tags;

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

class TagDouble extends Tag {
	private double data;

	TagDouble() {
	}

	public TagDouble(double data) {
		this.data = data;
	}

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

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

	TagType getType() {
		return TagType.DOUBLE;
	}

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

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

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

	public int hashCode() {
		long l = Double.doubleToLongBits(this.data);
		return super.hashCode() ^ (int)(l ^ l >>> 32);
	}

	public double getDouble() {
		return this.data;
	}
}
