/** * Tests to see if a candidate entry is a descendant of a base. * * @param ancestor the base ancestor * @param descendant the candidate to test for descendancy * @return true if the candidate is a descendant */ public static boolean isDescendant( DN ancestor, DN descendant ) { return descendant.isChildOf( ancestor ); }
/** * Tells if the current DN is a parent of another DN.<br> * For instance, <b>dc=com</b> is a parent * of <b>dc=example, dc=com</b> * * @param dn The child * @return true if the current DN is a parent of the given DN */ public boolean isParentOf( DN dn ) { if ( dn == null ) { return false; } return dn.isChildOf( this ); }
/** * Tells if a DN is a child of another DN.<br> * For instance, <b>dc=example, dc=com</b> is a child * of <b>dc=com</b> * * @param dn The parent * @return true if the current DN is a child of the given DN */ public boolean isChildOf( String dn ) { try { return isChildOf( new DN( dn ) ); } catch( LdapInvalidDnException lide ) { return false; } }
/** * Checks to see if two names are siblings. * * @param name1 the first name * @param name2 the second name * @return true if the names are siblings, false otherwise. */ public static boolean isSibling( DN name1, DN name2 ) throws LdapInvalidDnException { if ( name1.size() == name2.size() ) { DN parentDn = ( DN ) name1.clone(); parentDn.remove( name1.size() - 1 ); return name2.isChildOf( parentDn ); } return false; }
if ( rdn.isChildOf( ancestor ) )