All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hisp.dhis.UriBuilder Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
package org.hisp.dhis;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

import org.apache.hc.core5.net.URIBuilder;
import org.apache.hc.core5.net.URLEncodedUtils;

public class UriBuilder
    extends URIBuilder
{
    public UriBuilder( URI uri )
    {
        super( uri );
    }

    public UriBuilder( String uri )
        throws URISyntaxException
    {
        super( uri );
    }

    /**
     * Appends the given path segment to the URI. The path string
     * may contain multiple segments.
     *
     * @param path the path segment.
     * @return a {@link UriBuilder}.
     */
    public UriBuilder pathSegment( String path )
    {
        List segments = URLEncodedUtils.parsePathSegments( path );
        appendPathSegments( segments );
        return this;
    }

    /**
     * Appends the given path segments.
     *
     * @param segments the path segments.
     */
    private void appendPathSegments( List segments )
    {
        List paths = new ArrayList<>( getPathSegments() );
        paths.addAll( segments );
        setPathSegments( paths );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy