KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ldap > server > interceptor > InterceptorConfigBuilder


1 package org.apache.ldap.server.interceptor;
2
3
4 import java.util.HashMap JavaDoc;
5 import java.util.Iterator JavaDoc;
6 import java.util.Map JavaDoc;
7
8
9 /**
10  * @todo doc me
11  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
12  * @version $Rev: 169198 $, $Date: 2005-05-08 20:05:59 -0400 (Sun, 08 May 2005) $
13  */

14
15 public class InterceptorConfigBuilder
16 {
17
18     public static Map JavaDoc build( Map JavaDoc map, String JavaDoc prefix )
19     {
20         Map JavaDoc newMap = new HashMap JavaDoc();
21
22         Iterator JavaDoc it = map.entrySet().iterator();
23
24         while ( it.hasNext() )
25         {
26             Map.Entry JavaDoc e = ( Map.Entry JavaDoc ) it.next();
27
28             String JavaDoc key = e.getKey().toString();
29
30             if ( key.startsWith( prefix ) && key.length() > prefix.length() )
31             {
32                 key = key.substring( prefix.length() );
33
34                 if ( key.indexOf( '#' ) < 0 )
35                 {
36                     continue;
37                 }
38
39                 if ( key.charAt( 0 ) == '.' || key.charAt( 0 ) == '#' )
40                 {
41                     key = key.substring( 1 );
42                 }
43
44                 newMap.put( key, e.getValue() );
45             }
46         }
47
48         return newMap;
49     }
50
51
52     private InterceptorConfigBuilder()
53     {
54     }
55 }
56
Popular Tags