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

package org.jfox.jndi;

import java.util.Properties;
import javax.naming.CompoundName;
import javax.naming.Name;
import javax.naming.NameParser;
import javax.naming.NamingException;

/**
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */


public class NameParserImpl implements NameParser, java.io.Serializable {
//  private static Properties syntax = PropertiesHolder.getNSProperties();
    private static Properties syntax = new Properties();

    static {
        syntax.setProperty("jndi.syntax.direction", "left_to_right");
        syntax.setProperty("jndi.syntax.ignorecase", "false");
        syntax.setProperty("jndi.syntax.separator", "/");
        syntax.setProperty("jndi.syntax.trimblanks", "true");
    }

    private static NameParserImpl me = new NameParserImpl();

    private NameParserImpl() {

    }

    /**
     * parse a name to javax.naming.Name
     */

    public Name parse(String name) throws NamingException {
        return new CompoundName(name, syntax);
    }

    public static synchronized NameParserImpl getInstance() {
        return me;
    }

    public static void main(String[] args) throws Exception {
        System.out.println(me.parse("/").toString());
    }
}
