directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel L├ęcharny <>
Subject Re: Prepare String
Date Tue, 05 Apr 2016 08:48:14 GMT
One more step !

Yesterday evening, I as able to work on the DeepTrimToLowerNormalizer
class, which is used to deal with the caseIgnoreMatch MatchingRule (the
most crequent Matching Rule), and I discovered that the java
Normalizer.normalize() method was already handling the combining
characters, which is otherwise a nightmare to handle (well, not that
much, but still). That will simplify the insignificantSpaceHandling
process a LOT.

Here is what will look like the DeepTrimToLowerNormalizer.normalize(
Value ) method :

    public Value normalize( Value value, PrepareString.AssertionType
assertionType ) throws LdapException
        if ( value == null )
            return null;

            // Transcoding
            String transcoded = PrepareString.transcode( value.getBytes() );

            // Map
            String mapped = value,
PrepareString.IGNORE_CASE );
            // Normalize
            String normalized = PrepareString.normalize( mapped );
            // Prohibit
            PrepareString.checkProhibited( normalized );
            // Bidi is ignored
            // Insignificant Characters Handling
            String normValue = PrepareString.insignificantSpaceHandling(
normalized, assertionType );

            return new Value( value.getAttributeType(),
value.getValue(), normalized );
        catch ( IOException ioe )
            throw new LdapInvalidAttributeValueException(
                I18n.ERR_04224, value ), ioe );

Note that this method work only for Values or non-substrings assertions
(ie, assertions used in a filter that is not a SubstringFilter). For
substrings assertions (Initial, Any or Final, like the strings in a
filter '(cn=test*abc*end)'), we have to add a new parameter to the
normalize method. I'll deal with that later.

As you can see, this is all but simple... Making my way through the
jungle though ;-)

But first, a day job !

View raw message