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

com.box.sdk.URLTemplate Maven / Gradle / Ivy

There is a newer version: 4.11.1
Show newest version
package com.box.sdk;

import java.net.MalformedURLException;
import java.net.URL;

class URLTemplate {
    private String template;

    URLTemplate(String template) {
        this.template = template;
    }

    URL build(String base, Object... values) {
        String urlString = String.format(base + this.template, values);

        URL url = null;
        try {
            url = new URL(urlString);
        } catch (MalformedURLException e) {
            assert false : "An invalid URL template indicates a bug in the SDK.";
        }

        return url;
    }

    URL buildWithQuery(String base, String queryString, Object... values) {
        String urlString = String.format(base + this.template, values) + queryString;
        URL url = null;
        try {
            url = new URL(urlString);
        } catch (MalformedURLException e) {
            assert false : "An invalid URL template indicates a bug in the SDK.";
        }

        return url;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy