01: package org.mockejb.jndi;
02:
03: import javax.naming.*;
04: import java.util.Properties;
05:
06: /**
07: * MockContext name parser.
08: * @author Dimitar Gospodinov
09: */
10: class MockContextNameParser implements NameParser {
11:
12: private static final Properties syntax = new Properties();
13: static {
14: syntax.put("jndi.syntax.direction", "left_to_right");
15: syntax.put("jndi.syntax.separator", "/");
16: syntax.put("jndi.syntax.ignorecase", "false");
17: syntax.put("jndi.syntax.trimblanks", "yes");
18: }
19:
20: /**
21: * Parses <code>name</code> into <code>CompoundName</code> using the following
22: * <code>CompoundName</code> properties:
23: * <p>
24: * jndi.syntax.direction = "left_to_right"
25: * jndi.syntax.separator = "/"
26: * jndi.syntax.ignorecase = "false"
27: * jndi.syntax.trimblanks = "yes"
28: * <p>
29: * Any characters '.' in the name <code>name</code> will be replaced with the
30: * separator character specified above, before parsing.
31: * @param name name to parse
32: * @throws NamingException if naming error occurrs
33: */
34: public Name parse(String name) throws NamingException {
35: return new CompoundName(name.replace('.', '/'), syntax);
36: }
37: }
|