Package com.qfs
Class QfsWebUtils
java.lang.Object
com.qfs.QfsWebUtils
Helper class containing methods to deal with URLs.
- Author:
- ActiveViam
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charThe separator used to separate parts of an URI. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetProtocol(String url) Get the protocol used by the given url.static StringnormalizeUrl(String url, boolean withTrailingSlash) Normalize an URL, removing extra "/" characters.static StringBuild an url by joining the different given parts separated bySEPARATOR.static String
-
Field Details
-
SEPARATOR
public static final char SEPARATORThe separator used to separate parts of an URI.- See Also:
-
-
Constructor Details
-
QfsWebUtils
public QfsWebUtils()
-
-
Method Details
-
url
Build an url by joining the different given parts separated bySEPARATOR= '/'.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
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
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.
-
getProtocol
Get the protocol used by the given url.- Parameters:
url- the url- Returns:
- the protocol used (among http, https, ws, wss). null if there is no protocol in this url).
-