当前位置: 首页>>代码示例>>Java>>正文


Java Dn.equals方法代码示例

本文整理汇总了Java中org.apache.directory.api.ldap.model.name.Dn.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Dn.equals方法的具体用法?Java Dn.equals怎么用?Java Dn.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.directory.api.ldap.model.name.Dn的用法示例。


在下文中一共展示了Dn.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: equals

import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean equals( Object obj )
{
    if ( obj == this )
    {
        return true;
    }

    if ( ( obj == null ) || !( obj instanceof BindRequest ) )
    {
        return false;
    }

    if ( !super.equals( obj ) )
    {
        return false;
    }

    BindRequest req = ( BindRequest ) obj;

    if ( req.isSimple() != isSimple() )
    {
        return false;
    }

    if ( req.isVersion3() != isVersion3() )
    {
        return false;
    }

    String name1 = req.getName();
    String name2 = getName();

    if ( Strings.isEmpty( name1 ) )
    {
        if ( !Strings.isEmpty( name2 ) )
        {
            return false;
        }
    }
    else
    {
        if ( Strings.isEmpty( name2 ) )
        {
            return false;
        }
        else if ( !name2.equals( name1 ) )
        {
            return false;
        }
    }

    Dn dn1 = req.getDn();
    Dn dn2 = getDn();

    if ( Dn.isNullOrEmpty( dn1 ) )
    {
        if ( !Dn.isNullOrEmpty( dn2 ) )
        {
            return false;
        }
    }
    else
    {
        if ( Dn.isNullOrEmpty( dn2 ) )
        {
            return false;
        }
        else if ( !dn1.equals( dn2 ) )
        {
            return false;
        }
    }

    return Arrays.equals( req.getCredentials(), getCredentials() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:80,代码来源:BindRequestImpl.java

示例2: compare

import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public int compare( Object obj0, Object obj1 )
{
    Dn dn0 = null;
    Dn dn1 = null;

    try
    {
        dn0 = getDn( obj0 );
        dn1 = getDn( obj1 );
    }
    catch ( LdapException e )
    {
        // -- what do we do here ?
        return -1;
    }

    int dn0Size = dn0.getRdns().size();
    int dn1Size = dn1.getRdns().size();
    
    // check the equality first, cause
    // when both DNs are equal checking isAncestorOf() returns true
    if ( dn0.equals( dn1 ) )
    {
        return 0;
    }
    else if ( dn0Size > dn1Size )
    {
        return -1;
    }
    else if ( dn1Size > dn0Size )
    {
        return 1;
    }

    for ( int i = dn0Size - 1; i >= 0; i-- )
    {
        int comp = dn0.getRdn( i ).compareTo( dn1.getRdn( i ) );
        
        if ( comp != 0 )
        {
            return comp;
        }
    }
    
    return 0;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:51,代码来源:ParsedDnComparator.java

示例3: compare

import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public int compare( Object obj0, Object obj1 )
{
    if ( ( obj0 instanceof String ) && ( obj1 instanceof String ) )
    {
        return compare( ( String ) obj0, ( String ) obj1 );
    }
    
    Dn dn0 = null;
    Dn dn1 = null;

    try
    {
        dn0 = getDn( obj0 );
        dn1 = getDn( obj1 );
    }
    catch ( LdapException e )
    {
        // -- what do we do here ?
        return -1;
    }

    int dn0Size = dn0.getRdns().size();
    int dn1Size = dn1.getRdns().size();
    
    // check the equality first, cause
    // when both DNs are equal checking isAncestorOf() returns true
    if ( dn0.equals( dn1 ) )
    {
        return 0;
    }
    else if ( dn0Size > dn1Size )
    {
        return -1;
    }
    else if ( dn1Size > dn0Size )
    {
        return 1;
    }

    for ( int i = dn0Size - 1; i >= 0; i-- )
    {
        int comp = dn0.getRdn( i ).compareTo( dn1.getRdn( i ) );
        
        if ( comp != 0 )
        {
            return comp;
        }
    }
    
    return 0;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:56,代码来源:DnComparator.java

示例4: moveAndRename

import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
{
    // Check the parameters first
    if ( entryDn == null )
    {
        throw new IllegalArgumentException( "The entry Dn must not be null" );
    }

    if ( entryDn.isRootDse() )
    {
        throw new IllegalArgumentException( "The RootDSE cannot be moved" );
    }

    if ( newDn == null )
    {
        throw new IllegalArgumentException( "The new Dn must not be null" );
    }

    if ( newDn.isRootDse() )
    {
        throw new IllegalArgumentException( "The RootDSE cannot be the target" );
    }

    // Create the request
    ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
    modDnRequest.setName( entryDn );
    modDnRequest.setNewRdn( newDn.getRdn() );
    
    // Check if we really need to specify newSuperior.
    // newSuperior is optional [RFC4511, section 4.9]
    // Some servers (e.g. OpenDJ 2.6) require a special privilege if
    // newSuperior is specified even if it is the same as the old one. Therefore let's not
    // specify it if we do not need it. This is better interoperability. 
    Dn newDnParent = newDn.getParent();
    if ( newDnParent != null && !newDnParent.equals( entryDn.getParent() ) )
    {
        modDnRequest.setNewSuperior( newDnParent );
    }
    
    modDnRequest.setDeleteOldRdn( deleteOldRdn );

    ModifyDnResponse modifyDnResponse = modifyDn( modDnRequest );

    processResponse( modifyDnResponse );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:50,代码来源:LdapNetworkConnection.java


注:本文中的org.apache.directory.api.ldap.model.name.Dn.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。