aicas logo Jamaica 3.4 release 8

com.sun.jndi.toolkit.url
Class Uri

java.lang.Object
  extended by com.sun.jndi.toolkit.url.Uri
Direct Known Subclasses:
LdapURL

public class Uri
extends Object

A Uri object represents an absolute Uniform Resource Identifier (URI) as defined by RFC 2396 and updated by RFC 2373 and RFC 2732. The most commonly used form of URI is the Uniform Resource Locator (URL).

The java.net.URL class cannot be used to parse URIs since it requires the installation of URL stream handlers that may not be available. The hack of getting around this by temporarily replacing the scheme part of a URI is not appropriate here: JNDI service providers must work on older Java platforms, and we want new features and bug fixes that are not available in old versions of the URL class.

It may be appropriate to drop this code in favor of the java.net.URI class. The changes would need to be written so as to still run on pre-1.4 platforms not containing that class.

The format of an absolute URI (see the RFCs mentioned above) is:

      absoluteURI   = scheme ":" ( hier_part | opaque_part )

      scheme        = alpha *( alpha | digit | "+" | "-" | "." )

      hier_part     = ( net_path | abs_path ) [ "?" query ]
      opaque_part   = uric_no_slash *uric

      net_path      = "//" authority [ abs_path ]
      abs_path      = "/"  path_segments

      authority     = server | reg_name
      reg_name      = 1*( unreserved | escaped | "$" | "," |
                          ";" | ":" | "@" | "&" | "=" | "+" )
      server        = [ [ userinfo "@" ] hostport ]
      userinfo      = *( unreserved | escaped |
                         ";" | ":" | "&" | "=" | "+" | "$" | "," )

      hostport      = host [ ":" port ]
      host          = hostname | IPv4address | IPv6reference
      port          = *digit

      IPv6reference = "[" IPv6address "]"
      IPv6address   = hexpart [ ":" IPv4address ]
      IPv4address   = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit
      hexpart       = hexseq | hexseq "::" [ hexseq ] | "::" [ hexseq ]
      hexseq        = hex4 *( ":" hex4)
      hex4          = 1*4hex

      path          = [ abs_path | opaque_part ]
      path_segments = segment *( "/" segment )
      segment       = *pchar *( ";" param )
      param         = *pchar
      pchar         = unreserved | escaped |
                      ":" | "@" | "&" | "=" | "+" | "$" | ","

      query         = *uric

      uric          = reserved | unreserved | escaped
      uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
                      "&" | "=" | "+" | "$" | ","
      reserved      = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                      "$" | "," | "[" | "]"
      unreserved    = alphanum | mark
      mark          = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
      escaped       = "%" hex hex
      unwise        = "{" | "}" | "|" | "\" | "^" | "`"
 

Currently URIs containing userinfo or reg_name are not supported. The opaque_part of a non-hierarchical URI is treated as if if were a path without a leading slash.


Field Summary
protected  boolean hasAuthority
           
protected  String host
           
protected  String path
           
protected  int port
           
protected  String query
           
protected  String scheme
           
protected  String uri
           
 
Constructor Summary
protected Uri()
          Creates an uninitialized Uri object.
  Uri(String uri)
          Creates a Uri object given a URI string.
 
Method Summary
 String getHost()
          Returns the host from the URI's authority part, or null if no host is provided.
 String getPath()
          Returns the URI's path.
 int getPort()
          Returns the port from the URI's authority part, or -1 if no port is provided.
 String getQuery()
          Returns the URI's query part, or null if no query is provided.
 String getScheme()
          Returns the URI's scheme.
protected  void init(String uri)
          Initializes a Uri object given a URI string.
 String toString()
          Returns the URI as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

uri

protected String uri

scheme

protected String scheme

host

protected String host

port

protected int port

hasAuthority

protected boolean hasAuthority

path

protected String path

query

protected String query
Constructor Detail

Uri

public Uri(String uri)
    throws MalformedURLException
Creates a Uri object given a URI string.

Throws:
MalformedURLException

Uri

protected Uri()
Creates an uninitialized Uri object. The init() method must be called before any other Uri methods.

Method Detail

init

protected void init(String uri)
             throws MalformedURLException
Initializes a Uri object given a URI string. This method must be called exactly once, and before any other Uri methods.

Throws:
MalformedURLException

getScheme

public String getScheme()
Returns the URI's scheme.


getHost

public String getHost()
Returns the host from the URI's authority part, or null if no host is provided. If the host is an IPv6 literal, the delimiting brackets are part of the returned value (see URI.getHost()).


getPort

public int getPort()
Returns the port from the URI's authority part, or -1 if no port is provided.


getPath

public String getPath()
Returns the URI's path. The path is never null. Note that a slash following the authority part (or the scheme if there is no authority part) is part of the path. For example, the path of "http://host/a/b" is "/a/b".


getQuery

public String getQuery()
Returns the URI's query part, or null if no query is provided. Note that a query always begins with a leading "?".


toString

public String toString()
Returns the URI as a string.

Overrides:
toString in class Object
Returns:
a string identifying this object.

aicas logo Jamaica 3.4 release 8

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.