On Wed, Jul 8, 2015 at 4:47 PM, Emmanuel Lécharny <[email protected]>
wrote:

> Hi guys,
>
> I'm not sure we have not already implemented a dn.compareTo() method
> somewhere in a utility class...
>
> there is a DnComparator in api-ldap-model module

> Just in case, I'll add it to the API. I think the algorithm for such a
> method would be :
>
> - if both dn are equals, return 0
> - if dn1.isDescendant( dn2 ) return 1
> - if dn2.isDescendant( dn1 ) return -1
>
it doesn't do descendent check, but does plain string comparison
there is a note on why it doesn't use isAncestorOf()
worth improving this if possible rather than adding a new class

> - otherwise, find the common parent
>   - if found, compare the first RDN after the parent in both RDN and
> return the result (Rdn has a compareTo method)
>   - otherwise, compare the first RDN of both DN
>
> sounds good ?
>



-- 
Kiran Ayyagari
http://keydap.com

Reply via email to