本文整理汇总了Java中org.apache.directory.api.ldap.model.name.Dn.isDescendantOf方法的典型用法代码示例。如果您正苦于以下问题:Java Dn.isDescendantOf方法的具体用法?Java Dn.isDescendantOf怎么用?Java Dn.isDescendantOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.ldap.model.name.Dn
的用法示例。
在下文中一共展示了Dn.isDescendantOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: anonymizeDn
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
* Anonymize the entry's DN
*/
private Dn anonymizeDn( Dn entryDn ) throws LdapException
{
// Search for the naming context
Dn descendant = entryDn;
Dn namingContext = null;
for ( Dn nc : namingContexts )
{
if ( entryDn.isDescendantOf( nc ) )
{
descendant = entryDn.getDescendantOf( nc );
namingContext = nc;
break;
}
}
Rdn[] anonymizedRdns = new Rdn[entryDn.size()];
int rdnPos = entryDn.size() - 1;
if ( namingContext != null )
{
// Copy the naming contex
for ( Rdn ncRdn : namingContext )
{
anonymizedRdns[rdnPos] = ncRdn;
rdnPos--;
}
}
// Iterate on all the RDN
for ( Rdn rdn : descendant )
{
Ava[] anonymizedAvas = new Ava[rdn.size()];
int pos = 0;
// Iterate on the AVAs
for ( Ava ava : rdn )
{
Ava anonymizedAva = anonymizeAva( ava );
anonymizedAvas[pos] = anonymizedAva;
pos++;
}
Rdn anonymizedRdn = new Rdn( schemaManager, anonymizedAvas );
anonymizedRdns[rdnPos] = anonymizedRdn;
rdnPos--;
}
return new Dn( schemaManager, anonymizedRdns );
}
示例2: move
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
* move the DnNode's Dn
*
* @param newParent the new parent Dn
* @throws LdapException If the move failed
*/
public synchronized void move( Dn newParent ) throws LdapException
{
DnNode<N> tmp = null;
Dn tmpDn = null;
// check if the new parent Dn is child of the parent
if ( newParent.isDescendantOf( parent.nodeDn ) )
{
tmp = parent;
tmpDn = parent.nodeDn;
}
// if yes, then drill for the new parent node
if ( tmpDn != null )
{
int parentNodeSize = tmpDn.size();
int count = newParent.size() - parentNodeSize;
while ( count-- > 0 )
{
tmp = tmp.getChild( newParent.getRdn( parentNodeSize++ ) );
}
}
// if not, we have to traverse all the way up to the
// root node and then find the new parent node
if ( tmp == null )
{
tmp = this;
while ( tmp.parent != null )
{
tmp = tmp.parent;
}
tmp = tmp.getNode( newParent );
}
nodeDn = newParent.add( nodeRdn );
updateAfterModDn( nodeDn );
if ( parent != null )
{
parent.children.remove( nodeRdn.getNormName() );
}
parent = tmp;
parent.children.put( nodeRdn.getNormName(), this );
}