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


Java Dn.getRdns方法代码示例

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


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

示例1: hasParent

import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
 * Tells if there is a parent for a given Dn,. This parent should be a
 * subset of the given dn.<br>
 * For instance, if we have stored dc=acme, dc=org into the tree,
 * the Dn: ou=example, dc=acme, dc=org will have a parent
 * <br>For the Dn ou=apache, dc=org, there is no parent, so false will be returned.
 *
 * @param dn the normalized distinguished name to resolve to a parent
 * @return true if there is a parent associated with the normalized dn
 */
public synchronized boolean hasParent( Dn dn )
{
    List<Rdn> rdns = dn.getRdns();

    DnNode<N> currentNode = this;
    DnNode<N> parentNode = null;

    // Iterate through all the Rdn until we find the associated element
    for ( int i = rdns.size() - 1; i >= 0; i-- )
    {
        Rdn rdn = rdns.get( i );

        if ( rdn.equals( currentNode.nodeRdn ) )
        {
            parentNode = currentNode;
        }
        else if ( currentNode.hasChildren() )
        {
            currentNode = currentNode.children.get( rdn.getNormName() );

            if ( currentNode == null )
            {
                break;
            }

            parentNode = currentNode;
        }
        else
        {
            break;
        }
    }

    return parentNode != null;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:46,代码来源:DnNode.java

示例2: remove

import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
 * Removes a node from the tree.
 *
 * @param dn the node's Dn
 * @throws LdapException if the Dn is null or empty
 */
public synchronized void remove( Dn dn ) throws LdapException
{
    checkDn( dn );

    // Find the parent first : we won't be able to remove
    // a node if it's not present in the tree !
    DnNode<N> parentNode = getNode( dn );

    if ( parentNode == null )
    {
        return;
    }

    // Now, check that this parent has the same Dn than the one
    // we gave and that there is no children
    if ( ( dn.size() != parentNode.depth ) || parentNode.hasChildren() )
    {
        return;
    }

    // Ok, no children, same Dn, let's remove what we can.
    parentNode = parentNode.getParent();

    for ( Rdn rdn : dn.getRdns() )
    {
        parentNode.children.remove( rdn.getNormName() );

        if ( parentNode.children.size() > 0 )
        {
            // We have to stop here, because the parent's node is shared with other Node.
            break;
        }

        parentNode = parentNode.getParent();
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:43,代码来源:DnNode.java

示例3: hasParentElement

import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
 * Get the closest Node for a given Dn which has an element, if present in the tree.<br>
 * For instance, if we have stored dc=acme, dc=org into the tree,
 * the Dn: ou=example, dc=acme, dc=org will have a parent, and
 * dc=acme, dc=org will be returned if it has an associated element.
 * <br>For the Dn ou=apache, dc=org, there is no parent, so null will be returned.
 *
 * @param dn the normalized distinguished name to resolve to a parent
 * @return the Node associated with the normalized dn
 */
public synchronized boolean hasParentElement( Dn dn )
{
    List<Rdn> rdns = dn.getRdns();

    DnNode<N> currentNode = this;
    boolean hasElement = false;

    // Iterate through all the Rdn until we find the associated partition
    for ( int i = rdns.size() - 1; i >= 0; i-- )
    {
        Rdn rdn = rdns.get( i );

        if ( currentNode.hasChildren() )
        {
            currentNode = currentNode.children.get( rdn.getNormName() );

            if ( currentNode == null )
            {
                break;
            }

            if ( currentNode.hasElement() )
            {
                hasElement = true;
            }

            parent = currentNode;
        }
        else
        {
            break;
        }
    }

    return hasElement;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:47,代码来源:DnNode.java

示例4: getParentWithElement

import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
 * Get the closest Node for a given Dn which has an element, if present in the tree.<br>
 * For instance, if we have stored dc=acme, dc=org into the tree,
 * the Dn: ou=example, dc=acme, dc=org will have a parent, and
 * dc=acme, dc=org will be returned if it has an associated element.
 * <br>For the Dn ou=apache, dc=org, there is no parent, so null will be returned.
 *
 * @param dn the normalized distinguished name to resolve to a parent
 * @return the Node associated with the normalized dn
 */
public synchronized DnNode<N> getParentWithElement( Dn dn )
{
    List<Rdn> rdns = dn.getRdns();

    DnNode<N> currentNode = this;
    DnNode<N> element = null;

    // Iterate through all the Rdn until we find the associated partition
    for ( int i = rdns.size() - 1; i >= 1; i-- )
    {
        Rdn rdn = rdns.get( i );

        if ( currentNode.hasChildren() )
        {
            currentNode = currentNode.children.get( rdn.getNormName() );

            if ( currentNode == null )
            {
                break;
            }

            if ( currentNode.hasElement() )
            {
                element = currentNode;
            }

            parent = currentNode;
        }
        else
        {
            break;
        }
    }

    return element;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:47,代码来源:DnNode.java


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