KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > naming > namingutil > INSURLHandler


1 /*
2  * @(#)INSURLHandler.java 1.5 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package com.sun.corba.se.impl.naming.namingutil;
8
9 import org.omg.CORBA.CompletionStatus JavaDoc;
10 import java.util.StringTokenizer JavaDoc;
11
12 /**
13  * This class is the entry point to parse different types of INS URL's.
14  *
15  * @Author Hemanth
16  */

17
18 public class INSURLHandler {
19
20     private static INSURLHandler insURLHandler = null;
21
22     // Length of corbaloc:
23
private static final int CORBALOC_PREFIX_LENGTH = 9;
24
25     // Length of corbaname:
26
private static final int CORBANAME_PREFIX_LENGTH = 10;
27
28     private INSURLHandler( ) {
29     }
30
31     public synchronized static INSURLHandler getINSURLHandler( ) {
32         if( insURLHandler == null ) {
33             insURLHandler = new INSURLHandler( );
34         }
35         return insURLHandler;
36     }
37
38     public INSURL parseURL( String JavaDoc aUrl ) {
39         String JavaDoc url = aUrl;
40         if ( url.startsWith( "corbaloc:" ) == true ) {
41             return new CorbalocURL( url.substring( CORBALOC_PREFIX_LENGTH ) );
42         } else if ( url.startsWith ( "corbaname:" ) == true ) {
43             return new CorbanameURL( url.substring( CORBANAME_PREFIX_LENGTH ) );
44         }
45         return null;
46     }
47 }
48
Popular Tags