public JSONEventType next() throws IOException {
		JSONEventType type = null;
		do {
			set(null, null, false);
			switch (state) {
			case BEFORE_ROOT:
				state = beforeRoot();
				break;
			case AFTER_ROOT:
				state = afterRoot();
				break;
			case BEFORE_NAME:
				state = beforeName();
				break;
			case AFTER_NAME:
				state = afterName();
				break;
			case BEFORE_VALUE:
				state = beforeValue();
				break;
			case AFTER_VALUE:
				state = afterValue();
				break;
			}
			
			if (getDepth() <= getMaxDepth()) {
				type = getType();
			}
		} while (state != -1 && type == null);
		
		return type;
	}