public void setQuery(String query) {
        if (query == null) {
            this.parameters = null;
            return;
        }

        LinkedList<Parameter> parameters = new LinkedList<Parameter>();

        if (query.equals("")) {
            this.parameters = parameters;
            return;
        }

        query = fixUrlEncoding(query);

        String parts[] = query.split(Pattern.quote(querySeparator));
        for (String part : parts) {
            String v[] = part.split("=", 2);

            if (v.length == 1) {
                parameters.add(new Parameter(v[0], null));
            } else {
                try {
                    try {
                        parameters.add(new Parameter(v[0], URLDecoder.decode(v[1], encoding.equals("detect") ? "UTF-8" : encoding)));
                    } catch (IllegalArgumentException e) {
                        try {
                            parameters.add(new Parameter(v[0], URLDecoder.decode(v[1], "ISO-8859-1")));
                            encoding = "ISO-8859-1";
                        } catch (IllegalArgumentException no_perro) {
                            parameters.add(new Parameter(v[0], v[1]));
                        }
                    }
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                }
            }
        }

        this.parameters = parameters;
    }