public class UrlUtils
extends Object
Modifier and Type | Class and Description |
---|---|
static class |
UrlUtils.URL_PARTS |
Modifier and Type | Field and Description |
---|---|
static String |
FILE_TOKEN
FILE token.
|
static String |
FILE_URL |
static String |
FILES_URL |
static String |
PATH_TOKEN
PATH token.
|
static String |
WEB_INF
WEB-INF directory name.
|
Constructor and Description |
---|
UrlUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
decodeUrl(String url)
Decodes a
application/x-www-form-urlencoded string using
UTF-8 encoding scheme. |
static Map<String,List<String>> |
decodeUrlQuery(String query)
Decode url query.
|
static String |
fileName2Url(String fileName)
Convert the file name to url.
|
static String |
getDataSetName(String catalog)
Gets the data set name.
|
static String |
getFileName(String token,
String input)
Gets the file name from the string containing url and file name using
token as a delimiter.
Example: input: http://localhost:8080/something/{file:test} token: file: return: test |
static TypedKeyValue<String,TypedKeyValue<String,String>> |
getHostPortAndFile(String url)
Gets the host port and file.
|
static TypedKeyValue<String,String> |
getNotSupportedProtocols(String url)
Get the not supported protocols such as IMAP, etc from the url.
|
static String |
getUrl(String token,
String input)
Gets the url from the string containing url and file name.
Example: input: http://localhost:8080/something/{file:test} token: file: return: http://localhost:8080/something |
static TypedKeyValue<String,String> |
getUrlAndPath(String source)
Gets the url and path from the source.
|
static TypedKeyValue<String,String> |
getUrlAndPath(String url,
boolean isFileSystem)
Parse url and return part of the url before path and path.
|
static TypedKeyValue<String,TypedKeyValue<String,String>> |
getUrlFolderFile(String url)
Gets the url, folder and file name from the url.
|
static String |
getUrlToken(String token)
Gets the url token.
|
static TypedKeyValue<String,String> |
getUrlWithPathAndFile(String url,
boolean isFileSystem)
Parse url and return part of the url before path and path.
|
static String |
getUrlWithProtocolUserNameAndPassword(String url,
String protocol,
String user,
String password)
Gets the url with protocol user name and password.
|
static boolean |
hasUrlToken(String token,
String input)
Checks if input string contains specific token.
|
static boolean |
isUrl(String url)
Checks if given string a is a formally url.
|
static Map<UrlUtils.URL_PARTS,String> |
parseUrl(String url)
Parses the url and fills the map with url parts.
|
static String |
parseUrl(String url,
UrlUtils.URL_PARTS part)
Parse the url and return requested part of the url.
|
static TypedKeyValue<String,String> |
parseUrlWithPath(String source)
Parse url with path.
|
static String |
setUrl(String token,
String input,
String value)
Sets the value for the token in the input string.
Example: token: file: input: http://localhost:8080/something/{file:} value: test2 return: http://localhost:8080/something/{file:test2} |
static String |
stripLeadingSlash(String path)
Strip leading slash.
|
static String |
urlEncode(String url)
Encodes URL.
|
static String |
urlToPath(String url)
Gets path from the string representing url.
Example: url: file:/C:/Tomcat 5.5/webapps/developer/WEB-INF/lib/toolsverse-core.jar!/com/toolsverse/config/SystemConfig.class return: C:/Tomcat 5.5/webapps/developer/WEB-INF |
public static String FILE_URL
public static String FILES_URL
public static final String WEB_INF
public static final String PATH_TOKEN
public static final String FILE_TOKEN
public static String decodeUrl(String url)
application/x-www-form-urlencoded
string using
UTF-8 encoding scheme.url
- the String
to decodeString
public static String fileName2Url(String fileName)
fileName
- the file namepublic static String getDataSetName(String catalog)
catalog
- the catalogpublic static String getFileName(String token, String input)
token
- the tokeninput
- the inputpublic static TypedKeyValue<String,String> getNotSupportedProtocols(String url)
url
- the urlpublic static String getUrl(String token, String input)
token
- the tokeninput
- the inputpublic static TypedKeyValue<String,String> getUrlAndPath(String source)
source
- the sourcepublic static TypedKeyValue<String,String> parseUrlWithPath(String source) throws Exception
source
- the sourceException
public static TypedKeyValue<String,String> getUrlAndPath(String url, boolean isFileSystem) throws Exception
url
- the urlisFileSystem
- if true ignore correct url formattingException
- in case of any errorpublic static TypedKeyValue<String,String> getUrlWithPathAndFile(String url, boolean isFileSystem) throws Exception
url
- the urlisFileSystem
- if true ignore correct url formattingException
- in case of any errorpublic static String getUrlToken(String token)
token
- the tokenpublic static boolean hasUrlToken(String token, String input)
token
- the tokeninput
- the inputpublic static boolean isUrl(String url)
url
- the urlpublic static Map<UrlUtils.URL_PARTS,String> parseUrl(String url)
url
- the urlpublic static String parseUrl(String url, UrlUtils.URL_PARTS part) throws Exception
url
- the urlpart
- the part of url to returnException
- n case of any errorpublic static String setUrl(String token, String input, String value)
token
- the tokeninput
- the inputvalue
- the valuepublic static String stripLeadingSlash(String path)
path
- the pathpublic static String urlEncode(String url)
url
- the url to encodepublic static String urlToPath(String url)
url
- the urlpublic static TypedKeyValue<String,TypedKeyValue<String,String>> getHostPortAndFile(String url)
url
- the urlpublic static TypedKeyValue<String,TypedKeyValue<String,String>> getUrlFolderFile(String url) throws Exception
url
- the urlException
public static String getUrlWithProtocolUserNameAndPassword(String url, String protocol, String user, String password) throws Exception
url
- the urlprotocol
- the protocoluser
- the userpassword
- the passwordException
public static Map<String,List<String>> decodeUrlQuery(String query)
query
- the queryCopyright © 2010-2020 Toolsverse. All Rights Reserved.