Class URLBuilder

  • All Implemented Interfaces:

    
    public class URLBuilder
    
                        

    A class providing a better way to construct a url.

    • Constructor Detail

      • URLBuilder

        URLBuilder()
        constructor
    • Method Detail

      • enableSSL

         URLBuilder enableSSL(boolean sslEnabled)

        set whether SSL is enabled

        Parameters:
        sslEnabled - the boolean flag to indicated whether SSL is enabled
        Returns:

        this

      • addPath

         URLBuilder addPath(String newPath)

        add path to the url, should not include '/' in the string

        Parameters:
        newPath - path string without '/'
        Returns:

        this

      • addQueryParameter

         URLBuilder addQueryParameter(String key, String value)

        add one query parameter with key/value pair, both key and value will be encoded

        Parameters:
        key - the key of the query parameter
        value - the value of the query parameter
        Returns:

        this

      • addQuery

         URLBuilder addQuery(String newQuery)

        add a whole string as a query in the url, the string will be encoded

        Parameters:
        newQuery - the query string to be added to the url
        Returns:

        this

      • addQuery

         URLBuilder addQuery(String newQuery, URLBuilder.EncodeType encodeType)

        add a whole string as a query in the url

        Parameters:
        newQuery - the query string to be added to the url
        encodeType - encode type to be used to encode the query
        Returns:

        this

      • build

         String build()

        build the url string based on all the data provided before

        Returns:

        the url string