public URLBuilder(String baseUrl, String... path) { this(baseUrl); for (String p : path) { path(p); } }
public URLBuilder(String baseUrl, String... path) { this(baseUrl); for (String p : path) { path(p); } }
/** * Add a path element to the URL being built. It will add (or remove) / symbols as needed * * @param path path * @return URLBuilder */ public URLBuilder path(String path) { return path(path, false); }
/** * Add a path element to the URL being built. It will add (or remove) / symbols as needed * * @param path path * @return URLBuilder */ public URLBuilder path(String path) { return path(path, false); }
/** * Adds a path to the URL being built. * It will first strip out any parameters that might be included in the path, and then append it to the current URL, * Inserting a slash sign between the two, if neither the old url doesn't end with one, or the path starts with one. * * @param path Path to append. * @return URLBuilder instance. */ @Deprecated public URLBuilder addPath(String path) { return path(path); }
/** * Adds a path to the URL being built. * It will first strip out any parameters that might be included in the path, and then append it to the current URL, * Inserting a slash sign between the two, if neither the old url doesn't end with one, or the path starts with one. * * @param path Path to append. * @return URLBuilder instance. */ @Deprecated public URLBuilder addPath(String path) { return path(path); }
/** * Return an absolute URL under the context path. * * @param path Path * @return absolute URL */ public static String getContextURL(String path) { return createContextURLBuilder().path(path).toString(); }
public static String buildUrl(String baseUrl, String... pathElements) { final URLBuilder url = new URLBuilder(baseUrl); for (String element : pathElements) { url.path(element); } return url.toString(); }
public static URLBuilder createContextURLBuilder() { final ExternalContext ctx = JSFUtils.getExternalContext(); URLBuilder urlBuilder = new URLBuilder(ctx.getRequestScheme() + "://" + ctx.getRequestServerName() + ":" + ctx.getRequestServerPort()); if (!StringUtils.isEmpty(ctx.getRequestContextPath())) { urlBuilder.path(ctx.getRequestContextPath()); } return urlBuilder; }