org.globus.util
Class GlobusURL

java.lang.Object
  extended by org.globus.util.GlobusURL

public class GlobusURL
extends Object

This class represents the URLs needed by various Globus services, including:

This class is not extended from URL since it is not intended to do stream handling. Instead it is primarily for the parsing of Globus URLs and is able to handle the extraction of user names and passwords from the URL as well. It also can parse literal IPv6 addresses (as per RFC 2732).


Field Summary
protected  String host
           
protected  int port
           
protected  String protocol
           
protected  String pwd
           
protected  String url
           
protected  String urlPath
           
protected  String user
           
 
Constructor Summary
GlobusURL(String url)
          Parses the url and extracts the url parts.
GlobusURL(URL url)
          Creates a GlobusURL instance from URL instance.
 
Method Summary
 boolean equals(Object obj)
          Compares two urls.
 String getFile()
          Deprecated.  
 String getHost()
          Returns the host name of an url.
 String getPath()
          Returns the url path part of an url.
 int getPort()
          Returns the port number of an url.
static int getPort(String protocol)
           
 String getProtocol()
          Returns the protocol of an url.
 String getPwd()
          Returns the password of an url.
 String getURL()
          Returns the string representation of an url.
 String getUrlPath()
          Deprecated. Though this class does not extend java.net.URL, it should be similar where possible to be intuitive to the user used to URL.
 String getUser()
          Returns the user name of an url.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

protocol

protected String protocol

host

protected String host

urlPath

protected String urlPath

user

protected String user

pwd

protected String pwd

url

protected String url

port

protected int port
Constructor Detail

GlobusURL

public GlobusURL(String url)
          throws MalformedURLException
Parses the url and extracts the url parts.

Parameters:
url - the url to parse.
Throws:
MalformedURLException - if the url is malformed.

GlobusURL

public GlobusURL(URL url)
Creates a GlobusURL instance from URL instance.
Note: Not all the url parts are copied.

Method Detail

getPort

public static int getPort(String protocol)

getURL

public String getURL()
Returns the string representation of an url.

Returns:
the url as string.

getProtocol

public String getProtocol()
Returns the protocol of an url.

Returns:
the protocol part of the url.

getHost

public String getHost()
Returns the host name of an url.

Returns:
the host name part of the url.

getPort

public int getPort()
Returns the port number of an url.

Returns:
the port name of the url. -1 if the port was not specified.

getPath

public String getPath()
Returns the url path part of an url.

Returns:
the url path part of the url. Returns null if the url path is not specified.

getFile

public String getFile()
Deprecated. 

Returns the url path part of an url.

Returns:
the url path part of the url. Returns null if the url path is not specified.

getUrlPath

public String getUrlPath()
Deprecated. Though this class does not extend java.net.URL, it should be similar where possible to be intuitive to the user used to URL.

Returns the url path part of an url.

Returns:
the url path part of the url. Returns null if the url path is not specified.

getUser

public String getUser()
Returns the user name of an url.

Returns:
the user name if present in the url, otherwise returns null.

getPwd

public String getPwd()
Returns the password of an url.

Returns:
the password if present in the url, otherwise returns null.

equals

public boolean equals(Object obj)
Compares two urls.

Overrides:
equals in class Object
Parameters:
obj - could be a string representation of an url or an instance of this class.
Returns:
true if the urls are the same, false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object