/** * {@inheritDoc} */ public int compareTo( DN dn ) { if ( dn.size() != size() ) { return size() - dn.size(); } for ( int i = rdns.size(); i > 0; i-- ) { RDN rdn1 = rdns.get( i - 1 ); RDN rdn2 = dn.rdns.get( i - 1 ); int res = rdn1.compareTo( rdn2 ); if ( res != 0 ) { return res; } } return EQUAL; }
/** * 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; }
/** * Copies a DN to an DN. * * @param name composed of String name components. * @throws LdapInvalidDnException If the Name is invalid. */ public DN( DN dn ) throws LdapInvalidDnException { if ( ( dn != null ) && ( dn.size() != 0 ) ) { for ( int ii = 0; ii < dn.size(); ii++ ) { String nameComponent = dn.get( ii ); add( nameComponent ); } } normalized = false; }
/** * {@inheritDoc} */ public RDN remove( int posn ) throws LdapInvalidDnException { if ( rdns.size() == 0 ) { return RDN.EMPTY_RDN; } if ( ( posn < 0 ) || ( posn >= rdns.size() ) ) { String message = I18n.err( I18n.ERR_04206, posn, rdns.size() ); LOG.error( message ); throw new ArrayIndexOutOfBoundsException( message ); } int realPos = size() - posn - 1; RDN rdn = rdns.remove( realPos ); normalizeInternal(); toUpName(); return rdn; }
/** * {@inheritDoc} */ public DN getSuffix( int posn ) { if ( rdns.size() == 0 ) { return EMPTY_DN; } if ( ( posn < 0 ) || ( posn > rdns.size() ) ) { String message = I18n.err( I18n.ERR_04206, posn, rdns.size() ); LOG.error( message ); throw new ArrayIndexOutOfBoundsException( message ); } DN newDN = new DN(); for ( int i = 0; i < size() - posn; i++ ) { // Don't forget to clone the rdns ! newDN.rdns.add( ( RDN ) rdns.get( i ).clone() ); } newDN.normName = newDN.toNormName(); newDN.upName = getUpNameSuffix( posn ); return newDN; }
/** * {@inheritDoc} */ public DN add( int posn, String comp ) throws LdapInvalidDnException { if ( ( posn < 0 ) || ( posn > size() ) ) { String message = I18n.err( I18n.ERR_04206, posn, rdns.size() ); LOG.error( message ); throw new ArrayIndexOutOfBoundsException( message ); } //FIXME this try-catch block is for the time being, during removal of // java.naming.Name we have to remove this try { // We have to parse the nameComponent which is given as an argument RDN newRdn = new RDN( comp ); int realPos = size() - posn; rdns.add( realPos, newRdn ); } catch( LdapInvalidDnException le ) { throw new LdapInvalidDnException( le.getMessage() ); } normalizeInternal(); toUpName(); return this; }
/** * {@inheritDoc} */ public DN addAll( int posn, DN dn ) throws LdapInvalidDnException { if ( ( dn == null ) || ( dn.size() == 0 ) ) { return this; } // Concatenate the rdns rdns.addAll( size() - posn, dn.rdns ); // Regenerate the normalized name and the original string if ( this.isNormalized() && dn.isNormalized() ) { if ( this.size() != 0 ) { normName = dn.getNormName() + "," + normName; bytes = StringTools.getBytesUtf8( normName ); upName = dn.getName() + "," + upName; } } else { normalizeInternal(); toUpName(); } return this; }
if ( ( dn == null ) || ( dn.size() == 0 ) || ( oidsMap == null ) || ( oidsMap.size() == 0 ) )
if ( size() == 0 )
/** * {@inheritDoc} */ public DN addAll( int posn, Name name ) throws InvalidNameException, LdapInvalidDnException { if ( ( name == null ) || ( name.size() == 0 ) ) { return this; } for ( int i = name.size() - 1; i >= 0; i-- ) { RDN rdn = new RDN( name.get( i ) ); rdns.add( size() - posn, rdn ); } normalizeInternal(); toUpName(); return this; }
ancestorDn.remove( aliasDN.size() - 1 ); Long ancestorId = getEntryId( ancestorDn.getNormName() ); subAliasIdx.drop( ancestorId, targetId ); while ( !ancestorDn.equals( suffixDn ) && ancestorDn.size() > suffixDn.size() ) ancestorDn = ( DN ) ancestorDn.getPrefix( ancestorDn.size() - 1 ); ancestorId = getEntryId( ancestorDn.getNormName() );
for ( int ii = 0; ii < ancestor.size(); ii++ )
oldSuperior.remove( oldSuperior.size() - 1 ); reverted.setNewSuperior( oldSuperior.getName() );
oldSuperior.remove( oldSuperior.size() - 1 ); reverted.setNewSuperior( oldSuperior.getName() );