Package com.qfs
Class QfsWebUtils
- java.lang.Object
-
- com.qfs.QfsWebUtils
-
public class QfsWebUtils extends Object
Helper class containing methods to deal with URLs.- Author:
- ActiveViam
-
-
Field Summary
Fields Modifier and Type Field Description static charSEPARATORThe separator used to separate parts of an URI.
-
Constructor Summary
Constructors Constructor Description QfsWebUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetProtocol(String url)Get the protocol used by the given url.static StringnormalizeUrl(String url, boolean withTrailingSlash)Normalize an URL, removing extra "/" characters.static Stringurl(boolean withTrailingSlash, String... parts)Build an url by joining the different given parts separated bySEPARATOR.static Stringurl(String... parts)
-
-
-
Field Detail
-
SEPARATOR
public static final char SEPARATOR
The separator used to separate parts of an URI.- See Also:
- Constant Field Values
-
-
Method Detail
-
url
public static String url(String... parts)
Build an url by joining the different given parts separated bySEPARATOR= 47.The url start with
ROOT.E.g: - url("a", "/b", "/c/") returns /a/b/c - url("http://localhost:9090", "a", "/b", "/c/") returns http://localhost:9090/a/b/c- Parameters:
parts- parts of the url.- Returns:
- the url
-
url
public static String url(boolean withTrailingSlash, String... parts)
Build an url by joining the different given parts separated bySEPARATOR.The url start with
ROOTand may end withSEPARATOR.E.g: - url("a", "/b", "/c") returns /a/b/c/ - url("http://localhost:9090", "a", "/b", "/c") returns http://localhost:9090/a/b/c/- Parameters:
withTrailingSlash- true if the url need to end with "/", false otherwise.parts- parts of the url.- Returns:
- the url
-
normalizeUrl
public static String normalizeUrl(String url, boolean withTrailingSlash)
Normalize an URL, removing extra "/" characters.- Parameters:
url- the url to normalize.withTrailingSlash- true if the url wants to end with "/", false otherwise.If true and the trailing / is missing, it is added to the url. If false and present, it is removed.
- Returns:
- the normalized url.
-
-