class Protocol {

	public final static Object getObject(String commandPart, Gateway gateway) {
		if (isEmpty(commandPart) || isEnd(commandPart)) {
			throw new Py4JException("Command Part is Empty or is the End of Command Part");
		} else {
			switch (commandPart.charAt(0)) {
			case BOOLEAN_TYPE:
				return getBoolean(commandPart);
			case DOUBLE_TYPE:
				return getDouble(commandPart);
			case LONG_TYPE:
				return getLong(commandPart);
			case INTEGER_TYPE:
				try {
					return getInteger(commandPart);
				} catch (NumberFormatException e) {
					return getLong(commandPart);
				}
			case BYTES_TYPE:
				return getBytes(commandPart);
			case NULL_TYPE:
				return getNull(commandPart);
			case VOID:
				return getNull(commandPart);
			case REFERENCE_TYPE:
				return getReference(commandPart, gateway);
			case STRING_TYPE:
				return getString(commandPart);
			case DECIMAL_TYPE:
				return getDecimal(commandPart);
			case PYTHON_PROXY_TYPE:
				return getPythonProxy(commandPart, gateway);
			default:
				throw new Py4JException("Command Part is unknown: " + commandPart);
			}
		}
	}

}