01: package com.flexive.war.webdav;
02:
03: /*
04: * JBoss, the OpenSource J2EE webOS
05: *
06: * Distributable under LGPL license.
07: * See terms of license at gnu.org.
08: */
09:
10: import javax.naming.*;
11: import java.util.Enumeration;
12: import java.util.Properties;
13:
14: /**
15: * A simple subclass of CompoundName that fixes the name syntax to:
16: * jndi.syntax.direction = left_to_right
17: * jndi.syntax.separator = "/"
18: *
19: * @author Scott_Stark@displayscape.com
20: * @version $Rev: 1 $
21: */
22: public class DefaultName extends CompoundName {
23: /**
24: * The Properties used for the project directory heirarchical names
25: */
26: static Name emptyName;
27: static Properties nameSyntax = new Properties();
28:
29: static {
30: nameSyntax.put("jndi.syntax.direction", "left_to_right");
31: nameSyntax.put("jndi.syntax.separator", "/");
32: try {
33: emptyName = new DefaultName("");
34: } catch (InvalidNameException e) {
35: }
36: }
37:
38: private static class DefaultNameParser implements NameParser {
39: public Name parse(String path) throws NamingException {
40: DefaultName name = new DefaultName(path);
41: return name;
42: }
43: }
44:
45: public static NameParser getNameParser() {
46: return new DefaultNameParser();
47: }
48:
49: /**
50: * Creates new DefaultName
51: */
52: public DefaultName(Enumeration comps) {
53: super (comps, nameSyntax);
54: }
55:
56: public DefaultName(String name) throws InvalidNameException {
57: super (name, nameSyntax);
58: }
59:
60: public DefaultName(Name name) {
61: super (name.getAll(), nameSyntax);
62: }
63:
64: public DefaultName() {
65: this(emptyName);
66: }
67:
68: }
|