public class URNUtils extends Object
URI,
{@link "http://tools.ietf.org/html/rfc2141"}
{@link "http://tools.ietf.org/html/rfc3188"}
{@link "http://tools.ietf.org/html/rfc3986"}| Constructor and Description |
|---|
URNUtils() |
| Modifier and Type | Method and Description |
|---|---|
static AbstractMap<String,String> |
addMaps(AbstractMap<String,String> map1,
AbstractMap<String,String> map2)
Adds two given maps and returns a map that contains key|value pairs of both.
|
static String |
addParamsToUrl(String urlStr,
AbstractMap<String,String> params)
Adds given new parameters to existing URL.
|
static String |
addQueryToUrl(String urlStr,
String aq)
Adds given new query to existing URL.
|
static String |
buildUrl(String protocol,
String userInfo,
String host,
int port,
String path,
AbstractMap<String,String> params,
boolean encodeParams,
String anchor,
boolean checkJavaURI)
Builds an URI from its given components.
|
static String |
correctUrlString(String urlStr,
boolean correctEncoding,
boolean checkJavaURI)
Tries to return a RFC compatible, normalized URL as string from a given string.
|
static String |
correctUtf8error(String strToCorrect)
Corrects wrong converted or encoded strings.
|
static int |
getChecksum(String tmpurn)
Calculates the checksum of the given string.
|
static String |
getDateURN(String ns)
Returns a valid URN for the given Namespace beginning with actual date.
|
static String |
getNormalisedPath(String path)
Normalises given URL Path.
|
static TreeMap<String,String> |
getParameterMap(String query,
String regex)
Parses a URL query and returns key, value pairs as a TreeMap.
|
static TreeMap<String,String> |
getParameterMap(URL url)
Parses an URL query and returns key|value pairs as a TreeMap.
|
static String |
getRandomURN(String ns)
Returns a random generated, valid URN for the given Namespace.
|
static String |
getURN(String tmpurn)
Returns a valid URN with checksum for the given identifier without checksum.
|
static String |
getURNforId(String ns,
String id)
Returns a valid URN for the given Namespace and another id.
|
static String |
mapToEncodedString(AbstractMap<String,String> map,
String delimiter)
Iterates all elements of a map and returns key=value pairs separated with
given delimiter as URLEncoded string.
|
static String |
mapToString(AbstractMap<String,String> map,
String delimiter)
Iterates all elements of a map and returns key=value pairs separated with
given delimiter as string.
|
static String |
normalize(String str,
boolean lowerCase)
Normalizes the "Percent Encoding" of an URI
|
public static int getChecksum(String tmpurn)
tmpurn - URN without checksumpublic static String getURN(String tmpurn)
tmpurn - URN without checksumpublic static String getURNforId(String ns, String id)
ns - Namespaceid - Another unique numberpublic static String getRandomURN(String ns)
ns - Namespace for this URN.public static String getDateURN(String ns)
ns - Namespace for this URN.public static String mapToString(AbstractMap<String,String> map, String delimiter)
map - A map containing Key, Value pairsdelimiter - String between Key=Value pairs. (normally "&" or ";" for URLs).public static String mapToEncodedString(AbstractMap<String,String> map, String delimiter) throws UnsupportedEncodingException
map - A map containing Key, Value pairsdelimiter - String between Key=Value pairs. "&" or ";" for URIs.UnsupportedEncodingExceptionURLEncoderpublic static TreeMap<String,String> getParameterMap(String query, String regex) throws UnsupportedEncodingException
query - (URI) Query to parseregex - Regular expression to use for splitting.UnsupportedEncodingExceptionpublic static TreeMap<String,String> getParameterMap(URL url) throws UnsupportedEncodingException
url - URL to parseUnsupportedEncodingExceptionpublic static AbstractMap<String,String> addMaps(AbstractMap<String,String> map1, AbstractMap<String,String> map2) throws UnsupportedEncodingException
map1 - First map.map2 - Second map.UnsupportedEncodingExceptionTreeMap,
URLDecoder,
URLEncoderpublic static String getNormalisedPath(String path) throws UnsupportedEncodingException
path - URL Path to parse.UnsupportedEncodingException{@link "http://www.w3.org/TR/html401"}public static String correctUtf8error(String strToCorrect) throws UnsupportedEncodingException
strToCorrect - String to check.UnsupportedEncodingExceptionpublic static String correctUrlString(String urlStr, boolean correctEncoding, boolean checkJavaURI)
urlStr - URL to correct as string.correctEncoding - Try to correct common wrong Latin1 - UTF-8 conversions.checkJavaURI - Check if Java can parse this string as Java URL and URI without exceptionpublic static String addQueryToUrl(String urlStr, String aq) throws MalformedURLException, UnsupportedEncodingException, URISyntaxException
urlStr - URL to correct as string.aq - Additional query: query to add to given URL.
"http://www.w3.org/TR/html401"MalformedURLExceptionUnsupportedEncodingExceptionURISyntaxExceptionpublic static String addParamsToUrl(String urlStr, AbstractMap<String,String> params) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException
urlStr - URL as java string.params - New parameters to add.UnsupportedEncodingExceptionMalformedURLExceptionURISyntaxExceptionpublic static String buildUrl(String protocol, String userInfo, String host, int port, String path, AbstractMap<String,String> params, boolean encodeParams, String anchor, boolean checkJavaURI) throws UnsupportedEncodingException, URISyntaxException, MalformedURLException
protocol - Protocol part of this URIuserInfo - User info part of this URIhost - Host part of this URIport - Port part of this URIpath - Path part of this URIparams - Parameters part of this URIencodeParams - TRUE if the parameters must be encodedanchor - Anchor part of this URIcheckJavaURI - TRUE if extra validation wantedUnsupportedEncodingExceptionURISyntaxExceptionMalformedURLExceptionpublic static String normalize(String str, boolean lowerCase) throws UnsupportedEncodingException
str - The URI to normalize as Java StringlowerCase - TRUE if the string should be converted to all lower case.UnsupportedEncodingExceptionCopyright © 2014 Deutsche Nationalbibliothek / German National Library. All rights reserved.