UrlUtils (IcedTea-Web: NetX )
Keywords: net.sourceforge.jnlp.util.UrlUtils class
Date: 2018-03-18

net.sourceforge.jnlp.util

## Class UrlUtils

- java.lang.Object
- - net.sourceforge.jnlp.util.UrlUtils

-     public class UrlUtils
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UrlUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.io.File` | `decodeUrlAsFile(java.net.URL url)`
    `static java.net.URL` | `decodeUrlQuietly(java.net.URL url)`
    `static java.lang.String` | `ensureSlashTail(java.lang.String s)`
    `static java.net.URL` | `ensureSlashTail(java.net.URL u)`
    `static boolean` | `equalsIgnoreLastSlash(java.net.URL u1, java.net.URL u2)` both urls are processed by sanitizeLastSlash before actual equals.
    `static java.lang.String` | `getHostAndPort(java.net.URL url)`
    `static int` | `getPort(java.net.URL url)`
    `static int` | `getSanitizedPort(java.net.URL u)`
    `static java.net.URL` | `guessCodeBase(JNLPFile file)`
    `static boolean` | `isLocalFile(java.net.URL url)`
    `static boolean` | `isValidRFC2396Url(java.net.URL url)`
    `static java.lang.String` | `loadUrl(java.net.URL url)`
    `static java.lang.String` | `loadUrl(java.net.URL url, java.nio.charset.Charset ch)`
    `static java.lang.String[]` | `loadUrlWithInvalidHeader(java.net.URL url)`
    `static java.lang.String[]` | `loadUrlWithInvalidHeader(java.net.URL url, java.nio.charset.Charset ch)`
    `static java.lang.Object[]` | `loadUrlWithInvalidHeaderBytes(java.net.URL url)`
    `static java.net.URL` | `normalizeUrl(java.net.URL url)`
    `static java.net.URL` | `normalizeUrl(java.net.URL url, boolean encodeFileUrls)`
    `static java.net.URL` | `normalizeUrlAndStripParams(java.net.URL url)`
    `static java.net.URL` | `normalizeUrlAndStripParams(java.net.URL url, boolean encodeFileUrls)`
    `static java.net.URL` | `normalizeUrlQuietly(java.net.URL url)`
    `static java.net.URL` | `normalizeUrlQuietly(java.net.URL url, boolean encodeFileUrls)`
    `static java.net.URL` | `removeFileName(java.net.URL src)` This function i striping part behind last path delimiter.
    `static java.lang.String` | `sanitizeLastSlash(java.lang.String in)`
    `static java.net.URL` | `sanitizeLastSlash(java.net.URL in)` This function is removing all tailing slashes of url and both unix and windows salshes are supported.
    `static java.lang.String` | `setOfUrlsToHtmlList(java.lang.Iterable<java.net.URL> remoteUrls)` Small utility function creating li list from collection of urls
    `static java.lang.String` | `stripFile(java.net.URL documentbase)`
    `static boolean` | `urlEquals(java.net.URL u1, java.net.URL u2)` Compares a URL using string compareNullableStrings of its protocol, host, port, path, query, and anchor.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### UrlUtils

          public UrlUtils()

  - ### Method Detail

    - #### normalizeUrlAndStripParams

          public static java.net.URL normalizeUrlAndStripParams(java.net.URL url,
                                                                boolean encodeFileUrls)

    - #### normalizeUrlAndStripParams

          public static java.net.URL normalizeUrlAndStripParams(java.net.URL url)

    - #### isLocalFile

          public static boolean isLocalFile(java.net.URL url)

    - #### decodeUrlQuietly

          public static java.net.URL decodeUrlQuietly(java.net.URL url)

    - #### isValidRFC2396Url

          public static boolean isValidRFC2396Url(java.net.URL url)

    - #### normalizeUrl

          public static java.net.URL normalizeUrl(java.net.URL url,
                                                  boolean encodeFileUrls)
                                           throws java.net.MalformedURLException,
                                                  java.io.UnsupportedEncodingException,
                                                  java.net.URISyntaxException

      Throws:
        `java.net.MalformedURLException`
        `java.io.UnsupportedEncodingException`
        `java.net.URISyntaxException`

    - #### normalizeUrl

          public static java.net.URL normalizeUrl(java.net.URL url)
                                           throws java.net.MalformedURLException,
                                                  java.io.UnsupportedEncodingException,
                                                  java.net.URISyntaxException

      Throws:
        `java.net.MalformedURLException`
        `java.io.UnsupportedEncodingException`
        `java.net.URISyntaxException`

    - #### normalizeUrlQuietly

          public static java.net.URL normalizeUrlQuietly(java.net.URL url,
                                                         boolean encodeFileUrls)

    - #### normalizeUrlQuietly

          public static java.net.URL normalizeUrlQuietly(java.net.URL url)

    - #### decodeUrlAsFile

          public static java.io.File decodeUrlAsFile(java.net.URL url)

    - #### removeFileName

          public static java.net.URL removeFileName(java.net.URL src)

      This function i striping part behind last path delimiter. Expected is input like protcol://som.url/some/path/file.suff Then output will bee protcol://som.url/some/path Be aware of input like protcol://som.url/some/path/ then input will be just protcol://som.url/some/path You can use sanitizeLastSlash and see also unittests Both unix and windows salshes are supported
      Parameters:
        `src` - src to be stripped
      Returns:
        src without file

    - #### setOfUrlsToHtmlList

          public static java.lang.String setOfUrlsToHtmlList(java.lang.Iterable<java.net.URL> remoteUrls)

      Small utility function creating li list from collection of urls
      Parameters:
        `remoteUrls` - list of urls
      Returns:
        String containing html item list of those urls

    - #### sanitizeLastSlash

          public static java.net.URL sanitizeLastSlash(java.net.URL in)
                                                throws java.net.MalformedURLException

      This function is removing all tailing slashes of url and both unix and windows salshes are supported. See tests for valid and invalid inputs/outputs Shortly protcol://som.url/some/path/ or protcol://som.url/some/path//// (and same for windows protcol://som.url/some\path\\) will become protcol://som.url/some/path Even protcol://som.url/ is reduced to protcol://som.url When input is like
      Parameters:
        `in` - url t be sanitized
      Returns:
        url without trailing slash (if any)
      Throws:
        `java.net.MalformedURLException` - if original url was wrong

    - #### sanitizeLastSlash

          public static java.lang.String sanitizeLastSlash(java.lang.String in)

    - #### equalsIgnoreLastSlash

          public static boolean equalsIgnoreLastSlash(java.net.URL u1,
                                                      java.net.URL u2)

      both urls are processed by sanitizeLastSlash before actual equals. So protcol://som.url/some/path/ is same as protcol://som.url/some/path. Even protcol://som.url/some/path\ is same as protcol://som.url/some/path/
      Parameters:
        `u1` - first url to comapre
        `u2` - second
      Returns:
        true if urls are equals no matter of trailing slash

    - #### guessCodeBase

          public static java.net.URL guessCodeBase(JNLPFile file)

    - #### urlEquals

          public static boolean urlEquals(java.net.URL u1,
                                          java.net.URL u2)

      Compares a URL using string compareNullableStrings of its protocol, host, port, path, query, and anchor. This method avoids the host name lookup that URL.equals does for http: protocol URLs. It may not return the same value as the URL.equals method (different hostnames that resolve to the same IP address, ie sourceforge.net and www.sourceforge.net).
      Parameters:
        `u1` - first url to compareNullableStrings
        `u2` - second url to compareNullableStrings
      Returns:
        whether the u1 and u2 points to same resource or not

    - #### getSanitizedPort

          public static int getSanitizedPort(java.net.URL u)

    - #### getPort

          public static int getPort(java.net.URL url)

    - #### getHostAndPort

          public static java.lang.String getHostAndPort(java.net.URL url)

    - #### ensureSlashTail

          public static java.net.URL ensureSlashTail(java.net.URL u)

    - #### ensureSlashTail

          public static java.lang.String ensureSlashTail(java.lang.String s)

    - #### stripFile

          public static java.lang.String stripFile(java.net.URL documentbase)

    - #### loadUrl

          public static java.lang.String loadUrl(java.net.URL url)
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### loadUrl

          public static java.lang.String loadUrl(java.net.URL url,
                                                 java.nio.charset.Charset ch)
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### loadUrlWithInvalidHeaderBytes

          public static java.lang.Object[] loadUrlWithInvalidHeaderBytes(java.net.URL url)
                                                                  throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### loadUrlWithInvalidHeader

          public static java.lang.String[] loadUrlWithInvalidHeader(java.net.URL url)
                                                             throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### loadUrlWithInvalidHeader

          public static java.lang.String[] loadUrlWithInvalidHeader(java.net.URL url,
                                                                    java.nio.charset.Charset ch)
                                                             throws java.io.IOException

      Throws:
        `java.io.IOException`

Submit a bug or feature