Package gumi.builders.url

Examples of gumi.builders.url.UrlParameterMultimap$Immutable


            return new UrlBuilder();
        }
        final Matcher m = URI_PATTERN.matcher(url);
        String scheme = null, userInfo = null, hostName = null, path = null, fragment = null;
        Integer port = null;
        final UrlParameterMultimap queryParametersMultimap;
        if (m.find()) {
            scheme = m.group(2);
            if (m.group(4) != null) {
                final Matcher n = AUTHORITY_PATTERN.matcher(m.group(4));
                if (n.find()) {
View Full Code Here


    /**
     * Sets the query parameters to a deep copy of the input parameter. Use <tt>null</tt> to remove the whole section.
     */
    public UrlBuilder withQuery(final UrlParameterMultimap query) {
        final UrlParameterMultimap q;
        if (query == null) {
            q = newMultimap();
        } else {
            q = query.deepCopy();
        }
View Full Code Here

    /**
     * Adds a query parameter. New parameters are added to the end of the query string.
     */
    public UrlBuilder addParameter(final String key, final String value) {
        final UrlParameterMultimap qp = queryParametersMultimap.deepCopy().add(key, value);
        return of(decoder, encoder, scheme, userInfo, hostName, port, path, qp, fragment);
    }
View Full Code Here

    /**
     * Replaces a query parameter.
     * Existing parameters with this name are removed, and the new one added to the end of the query string.
     */
    public UrlBuilder setParameter(final String key, final String value) {
        final UrlParameterMultimap qp = queryParametersMultimap.deepCopy().replaceValues(key, value);
        return of(decoder, encoder, scheme, userInfo, hostName, port, path, qp, fragment);
    }
View Full Code Here

    /**
     * Removes a query parameter for a key and value.
     */
    public UrlBuilder removeParameter(final String key, final String value) {
        final UrlParameterMultimap qp = queryParametersMultimap.deepCopy().remove(key, value);
        return of(decoder, encoder, scheme, userInfo, hostName, port, path, qp, fragment);
    }
View Full Code Here

    /**
     * Removes all query parameters with this key.
     */
    public UrlBuilder removeParameters(final String key) {
        final UrlParameterMultimap qp = queryParametersMultimap.deepCopy().removeAllValues(key);
        return of(decoder, encoder, scheme, userInfo, hostName, port, path, qp, fragment);
    }
View Full Code Here

        }
        return urlDecode(fragment, DO_NOT_DECODE_PLUS_AS_SPACE);
    }

    public UrlParameterMultimap parseQueryString(final String query) {
        final UrlParameterMultimap ret = newMultimap();
        if (query == null || query.isEmpty()) {
            return ret;
        }
        for (final String part : query.split("&")) {
            final String[] kvp = part.split("=", 2);
            final String key, value;
            key = urlDecode(kvp[0], DECODE_PLUS_AS_SPACE);
            if (kvp.length == 2) {
                value = urlDecode(kvp[1], DECODE_PLUS_AS_SPACE);
            } else {
                value = null;
            }
            ret.add(key, value);
        }
        return ret;
    }
View Full Code Here

        return new AbstractMap.SimpleImmutableEntry<String, String>(key, value);
    }

    @Test
    public void createMultimap() {
        final UrlParameterMultimap m1 = UrlParameterMultimap.newMultimap();
    }
View Full Code Here

        final UrlParameterMultimap.Immutable m1 = UrlParameterMultimap.newMultimap().immutable();
    }

    @Test
    public void putArray() {
        final UrlParameterMultimap m1 = UrlParameterMultimap.newMultimap();
        m1.put("a", Arrays.asList("1", "2", "3"));
        m1.put("b", Arrays.asList("4", "5", "6"));
        m1.put("a", Arrays.asList("2", "3", "7"));
        assertEquals(Arrays.asList(newEntry("a", "2"), newEntry("a", "3"), newEntry("b", "4"),
                newEntry("b", "5"), newEntry("b", "6"), newEntry("a", "7")),
                m1.flatEntryList());
    }
View Full Code Here

                m1.flatEntryList());
    }

    @Test
    public void addEntries() {
        final UrlParameterMultimap m1 = UrlParameterMultimap.newMultimap();
        m1.add("a", "1").add("b", "2").add("c", "3");
        assertEquals(m1.flatEntryList().get(0), newEntry("a", "1"));
        assertEquals(m1.flatEntryList().get(1), newEntry("b", "2"));
        assertEquals(m1.flatEntryList().get(2), newEntry("c", "3"));
    }
View Full Code Here

TOP

Related Classes of gumi.builders.url.UrlParameterMultimap$Immutable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.