|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.webdav.client.URLTool
public class URLTool
A utility for manipulating URL
s.
Note: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
Constructor Summary | |
---|---|
URLTool()
|
Method Summary | |
---|---|
static URL |
appendTrailingSlash(String url)
Returns the given URL with a trailing slash appended to it. |
static URL |
appendTrailingSlash(URL url)
Returns the given URL with a trailing slash appended to
it. |
static URL |
getChild(String parent,
String member)
Returns the child URL formed by joining the given member with the given parent URL. |
static URL |
getChild(URL parent,
String member)
Returns the child URL formed by joining the given member with the given parent URL. |
static Vector |
getElements(String url)
Returns all elements in the given URLs path. |
static Vector |
getElements(URL url)
Returns all elements in the given URLs path. |
static String |
getLastElement(String url)
Returns the last element in the given URLs path, or null
if the URL is the root. |
static String |
getLastElement(URL url)
Returns the last element in the given URLs path, or null
if the URL is the root. |
static URL |
getParent(String url)
Returns the parent URL of the given URL, or null if the
given URL is the root. |
static URL |
getParent(URL url)
Returns the parent URL of the given URL, or null if the
given URL is the root. |
static URL |
getRoot(String urlString)
Returns the root URL of the given URL. |
static URL |
getRoot(URL url)
Returns the root URL of the given URL. |
static URL |
removeTrailingSlash(String url)
Returns the given URL with its trailing slash removed. |
static URL |
removeTrailingSlash(URL url)
Returns the given URL with its trailing slash removed. |
static boolean |
urlsOverlap(String url1,
String url2)
Returns a boolean indicating whether the given URLs overlap. |
static boolean |
urlsOverlap(URL url1,
URL url2)
Returns a boolean indicating whether the given URLs overlap. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public URLTool()
Method Detail |
---|
public static URL appendTrailingSlash(String url) throws MalformedURLException
Given URL | Returned URL |
---|---|
"http://hostname/folder" | "http://hostname/folder/" |
"http://hostname/folder/ | "http://hostname/folder/" |
url
- a URL
MalformedURLException
- if the given URL is malformedpublic static URL appendTrailingSlash(URL url)
URL
with a trailing slash appended to
it. If the URL
already has a trailing slash the
URL
is returned unchanged.
Given URL | Returned URL |
---|---|
"http://hostname/folder" | "http://hostname/folder/" |
"http://hostname/folder/ | "http://hostname/folder/" |
url
- a URL
public static URL getChild(String parent, String member) throws MalformedURLException
MalformedURLException
- if the given parent is malformedpublic static URL getChild(URL parent, String member)
public static Vector getElements(String url) throws MalformedURLException
Given URL | Element |
---|---|
"http://hostname/" | [] |
"http://hostname/folder/ | [folder] |
"http://hostname/folder/file | [folder, file] |
url
- a URL
MalformedURLException
- if the given URL is malformedpublic static Vector getElements(URL url)
Given URL | Element |
---|---|
"http://hostname/" | [] |
"http://hostname/folder/ | [folder] |
"http://hostname/folder/file | [folder, file] |
url
- a URL
public static String getLastElement(String url) throws MalformedURLException
null
if the URL is the root.
Given URL | Last Element |
---|---|
"http://hostname/" | null |
"http://hostname/folder/ | folder |
"http://hostname/folder/file | file |
url
- a URL
null
if the URL is the root
MalformedURLException
- if the given URL is malformedpublic static String getLastElement(URL url)
null
if the URL is the root.
Given URL | Last Element |
---|---|
"http://hostname/" | null |
"http://hostname/folder/ | folder |
"http://hostname/folder/file | file |
url
- a URL
null
if the URL is the rootpublic static URL getParent(String url) throws MalformedURLException
null
if the
given URL is the root.
Given URL | Parent URL |
---|---|
"http://hostname/" | null |
"http://hostname/folder/file | "http://hostname/folder/ |
url
- a URL
MalformedURLException
- if the given URL is malformedpublic static URL getParent(URL url)
null
if the
given URL is the root.
Given URL | Parent URL |
---|---|
"http://hostname/" | null |
"http://hostname/folder/file | "http://hostname/folder/ |
url
- a URL
public static URL getRoot(String urlString) throws MalformedURLException
Given URL | Root URL |
---|---|
"http://hostname/" | "http://hostname/" |
"http://hostname/folder/file | "http://hostname/" |
urlString
- a URL
MalformedURLException
- if the given URL is malformedpublic static URL getRoot(URL url)
Given URL | Root URL |
---|---|
"http://hostname/" | "http://hostname/" |
"http://hostname/folder/file | "http://hostname/" |
url
- a URL
public static URL removeTrailingSlash(String url) throws MalformedURLException
Given URL | Returned URL |
---|---|
"http://hostname/folder" | "http://hostname/folder" |
"http://hostname/folder/ | "http://hostname/folder" |
url
- a URL
MalformedURLException
- if the given URL is malformedpublic static URL removeTrailingSlash(URL url)
Given URL | Returned URL |
---|---|
"http://hostname/folder" | "http://hostname/folder" |
"http://hostname/folder/ | "http://hostname/folder" |
url
- a URL
public static boolean urlsOverlap(String url1, String url2) throws MalformedURLException
First URL | Second URL | Do they overlap |
---|---|---|
"http://hostname/folder/" | "http://hostname/folder/" | true |
"http://hostname/folder/" | "http://hostname/folder/file" | true |
"http://hostname/folder/file" | "http://hostname/folder/" | true |
"http://hostname/folder1/" | "http://hostname/folder2/" | false |
url1
- firt URLurl2
- second URL
MalformedURLException
public static boolean urlsOverlap(URL url1, URL url2)
First URL | Second URL | Do they overlap |
---|---|---|
"http://hostname/folder/" | "http://hostname/folder/" | true |
"http://hostname/folder/" | "http://hostname/folder/file" | true |
"http://hostname/folder/file" | "http://hostname/folder/" | true |
"http://hostname/folder1/" | "http://hostname/folder2/" | false |
"http://hostname1/folder/" | "http://hostname2/folder/" | false |
url1
- firt URLurl2
- second URL
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |