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.comparators;
21
22
23 import org.apache.directory.api.i18n.I18n;
24 import org.apache.directory.api.ldap.model.exception.LdapException;
25 import org.apache.directory.api.ldap.model.schema.LdapComparator;
26 import org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30
31
32
33
34
35
36 public class DeepTrimToLowerComparator extends LdapComparator<String>
37 {
38
39 private static final long serialVersionUID = 2L;
40
41
42 private static final Logger LOG = LoggerFactory.getLogger( DeepTrimToLowerComparator.class );
43
44
45
46
47
48
49
50 public DeepTrimToLowerComparator( String oid )
51 {
52 super( oid );
53 normalizer = new DeepTrimToLowerNormalizer();
54 }
55
56
57
58
59
60 public int compare( String key, String value )
61 {
62 String normalizedValue;
63
64 try
65 {
66 normalizedValue = normalizer.normalize( value );
67 }
68 catch ( LdapException e )
69 {
70 if ( LOG.isWarnEnabled() )
71 {
72 LOG.warn( I18n.msg( I18n.MSG_13700_FAILED_TO_NORMALIZE, value ), e );
73 }
74
75 normalizedValue = value;
76 }
77
78 return key.compareTo( normalizedValue );
79 }
80 }