|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.aitools.programd.util.URLTools
public class URLTools
URLTools contains helper methods for dealing with URLs.
| Constructor Summary | |
|---|---|
URLTools()
|
|
| Method Summary | |
|---|---|
static URL |
contextualize(URL context,
String subject)
Same as contextualize(URL, URL), except the
subject is a String which is supposed to not be
absolute (a quick check is made of this, and if the subject
does look absolute, it is made into a URL and sent to contextualize(URL, URL)). |
static URL |
contextualize(URL context,
URL subject)
Tries to put the subject in the "context" of the
context. |
static URL |
createValidURL(String path)
Attempts to create the given path into a valid URL, using
a few heuristics. |
static URL |
createValidURL(String path,
URL context)
Attempts to create the given path into a valid URL, using
a few heuristics. |
static URL |
createValidURL(String path,
URL context,
boolean tryToValidate)
Attempts to create the given path into a valid URL, using
a few heuristics. |
static String |
escape(String url)
Does very minimal URL escaping -- just enough to avoid complaints from the URI & URL constructors (maybe). |
static long |
getLastModified(URL path)
Tries to get the last modified timestamp for the path. |
static URL |
getParent(URL url)
|
static List<URL> |
getURLs(String pathspec,
URL context)
Take a path spec that may, or may not, use glob-style wildcards to indicate multiple files, and returns a list of URLs pointing to those files. |
static boolean |
pathsAreEquivalent(String path1,
String path2)
Using some rather uncomfortable heuristics, judges whether two given paths are (probably) equivalent, by ignoring certain differences like platform-specific path separators vs. |
static boolean |
seemsToExist(URL url)
Tests whether a resource seems to exist at the given URL |
static String |
unescape(String url)
Reverses escape(String). |
static String |
unescape(URL url)
A convenience method that calls toString() on the given URL, then returns the result of unescape(String). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public URLTools()
| Method Detail |
|---|
public static URL contextualize(URL context,
URL subject)
Tries to put the subject in the "context" of the
context. If the context URL does not
appear to specify a file, this will essentially be the equivalent of
URI.resolve; if a file is
specified by context, and if subject is
relative, then this will replace the file component of
context with subject.
If subject is not relative, this will throw a
MalformedURLException is thrown.
context - subject -
subject in the context
public static URL contextualize(URL context,
String subject)
contextualize(URL, URL), except the
subject is a String which is supposed to not be
absolute (a quick check is made of this, and if the subject
does look absolute, it is made into a URL and sent to contextualize(URL, URL)).
context - subject -
subject in the context
public static URL createValidURL(String path)
throws FileNotFoundException
path into a valid URL, using
a few heuristics. Tries to validate the given path (if it is a file).
path -
FileNotFoundException
public static URL createValidURL(String path,
URL context)
throws FileNotFoundException
path into a valid URL, using
a few heuristics. Tries to validate the given path (if it is a file).
path - context - the context in which to resolve relative URLs (may be null)
FileNotFoundException
public static URL createValidURL(String path,
URL context,
boolean tryToValidate)
throws FileNotFoundException
path into a valid URL, using
a few heuristics.
path - context - the context in which to resolve relative URLs (may be null)tryToValidate - whether the method should try to validate the existence of the path
FileNotFoundException
public static List<URL> getURLs(String pathspec,
URL context)
pathspec - the path specification that may point to one or many files
public static URL getParent(URL url)
url - some URL
public static boolean seemsToExist(URL url)
url - the URL to test
public static long getLastModified(URL path)
path - the URL to check
public static String escape(String url)
url - the URL to escape
public static String unescape(String url)
escape(String).
url - the URL to unescape
public static String unescape(URL url)
unescape(String).
public static boolean pathsAreEquivalent(String path1,
String path2)
path1 - path2 -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||