org.sapia.ubik.net
Class Uri

java.lang.Object
  extended by org.sapia.ubik.net.Uri

public class Uri
extends java.lang.Object

This class models a URI.

Usage:

  Uri httpURI = Uri.parse("http://www.sapia-oss.org:80/index.html");

  // will print: http
  System.out.println(httpURI.getScheme());

  // will print: www.sapia-oss.org
  System.out.println(httpURI.getHost());

  // will print: 80
  System.out.println(httpURI.getPort());

  // will print: /index.html
  System.out.println(httpURI.getPath());

  Uri fileURI = Uri.parse("file:/some/directory/foo.txt");

  // will print: file
  System.out.println(fileURI.getScheme());

  // these calls don't make sense:
  System.out.println(fileURI.getHost());
  System.out.println(fileURI.getHost());

  // will print: /some/directory/foo.txt
  System.out.println(fileURI.getPath());

 

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Field Summary
static java.lang.String UNDEFINED_HOST
           
static int UNDEFINED_PORT
           
 
Constructor Summary
Uri(java.lang.String scheme, java.lang.String host, int port, java.lang.String path)
           
 
Method Summary
 java.lang.String getHost()
          Returns the host of this URI.
 java.lang.String getPath()
          Returns the path of this URI.
 int getPort()
          Returns the port of this URI.
 QueryString getQueryString()
          Returns this instance's query string.
 java.lang.String getScheme()
          Returns the scheme of this URI.
static Uri parse(java.lang.String uriStr)
          Parses the given URI string and returns its object representation.
 void setHost(java.lang.String host)
          Sets this instance's host.
 void setPort(int port)
          Sets this instance's port.
 void setScheme(java.lang.String scheme)
          Sets this instance's scheme.
 java.lang.String toString()
          Returns this instance's string format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDEFINED_PORT

public static final int UNDEFINED_PORT
See Also:
Constant Field Values

UNDEFINED_HOST

public static final java.lang.String UNDEFINED_HOST
See Also:
Constant Field Values
Constructor Detail

Uri

public Uri(java.lang.String scheme,
           java.lang.String host,
           int port,
           java.lang.String path)
Method Detail

getPath

public java.lang.String getPath()
Returns the path of this URI.

Returns:
a path.

getScheme

public java.lang.String getScheme()
Returns the scheme of this URI.

Returns:
a scheme.

getHost

public java.lang.String getHost()
Returns the host of this URI.

Returns:
a host - if no host was specified, the returned value corresponds to the UNDEFINED_HOST constant of this class.

getPort

public int getPort()
Returns the port of this URI.

Returns:
a port - if no port was specified, the returned value corresponds to the UNDEFINED_PORT constant of this class.

setScheme

public void setScheme(java.lang.String scheme)
Sets this instance's scheme.

Parameters:
a - scheme.

setHost

public void setHost(java.lang.String host)
Sets this instance's host.

Parameters:
a - host identifier.

setPort

public void setPort(int port)
Sets this instance's port.

Parameters:
a - port.

getQueryString

public QueryString getQueryString()
Returns this instance's query string.

Returns:
a QueryString, or null if this instance has no query string.

toString

public java.lang.String toString()
Returns this instance's string format.

Overrides:
toString in class java.lang.Object
Returns:
a String.

parse

public static Uri parse(java.lang.String uriStr)
                 throws UriSyntaxException
Parses the given URI string and returns its object representation.

Returns:
a Uri.
Throws:
UriSyntaxException


Copyright © 2010 Sapia OSS. All Rights Reserved.