org.openorb.util
Class NamingUtils

java.lang.Object
  |
  +--org.openorb.util.NamingUtils

public abstract class NamingUtils
extends java.lang.Object

The functions in this class perform various tranlations on stringified CosNaming names.

Version:
$Revision: 1.5 $ $Date: 2001/07/18 07:40:21 $
Author:
Chris Wood <wood@intalio.com>

Constructor Summary
NamingUtils()
           
 
Method Summary
static java.lang.String decodeRFC2396(java.lang.String enc)
          Decodes an RFC2396 encoded string.
static void deepBind(NamingContext context, NameComponent[] name, Object obj)
          Binds a objet to a name, creating any required subcontexts.
static void deepBind(NamingContext context, java.lang.String name, Object obj)
          Binds a objet to a name, creating any required subcontexts.
static void deepRebind(NamingContext context, NameComponent[] name, Object obj)
          Binds a objet to a name, creating any required subcontexts.
static void deepRebind(NamingContext context, java.lang.String name, Object obj)
          Binds a objet to a name, creating any required subcontexts.
static java.lang.String encodeRFC2396(java.lang.String str)
          Encodes a string according to RFC2396.
static NameComponent[] parent(NameComponent[] name)
          Get the parent name of the given name.
static java.lang.String parent(java.lang.String name)
          Get the parent name of the given name.
static NamingContext resolveOrCreateContext(NamingContext context, NameComponent[] name)
          Resolve contexts as far as they exist in the name, and create the remainder
static NameComponent[] to_name(java.lang.String sn)
          This operation accepts a stringified name and returns a Name.
static java.lang.String to_string(NameComponent[] n)
          This operation accepts Name and returns a stringified name.
static java.lang.String to_url(java.lang.String addr, java.lang.String sn)
          This operation takes an URL address and performs any escapes necessary on the stringified name and returns a fully formed URL string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamingUtils

public NamingUtils()
Method Detail

deepBind

public static void deepBind(NamingContext context,
                            java.lang.String name,
                            Object obj)
                     throws InvalidName,
                            NotFound,
                            CannotProceed,
                            AlreadyBound
Binds a objet to a name, creating any required subcontexts.
Parameters:
context - The name context root.
name - The name
obj - The object to bind.

deepBind

public static void deepBind(NamingContext context,
                            NameComponent[] name,
                            Object obj)
                     throws InvalidName,
                            NotFound,
                            CannotProceed,
                            AlreadyBound
Binds a objet to a name, creating any required subcontexts.
Parameters:
context - The name context root.
name - The name
obj - The object to bind.

deepRebind

public static void deepRebind(NamingContext context,
                              java.lang.String name,
                              Object obj)
                       throws InvalidName,
                              NotFound,
                              CannotProceed
Binds a objet to a name, creating any required subcontexts.
Parameters:
context - The name context root.
name - The name
obj - The object to bind.

deepRebind

public static void deepRebind(NamingContext context,
                              NameComponent[] name,
                              Object obj)
                       throws InvalidName,
                              NotFound,
                              CannotProceed
Binds a objet to a name, creating any required subcontexts.
Parameters:
context - The name context root.
name - The name
obj - The object to bind.

resolveOrCreateContext

public static NamingContext resolveOrCreateContext(NamingContext context,
                                                   NameComponent[] name)
                                            throws InvalidName,
                                                   NotFound,
                                                   CannotProceed
Resolve contexts as far as they exist in the name, and create the remainder
Parameters:
context - The name context root.
name - The name

to_name

public static NameComponent[] to_name(java.lang.String sn)
                               throws InvalidName
This operation accepts a stringified name and returns a Name.
Parameters:
sn - the stringified name to transform to a name.
Throws:
InvalidName - This exception is raised if the stringified name is syntactically malformed or violates an implementation limit.

to_string

public static java.lang.String to_string(NameComponent[] n)
                                  throws InvalidName
This operation accepts Name and returns a stringified name.
Parameters:
n - the name to stringified.
Throws:
InvalidName - This exception is raised if the name is invalid.

to_url

public static java.lang.String to_url(java.lang.String addr,
                                      java.lang.String sn)
                               throws InvalidAddress,
                                      InvalidName
This operation takes an URL address and performs any escapes necessary on the stringified name and returns a fully formed URL string.
Parameters:
addr - the address ( for example myhost.xyz.com )
sn - the stringified name to add to the URL
Returns:
the URL string format.
Throws:
InvalidAddress - This exception is raises if a address is invalid ( it means that the address does not respect the address format ).
InvalidName - This exception is raised if the stringified name is syntactically malformed or violates an implementation limit.

encodeRFC2396

public static java.lang.String encodeRFC2396(java.lang.String str)
Encodes a string according to RFC2396. All escaped chars use UTF-8 encoding.

decodeRFC2396

public static java.lang.String decodeRFC2396(java.lang.String enc)
Decodes an RFC2396 encoded string.
Parameters:
enc - the string to encode.
Throws:
InvalidArgumentException - the string to decode is formatted incorrectly.

parent

public static NameComponent[] parent(NameComponent[] name)
Get the parent name of the given name. The parent of the empty name will be also empty.
Parameters:
name - the name.

parent

public static java.lang.String parent(java.lang.String name)
Get the parent name of the given name. The parent of the empty name will be also empty. It is assumed that the name is in the correct format.
Parameters:
name - the name.