< prev index next >

src/java.corba/share/classes/com/sun/jndi/cosnaming/CorbanameUrl.java

Print this page




  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.jndi.cosnaming;
  27 
  28 import javax.naming.Name;
  29 import javax.naming.NamingException;
  30 
  31 import java.net.MalformedURLException;
  32 import com.sun.jndi.toolkit.url.UrlUtil;
  33 
  34 /**
  35  * Extract components of a "corbaname" URL.
  36  *
  37  * The format of an corbaname URL is defined in INS 99-12-03 as follows.
  38  *<p>
  39  * corbaname url = "corbaname:" <corbaloc_obj> ["#" <string_name>]
  40  * corbaloc_obj  = <obj_addr_list> ["/" <key_string>]
  41  * obj_addr_list = as defined in a corbaloc URL
  42  * key_string    = as defined in a corbaloc URL
  43  * string_name   = stringified COS name | empty_string
  44  *<p>
  45  * Characters in <string_name> are escaped as follows.
  46  * US-ASCII alphanumeric characters are not escaped. Any characters outside
  47  * of this range are escaped except for the following:

  48  *        ; / : ? @ & = + $ , - _ . ! ~ * ; ( )

  49  * Escaped characters is escaped by using a % followed by its 2 hexadecimal
  50  * numbers representing the octet.
  51  *<p>
  52  * The corbaname URL is parsed into two parts: a corbaloc URL and a COS name.
  53  * The corbaloc URL is constructed by concatenation "corbaloc:" with
  54  * <corbaloc_obj>.
  55  * The COS name is <string_name> with the escaped characters resolved.
  56  *<p>
  57  * A corbaname URL is resolved by:
  58  *<ol>
  59  *<li>Construct a corbaloc URL by concatenating "corbaloc:" and <corbaloc_obj>.
  60  *<li>Resolve the corbaloc URL to a NamingContext by using

  61  *     nctx = ORB.string_to_object(corbalocUrl);
  62  *<li>Resolve <string_name> in the NamingContext.
  63  *</ol>

  64  *
  65  * @author Rosanna Lee
  66  */
  67 
  68 public final class CorbanameUrl {
  69     private String stringName;
  70     private String location;
  71 
  72     /**
  73      * Returns a possibly empty but non-null string that is the "string_name"
  74      * portion of the URL.
  75      */
  76     public String getStringName() {
  77         return stringName;
  78     }
  79 
  80     public Name getCosName() throws NamingException {
  81         return CNCtx.parser.parse(stringName);
  82     }
  83 




  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.jndi.cosnaming;
  27 
  28 import javax.naming.Name;
  29 import javax.naming.NamingException;
  30 
  31 import java.net.MalformedURLException;
  32 import com.sun.jndi.toolkit.url.UrlUtil;
  33 
  34 /**
  35  * Extract components of a "corbaname" URL.
  36  *
  37  * The format of an corbaname URL is defined in INS 99-12-03 as follows.
  38  * <pre>{@code
  39  * corbaname url = "corbaname:" <corbaloc_obj> ["#" <string_name>]
  40  * corbaloc_obj  = <obj_addr_list> ["/" <key_string>]
  41  * obj_addr_list = as defined in a corbaloc URL
  42  * key_string    = as defined in a corbaloc URL
  43  * string_name   = stringified COS name | empty_string
  44  * }</pre>
  45  * Characters in {@code <string_name>} are escaped as follows.
  46  * US-ASCII alphanumeric characters are not escaped. Any characters outside
  47  * of this range are escaped except for the following:
  48  * <pre>{@code
  49  *        ; / : ? @ & = + $ , - _ . ! ~ * ; ( )
  50  * }</pre>
  51  * Escaped characters is escaped by using a % followed by its 2 hexadecimal
  52  * numbers representing the octet.
  53  * <p>
  54  * The corbaname URL is parsed into two parts: a corbaloc URL and a COS name.
  55  * The corbaloc URL is constructed by concatenation {@code "corbaloc:"} with
  56  * {@code <corbaloc_obj>}.
  57  * The COS name is {@code <string_name>} with the escaped characters resolved.
  58  * <p>
  59  * A corbaname URL is resolved by:
  60  * <ol>
  61  * <li>Construct a corbaloc URL by concatenating {@code "corbaloc:"} and {@code <corbaloc_obj>}.
  62  * <li>Resolve the corbaloc URL to a NamingContext by using
  63  * <pre>{@code
  64  *     nctx = ORB.string_to_object(corbalocUrl);
  65  * }</pre>
  66  * <li>Resolve {@code <string_name>} in the NamingContext.
  67  * </ol>
  68  *
  69  * @author Rosanna Lee
  70  */
  71 
  72 public final class CorbanameUrl {
  73     private String stringName;
  74     private String location;
  75 
  76     /**
  77      * Returns a possibly empty but non-null string that is the "string_name"
  78      * portion of the URL.
  79      */
  80     public String getStringName() {
  81         return stringName;
  82     }
  83 
  84     public Name getCosName() throws NamingException {
  85         return CNCtx.parser.parse(stringName);
  86     }
  87 


< prev index next >