|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.schemedit.url.UrlHelper
public class UrlHelper
Utilities for manipulating and comparing URLs
Constructor Summary | |
---|---|
UrlHelper()
Constructor for the UrlHelper object |
Method Summary | |
---|---|
static int |
deltaPath(URL url1,
URL url2)
Compute a "delta" between two URLs that serves as a measure of their similarity. |
static int |
deltaPathLen(String urlStr1,
String urlStr2)
Returns the difference in path lengths of two urls represented as strings |
static int |
deltaPathLen(URL url1,
URL url2)
Find the difference between the path lengths of two urls. |
static URL |
getAncestor(String urlStr,
int levels)
Gets the specified ancestor (using the levels param) of a given url (represented as a string). |
static URL |
getAncestor(URL url,
int levels)
Gets the ancestor of the given URL by calling getParent "level" times. |
static String |
getParamValue(String paramName,
String url)
Gets the paramValue attribute of the UrlHelper class |
static URL |
getParent(String urlStr)
Gets the parent attribute of the UrlHelper class |
static URL |
getParent(URL url)
Gets the parent attribute of the UrlHelper class |
static String |
getPathItem(String urlStr,
int index)
Gets the pathItem attribute of the UrlHelper class |
static String |
getPathItem(URL url,
int index)
return the nth path item, empty string if nth item does not exist |
static List |
getPathItems(URL url)
Returns the segments of a url path split around the path separator ("/") |
static int |
getPathLen(String s)
Returns the length of the path component of a url represented as a string |
static int |
getPathLen(URL url)
Returns the length of the path component (URL.getPath()) of a url. |
static Map |
getQueryArgs(String url)
Gets the queryArgs attribute of the UrlHelper class |
static String |
getSimilarUrlPath(String urlStr,
int levels)
Use wild cards to make a url that will retrieve all "ancestors" of the given url up to the specified level. |
static URL |
getUrl(String urlStr)
Converts a string into a URL instance, returning null in the case of a malformedUrl |
static boolean |
isSimilar(String baseStr,
String urlStr,
int maxDelta)
Checks whether two urls are similar within a variable "distance" that is a function of the respective lengths of the two urls. |
static boolean |
isValid(URL url)
A valid URL must have values for protocol and host. |
static void |
main(String[] args)
The main program for the UrlHelper class |
static String |
normalize(String s)
To be called on form input from metadata editor |
static boolean |
validateUrl(String urlStr)
Ensure that a urlStr contains a valid protocol and a host. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UrlHelper()
Method Detail |
---|
public static String normalize(String s)
s
- NOT YET DOCUMENTED
URISyntaxException
- NOT YET DOCUMENTEDpublic static boolean isSimilar(String baseStr, String urlStr, int maxDelta)
assumes urlStr represents a valid URL, and that the protocol, host, and port match those of the baseURL. NOTE: the urls we want to check in DCS will already pass this test because they are retrieved by a query string that is built from a legal baseURL and include equal protocol, host and ports.
baseStr
- A reference URL against which to check another urlurlStr
- A url string to be checked for similarity against baseUrlmaxDelta
- The maximum difference in url length (the length of the
value returned by URL.getPath() split by "/")
public static int deltaPathLen(URL url1, URL url2)
url1
- Description of the Parameterurl2
- Description of the Parameter
public static int deltaPath(URL url1, URL url2)
First find the portions of the two paths that are identical. Then sum the items in each url path items that are not found in the other.
url1
- Description of the Parameterurl2
- Description of the Parameter
public static int deltaPathLen(String urlStr1, String urlStr2)
urlStr1
- Description of the ParameterurlStr2
- Description of the Parameter
public static String getPathItem(URL url, int index)
url
- Description of the Parameterindex
- Description of the Parameter
public static String getPathItem(String urlStr, int index)
urlStr
- Description of the Parameterindex
- Description of the Parameter
public static List getPathItems(URL url)
url
- A URL instance
public static int getPathLen(URL url)
url
- Description of the Parameter
public static int getPathLen(String s)
s
- Description of the Parameter
public static URL getUrl(String urlStr)
urlStr
- Description of the Parameter
public static boolean isValid(URL url)
url
- A URL instance
URL
public static boolean validateUrl(String urlStr) throws MalformedURLException
urlStr
- String representation of a URL
MalformedURLException
- if not validpublic static String getSimilarUrlPath(String urlStr, int levels)
urlStr
- base url to be "generalized" using wildcardlevels
- the number of levels up to generalize urlStr
public static URL getAncestor(String urlStr, int levels)
urlStr
- url represented as a Stringlevels
- specifies how many levels "up" to go.
public static URL getAncestor(URL url, int levels)
url
- Description of the Parameterlevels
- Description of the Parameter
public static URL getParent(String urlStr)
urlStr
- Description of the Parameter
public static URL getParent(URL url)
url
- Description of the Parameter
public static String getParamValue(String paramName, String url)
paramName
- Description of the Parameterurl
- Description of the Parameter
public static Map getQueryArgs(String url)
url
- Description of the Parameter
public static void main(String[] args)
args
- The command line arguments
|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |