KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > jndi > NameParserImpl


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6
7 package org.jfox.jndi;
8
9 import java.util.Properties JavaDoc;
10 import javax.naming.CompoundName JavaDoc;
11 import javax.naming.Name JavaDoc;
12 import javax.naming.NameParser JavaDoc;
13 import javax.naming.NamingException JavaDoc;
14
15 /**
16  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
17  */

18
19
20 public class NameParserImpl implements NameParser JavaDoc, java.io.Serializable JavaDoc {
21 // private static Properties syntax = PropertiesHolder.getNSProperties();
22
private static Properties JavaDoc syntax = new Properties JavaDoc();
23
24     static {
25         syntax.setProperty("jndi.syntax.direction", "left_to_right");
26         syntax.setProperty("jndi.syntax.ignorecase", "false");
27         syntax.setProperty("jndi.syntax.separator", "/");
28         syntax.setProperty("jndi.syntax.trimblanks", "true");
29     }
30
31     private static NameParserImpl me = new NameParserImpl();
32
33     private NameParserImpl() {
34
35     }
36
37     /**
38      * parse a name to javax.naming.Name
39      */

40
41     public Name JavaDoc parse(String JavaDoc name) throws NamingException JavaDoc {
42         return new CompoundName JavaDoc(name, syntax);
43     }
44
45     public static synchronized NameParserImpl getInstance() {
46         return me;
47     }
48
49     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
50         System.out.println(me.parse("/").toString());
51     }
52 }
53
Popular Tags