| java.lang.Object net.refractions.udig.catalog.URLUtils
URLUtils | public class URLUtils (Code) | | Utilities for dealing with the catalog's use of URLs as identifiers
author: Jesse since: 1.1.0 |
Method Summary | |
public static URL | constructURL(File reference, String url) Creates a URL from the string. | public static URL | toRelativePath(File reference, URL destination) Converts the URL to a URL indicating the relative path from the reference file to the location indicated
by the destination URL. | public static boolean | urlEquals(URL url1, URL url2, boolean stripRef) Primarily for testing the comparison of URLS. | public static File | urlToFile(URL url) Takes a URL and converts it to a File. | public static String | urlToString(URL url1, boolean ignoreRef) Provides a standard way of converting to string.
Parameters: url1 - url to convert to string Parameters: ignoreRef - wether to ignore te reference in the string. |
constructURL | public static URL constructURL(File reference, String url) throws MalformedURLException(Code) | | Creates a URL from the string. If the String is a relative URL (and is a file) the returned
URL will be resolved to the Absolute path with respect to the reference parameter.
Parameters: reference - the base of any relative path. MUST BE A FILE Parameters: url - the url in string form. the URL created from the string |
toRelativePath | public static URL toRelativePath(File reference, URL destination)(Code) | | Converts the URL to a URL indicating the relative path from the reference file to the location indicated
by the destination URL. If it is not possible to to make a relative path then the destination URL will be returned unchanged.
Examples:
- reference = c:\foo\bar
destination = file:/c:\booger\data
return = file:/..\..\booger\data
- reference = c:\foo\bar
destination = file:/d:\booger\data
return = file:/d:\booger\data
- reference = c:\foo\bar
destination = http://booger.com\data
return = http://booger.com\data
Parameters: reference - the "from" file. The file that the relative path will start at. MUST BE A FILE Parameters: destination - the URL to transform to a relative path the relative path from reference to destination |
urlEquals | public static boolean urlEquals(URL url1, URL url2, boolean stripRef)(Code) | | Primarily for testing the comparison of URLS. it is not a simple thing because different platforms can sometimes
create ones with a dangling / or with / vs \ some times file:/// or file:/.
Parameters: url1 - first url to compare Parameters: url2 - second url Parameters: stripRef - if the reference should be ignored. For example searching for the IServiceof a IGeoResource. The Service ID would not have a reference but the IGeoResource would so ignore the reference in this case. true if they refer to the same resource. |
urlToFile | public static File urlToFile(URL url)(Code) | | Takes a URL and converts it to a File. The attempts to deal with
Windows UNC format specific problems, specifically files located
on network shares and different drives.
If the URL.getAuthority() returns null or is empty, then only the
url's path property is used to construct the file. Otherwise, the
authority is prefixed before the path.
It is assumed that url.getProtocol returns "file".
Authority is the drive or network share the file is located on.
Such as "C:", "E:", "\\fooServer"
Parameters: url - |
urlToString | public static String urlToString(URL url1, boolean ignoreRef)(Code) | | Provides a standard way of converting to string.
Parameters: url1 - url to convert to string Parameters: ignoreRef - wether to ignore te reference in the string. the url in string form. Always uses / and file:/. (rather than file:///). |
|
|