本文整理汇总了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;
}
示例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();
}
}
示例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;
}
示例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;
}