org.qedeq.base.io
Class UrlUtility

java.lang.Object
  extended by org.qedeq.base.io.UrlUtility

public final class UrlUtility
extends java.lang.Object

A collection of useful static methods for URL s.

Author:
Michael Meyling

Method Summary
static java.lang.String createRelativePath(java.io.File origin, java.io.File next)
          Create relative address from origin to next.
static java.lang.String easyUrl(java.lang.String url)
          Simplify file URL by returning a file path.
static boolean isSetConnectionTimeOutSupported()
          Is setting of connection timeout supported in current environment?
static boolean isSetReadTimeoutSupported()
          Is setting of read timeout supported in current environment?
static void saveUrlToFile(java.lang.String url, java.io.File f, java.lang.String proxyHost, java.lang.String proxyPort, java.lang.String nonProxyHosts, int connectTimeout, int readTimeout, LoadingListener listener)
          Make local copy of an URL.
static java.net.URL toUrl(java.io.File file)
          Convert file in URL.
static java.io.File transformURLPathToFilePath(java.net.URL url)
          Convert URL path in file path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toUrl

public static java.net.URL toUrl(java.io.File file)
Convert file in URL.

Parameters:
file - File.
Returns:
URL.

transformURLPathToFilePath

public static java.io.File transformURLPathToFilePath(java.net.URL url)
Convert URL path in file path.

Parameters:
url - Convert this URL path.
Returns:
File path.

createRelativePath

public static final java.lang.String createRelativePath(java.io.File origin,
                                                        java.io.File next)
Create relative address from origin to next. The resulting file path has "/" as directory name separator. If the resulting file path is the same as origin specifies, we return "". Otherwise the result will always have an "/" as last character.

Parameters:
origin - This is the original location. Must be a directory.
next - This should be the next location. Must also be a directory.
Returns:
Relative (or if necessary absolute) file path.

easyUrl

public static java.lang.String easyUrl(java.lang.String url)
Simplify file URL by returning a file path.

Parameters:
url - URL to simplify.
Returns:
File path (if protocol is "file"). Otherwise just return url.

saveUrlToFile

public static void saveUrlToFile(java.lang.String url,
                                 java.io.File f,
                                 java.lang.String proxyHost,
                                 java.lang.String proxyPort,
                                 java.lang.String nonProxyHosts,
                                 int connectTimeout,
                                 int readTimeout,
                                 LoadingListener listener)
                          throws java.io.IOException
Make local copy of an URL.

Parameters:
url - Save this URL.
f - Save into this file. An existing file is overwritten.
proxyHost - Use this proxy host.
proxyPort - Use this port at proxy host.
nonProxyHosts - This are hosts not to be proxied.
connectTimeout - Connection timeout.
readTimeout - Read timeout.
listener - Here completion events are fired.
Throws:
java.io.IOException - Saving failed.

isSetConnectionTimeOutSupported

public static boolean isSetConnectionTimeOutSupported()
Is setting of connection timeout supported in current environment?

Returns:
Setting connection timeout supported?

isSetReadTimeoutSupported

public static boolean isSetReadTimeoutSupported()
Is setting of read timeout supported in current environment?

Returns:
Setting read timeout supported?


Copyright © 2014. All Rights Reserved.