com.marringtons.net.HTTP
Class URL

java.lang.Object
  extended bycom.marringtons.net.HTTP.URL

public class URL
extends Object

This class contains static helper methods for preparing and comparing URLs.

Author:
Paul Marrington

Constructor Summary
URL()
           
 
Method Summary
static String getHost(String url)
          Given a URL (with or without the http:// or other protocol), extract the host name and port.
static boolean sameHosts(String url1, String url2)
          Given 2 URLs, compare and see if they come from the same host/port.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URL

public URL()
Method Detail

getHost

public static String getHost(String url)
Given a URL (with or without the http:// or other protocol), extract the host name and port.
 getHost("http://google.com/whatever.html").equals("google.com");
 

Parameters:
url - to look at
Returns:
host portion of URL (including port if supplied)

sameHosts

public static boolean sameHosts(String url1,
                                String url2)
Given 2 URLs, compare and see if they come from the same host/port. Note that unlike the rest of the URL, the host name is case insensitive.

Parameters:
url1 - First URL to compare.
url2 - Second URL to compare.
Returns:
true if the 2 urls represent the same host/port (but possibly different paths).


Copyright © 2005 Paul Marrington http://library.marringtons.com