com.novell.sentinel.uri
Class GenericURI.Authority

java.lang.Object
  extended by com.novell.sentinel.uri.GenericURI.Authority
Enclosing class:
GenericURI

public static class GenericURI.Authority
extends Object

A class that manages the authority component of a URI.


Field Summary
static PercentCodex HOST_CODEX
          An encoder that encodes a non-IPv6 literal host information part of the authority component.
static PercentCodex IPV6_CODEX
          An encoder that encodes an IPv6 literal address part of the authority component.
static PercentCodex USER_CODEX
          An encoder that encodes the user information part of the authority component.
 
Constructor Summary
GenericURI.Authority()
          Construct an empty instance.
GenericURI.Authority(GenericURI.Authority src)
          Construct a new deep-copy instance from the information in the passed instance.
GenericURI.Authority(String authority)
          Construct an instance based on parsing the passed, raw, encoded authority component.
GenericURI.Authority(String host, int port)
          Construct an instance using the passed host and port as the authority information.
GenericURI.Authority(String user, String host, int port)
          Construct an instance using the passed user information, host, and port as the authority information.
 
Method Summary
 String getHost()
          Get the host information stored in this instance.
 int getPort()
          Get the port stored in this instance.
 String getRaw()
          Get the raw, unparsed, unencoded authority component string used to construct this instance, if any.
 String getUserInfo()
          Get the user information stored in this instance.
 boolean isEmpty()
          Return true if this instance is empty.
protected  void parse(String authority)
          Parse the passed raw string into the user info, host, and port.
 void set(String authority)
          Set the data from the passed raw, encoded authority component.
 void set(String host, int port)
          Set the host and port.
 void set(String user, String host, int port)
          Set the user information, host, and port.
 void setHost(String host)
          Set the host information.
 void setPort(int port)
          Set the port number.
protected  void setRaw(String rawAuthority)
          Set the raw string.
 void setUserInfo(String userInfo)
          Set the user information string.
 String toString()
          Output this instance as an encoded authority component of a URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

USER_CODEX

public static final PercentCodex USER_CODEX
An encoder that encodes the user information part of the authority component. The reserved characters (those that are percent encoded in a constructed URI string) are: '/', '?', '#', '[', ']', '@'.


HOST_CODEX

public static final PercentCodex HOST_CODEX
An encoder that encodes a non-IPv6 literal host information part of the authority component. The reserved characters (those that are percent encoded in a constructed URI string) are: ':', '/', '?', '#', '[', ']', '@'.


IPV6_CODEX

public static final PercentCodex IPV6_CODEX
An encoder that encodes an IPv6 literal address part of the authority component. The reserved characters (those that are percent encoded in a constructed URI string) are: '/', '?', '#', '[', ']', '@'.

Constructor Detail

GenericURI.Authority

public GenericURI.Authority()
Construct an empty instance.


GenericURI.Authority

public GenericURI.Authority(String authority)
Construct an instance based on parsing the passed, raw, encoded authority component.

Parameters:
authority - The authority component.

GenericURI.Authority

public GenericURI.Authority(String host,
                            int port)
Construct an instance using the passed host and port as the authority information.

Parameters:
host - The host name or address literal.
port - The port number.

GenericURI.Authority

public GenericURI.Authority(String user,
                            String host,
                            int port)
Construct an instance using the passed user information, host, and port as the authority information.

Parameters:
user - The user information.
host - The host name or address literal.
port - The port number.

GenericURI.Authority

public GenericURI.Authority(GenericURI.Authority src)
Construct a new deep-copy instance from the information in the passed instance.

Parameters:
src - The instance to copy.
Method Detail

isEmpty

public boolean isEmpty()
Return true if this instance is empty. The instance is considered non-empty only if there is a non-null, non-empty host identifier.

Returns:
true if empty.

toString

public String toString()
Output this instance as an encoded authority component of a URI.

Overrides:
toString in class Object

set

public void set(String authority)
Set the data from the passed raw, encoded authority component.

Parameters:
authority - The authority component string.

set

public void set(String host,
                int port)
Set the host and port.


set

public void set(String user,
                String host,
                int port)
Set the user information, host, and port.


getUserInfo

public String getUserInfo()
Get the user information stored in this instance.

Returns:
The user information string, or null.

setUserInfo

public void setUserInfo(String userInfo)
Set the user information string.


getHost

public String getHost()
Get the host information stored in this instance.


setHost

public void setHost(String host)
Set the host information.


getPort

public int getPort()
Get the port stored in this instance.

Returns:
The port number. -1 means the port has not been set.

setPort

public void setPort(int port)
Set the port number.


getRaw

public String getRaw()
Get the raw, unparsed, unencoded authority component string used to construct this instance, if any. If any structured setter has been used (i.e., any setter other than set(String)) then there is no raw information.

Returns:
The raw authority component string, or null.

setRaw

protected void setRaw(String rawAuthority)
Set the raw string. This is designed to be used in conjunction with the various setters. If a structured setter is used, the raw data should be set to null.

Parameters:
rawAuthority - The string to set, or null.

parse

protected void parse(String authority)
Parse the passed raw string into the user info, host, and port.

Parameters:
authority - The raw string.