1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.model.schema.registries;
21
22
23 import java.util.Map;
24
25 import org.apache.directory.api.i18n.I18n;
26 import org.apache.directory.api.ldap.model.exception.LdapException;
27 import org.apache.directory.api.ldap.model.schema.Normalizer;
28 import org.apache.directory.api.ldap.model.schema.SchemaObject;
29 import org.apache.directory.api.ldap.model.schema.SchemaObjectType;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33
34
35
36
37
38
39 public class DefaultNormalizerRegistry extends DefaultSchemaObjectRegistry<Normalizer>
40 implements NormalizerRegistry
41 {
42
43 private static final Logger LOG = LoggerFactory.getLogger( DefaultNormalizerRegistry.class );
44
45
46
47
48
49 public DefaultNormalizerRegistry()
50 {
51 super( SchemaObjectType.NORMALIZER, new OidRegistry<Normalizer>() );
52 }
53
54
55
56
57
58 @Override
59 public void unregisterSchemaElements( String schemaName ) throws LdapException
60 {
61 if ( schemaName == null )
62 {
63 return;
64 }
65
66
67
68 for ( Normalizer normalizer : this )
69 {
70 if ( schemaName.equalsIgnoreCase( normalizer.getSchemaName() ) )
71 {
72 String oid = normalizer.getOid();
73 SchemaObject removed = unregister( oid );
74
75 if ( LOG.isDebugEnabled() )
76 {
77 LOG.debug( I18n.msg( I18n.MSG_13702_REMOVED_FROM_REGISTRY, removed, oid ) );
78 }
79 }
80 }
81 }
82
83
84
85
86
87 @Override
88 public DefaultNormalizerRegistry copy()
89 {
90 DefaultNormalizerRegistry copy = new DefaultNormalizerRegistry();
91
92
93 copy.copy( this );
94
95 return copy;
96 }
97
98
99
100
101
102 @Override
103 public String toString()
104 {
105 StringBuilder sb = new StringBuilder();
106
107 sb.append( schemaObjectType ).append( ": " );
108 boolean isFirst = true;
109
110 for ( Map.Entry<String, Normalizer> entry : byName.entrySet() )
111 {
112 if ( isFirst )
113 {
114 isFirst = false;
115 }
116 else
117 {
118 sb.append( ", " );
119 }
120
121 Normalizer normalizer = entry.getValue();
122
123 String fqcn = normalizer.getFqcn();
124 int lastDotPos = fqcn.lastIndexOf( '.' );
125
126 sb.append( '<' ).append( normalizer.getOid() ).append( ", " );
127
128 if ( lastDotPos > 0 )
129 {
130 sb.append( fqcn.substring( lastDotPos + 1 ) );
131 }
132 else
133 {
134 sb.append( fqcn );
135 }
136
137 sb.append( '>' );
138 }
139
140 return sb.toString();
141 }
142 }