public static String[] convertSingleConsoleCommand(String command)
            throws InvalidCommandException {
        logger.trace("Converting single console command for ProcessBuilder: " + command);

        List<String> preparedResult = new ArrayList<String>();
        String tmp = null;

        for (String currentlyCheckedString : command.split(" ")) {
            if (tmp != null) {
                tmp += " " + currentlyCheckedString;
                if (endOfGroup.matcher(currentlyCheckedString).find()) {
                    preparedResult.add(tmp.substring(0, tmp.length() - 1));
                    tmp = null;
                }
            } else {
                if (singleWrapped.matcher(currentlyCheckedString).find())
                    preparedResult.add(currentlyCheckedString.substring(1,
                            currentlyCheckedString.length() - 1));
                else if (beginningOfGroup.matcher(currentlyCheckedString).find())
                    tmp = currentlyCheckedString.substring(1);
                else if (!currentlyCheckedString.isEmpty())
                    preparedResult.add(currentlyCheckedString);
            }
        }

        if (tmp != null) {
            logger.error("Failed to convert console command - command invalid (exception thrown)");
            throw new InvalidCommandException("There is error in \"" + command + "\" command");
        }

        logger.detailedTrace("\tConverted single console command: " + preparedResult);
        return preparedResult.toArray(new String[0]);
    }