Package io.cui.tools.net
Class UrlHelper
- java.lang.Object
-
- io.cui.tools.net.UrlHelper
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringaddPrecedingSlashToPath(String path)static StringaddTrailingSlashToUrl(String url)static booleanisValidUri(String uri)static StringremovePrecedingSlashFromPath(String path)static StringremoveTrailingSlashesFromUrl(String url)static List<String>splitPath(String pathString)Split the given path String in a unified view with a list ofString.static Optional<URI>tryParseUri(String uri)
-
-
-
Method Detail
-
addTrailingSlashToUrl
public static String addTrailingSlashToUrl(String url)
- Parameters:
url- to be adapted- Returns:
- the given url if it already suffixed with '/' or null / empty. The given url suffixed with '/' otherwise
-
removeTrailingSlashesFromUrl
public static String removeTrailingSlashesFromUrl(String url)
- Parameters:
url- to be adapted- Returns:
- the given url if it is not suffixed with '/' or null / empty. The given url '/' removed otherwise. Multiple trailing slashes will be removed as well
-
addPrecedingSlashToPath
public static String addPrecedingSlashToPath(String path)
- Parameters:
path- to be adapted- Returns:
- the given path if it already prefixed with '/'. The given path prefixed with '/' otherwise. In case of being null or empty it will return "/"
-
removePrecedingSlashFromPath
public static String removePrecedingSlashFromPath(String path)
- Parameters:
path-- Returns:
- the given path if it is not suffixed with '/' or null / empty. The given path '/' removed otherwise. Multiple preceding slashes will be removed as well
-
splitPath
public static List<String> splitPath(String pathString)
Split the given path String in a unified view with a list ofString. The individual path-elements are implicitly trimmed- Parameters:
pathString- if it is null or empty an empty List will be returned- Returns:
- the list view on the path elements. never null but may be empty
-
tryParseUri
public static Optional<URI> tryParseUri(String uri)
- Parameters:
uri- value to be verified if it is a valid URI.- Returns:
- URI object, if the given value is a valid URI.
-
isValidUri
public static boolean isValidUri(String uri)
- Parameters:
uri- value to be verified if it is a valid URI.- Returns:
- true, if the given value is a valid URI. False otherwise.
-
-