package cn.citycraft.GsonAgent.normal.stream;

import java.io.IOException;
import java.io.Reader;

import com.google.gson.stream.JsonReader;

import cn.citycraft.GsonAgent.api.stream.JsonToken;

public class JsonReaderHandle implements cn.citycraft.GsonAgent.api.stream.JsonReader {

	private final JsonReader handle;

	public JsonReaderHandle(final Reader in) {
		this(new JsonReader(in));
	}

	protected JsonReaderHandle(final JsonReader handle) {
		this.handle = handle;
	}

	@Override
	public void beginArray() throws IOException {
		getHandle().beginArray();
	}

	@Override
	public void beginObject() throws IOException {
		getHandle().beginObject();
	}

	@Override
	public void close() throws IOException {
		getHandle().close();
	}

	@Override
	public void endArray() throws IOException {
		getHandle().endArray();
	}

	@Override
	public void endObject() throws IOException {
		getHandle().endObject();
	}

	public JsonReader getHandle() {
		return handle;
	}

	@Override
	public boolean hasNext() throws IOException {
		return getHandle().hasNext();
	}

	@Override
	public boolean isLenient() {
		return getHandle().isLenient();
	}

	@Override
	public boolean nextBoolean() throws IOException {
		return getHandle().nextBoolean();
	}

	@Override
	public double nextDouble() throws IOException {
		return getHandle().nextDouble();
	}

	@Override
	public int nextInt() throws IOException {
		return getHandle().nextInt();
	}

	@Override
	public long nextLong() throws IOException {
		return getHandle().nextLong();
	}

	@Override
	public String nextName() throws IOException {
		return getHandle().nextName();
	}

	@Override
	public void nextNull() throws IOException {
		getHandle().nextNull();
	}

	@Override
	public String nextString() throws IOException {
		return getHandle().nextString();
	}

	@Override
	public JsonToken peek() throws IOException {
		return JsonToken.getByName(getHandle().peek().name());
	}

	@Override
	public void setLenient(final boolean lenient) {
		getHandle().setLenient(lenient);
	}

	@Override
	public void skipValue() throws IOException {
		getHandle().skipValue();
	}

	@Override
	public String toString() {
		return getHandle().toString();
	}

}
