KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ldap > server > prefs > PreferencesUtils


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.ldap.server.prefs;
18
19
20 import org.apache.ldap.common.name.LdapName;
21
22 import javax.naming.Name JavaDoc;
23 import javax.naming.NamingException JavaDoc;
24
25
26 /**
27  * Document this class.
28  *
29  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
30  * @version $Rev$
31  */

32 public class PreferencesUtils
33 {
34     /** the dn base of the system preference hierarchy */
35     static final String JavaDoc SYSPREF_BASE = "prefNodeName=sysPrefRoot,ou=system";
36
37
38     /**
39      * Translates an absolute system preferences node name into the distinguished
40      * name of the entry corresponding to the preferences node.
41      *
42      * @param absPrefPath the absolute path to the system preferences node
43      * @return the distinguished name of the entry representing the system preferences node
44      * @throws NamingException if there are namespace problems while translating the path
45      */

46     public static Name toSysDn( String JavaDoc absPrefPath ) throws NamingException JavaDoc
47     {
48         LdapName dn = new LdapName( SYSPREF_BASE );
49
50         String JavaDoc[] comps = absPrefPath.split( "/" );
51
52         for ( int ii = 0; ii < comps.length; ii++ )
53         {
54             if ( comps[ii] != null && ! comps[ii].trim().equals( "" ) )
55             {
56                 dn.add( "prefNodeName=" + comps[ii] );
57             }
58         }
59
60         return dn;
61     }
62 }
63
Popular Tags