com.ning.http.url
Class Url

java.lang.Object
  extended by com.ning.http.url.Url
All Implemented Interfaces:
Serializable

public class Url
extends Object
implements Serializable

See Also:
Serialized Form

Nested Class Summary
static class Url.Protocol
           
 
Constructor Summary
Url(String scheme, String host, int port, String path, String query)
           
 
Method Summary
 void addParameter(String name, String value)
           
 void clearParameters()
          reset the parameters list.
 boolean equals(Object obj)
           
 String getBaseUrl()
           
 String getHost()
           
 String getLocation()
           
 String getParameter(String name)
           
 Map<String,List<String>> getParameters()
           
 List<String> getParameters(String name)
           
 String getPath()
          Gets the path part of this url.
 int getPort()
           
 Url.Protocol getProtocol()
           
 String getQueryString()
           
 String getScheme()
           
 String getUri()
           
 int hashCode()
           
static boolean isValidUrl(String url)
          Is the given Url string in a valid format?
 void removeParameter(String name)
           
 void setBaseUrl(String url)
           
 void setHost(String host)
           
 void setParameter(String name, Object value)
           
 void setParameter(String name, String value)
           
 void setPath(String path)
           
 void setPort(int port)
           
 void setQueryString(String query)
           
 void setScheme(String s)
           
 void setUri(String uri)
           
 String toString()
           
 String toStringWithoutParams()
          Return the URL string, but without any parameters
static Url valueOf(String value)
          Constructs a Url object from the given url string.
static Url valueOf(String scheme, String host, String uri)
          Constructs a Url object from the given url string parts.
static Url valueOf(Url base, String uri)
          Resolves 'path' with respect to a given base url
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Url

public Url(String scheme,
           String host,
           int port,
           String path,
           String query)
Method Detail

valueOf

public static Url valueOf(String value)
                   throws MalformedURLException
Constructs a Url object from the given url string. The string is expected to be compliant with the URL RFC and all relevant parts need to be properly url-encoded

Parameters:
value - the string
Returns:
a url object
Throws:
MalformedURLException

valueOf

public static Url valueOf(String scheme,
                          String host,
                          String uri)
Constructs a Url object from the given url string parts. The parts are expected to be compliant with the URL RFC and need to be properly url-encoded


valueOf

public static Url valueOf(Url base,
                          String uri)
                   throws MalformedURLException
Resolves 'path' with respect to a given base url

Throws:
MalformedURLException

getScheme

public String getScheme()

setScheme

public void setScheme(String s)

getProtocol

public Url.Protocol getProtocol()

getPath

public String getPath()
Gets the path part of this url. The value is url-decoded.

Returns:
he path part of this url. The value is url-decoded.

setPath

public void setPath(String path)

getPort

public int getPort()

setPort

public void setPort(int port)

getHost

public String getHost()

setHost

public void setHost(String host)

setBaseUrl

public void setBaseUrl(String url)

getBaseUrl

public String getBaseUrl()

getLocation

public String getLocation()

setUri

public void setUri(String uri)

getUri

public String getUri()

toString

public String toString()
Overrides:
toString in class Object

toStringWithoutParams

public String toStringWithoutParams()
Return the URL string, but without any parameters

Returns:
a string

setParameter

public void setParameter(String name,
                         String value)

clearParameters

public void clearParameters()
reset the parameters list.


setParameter

public void setParameter(String name,
                         Object value)

addParameter

public void addParameter(String name,
                         String value)

getParameter

public String getParameter(String name)

getParameters

public List<String> getParameters(String name)

getParameters

public Map<String,List<String>> getParameters()

removeParameter

public void removeParameter(String name)

setQueryString

public void setQueryString(String query)

getQueryString

public String getQueryString()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

isValidUrl

public static boolean isValidUrl(String url)
Is the given Url string in a valid format?

Parameters:
url -
Returns:
true if valid


Copyright © 2010. All Rights Reserved.