本文整理汇总了Java中org.apache.directory.api.ldap.model.name.Dn.size方法的典型用法代码示例。如果您正苦于以下问题:Java Dn.size方法的具体用法?Java Dn.size怎么用?Java Dn.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.ldap.model.name.Dn
的用法示例。
在下文中一共展示了Dn.size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reverseMove
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
* Compute a reverse LDIF for a forward change which if in LDIF format
* would represent a Move operation. Hence there is no newRdn in the
* picture here.
*
* @param newSuperiorDn the new parent dn to be (must not be null)
* @param modifiedDn the dn of the entry being moved (must not be null)
* @return a reverse LDIF
* @throws LdapException if something went wrong
*/
public static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ) throws LdapException
{
LdifEntry entry = new LdifEntry();
Dn currentParent;
Rdn currentRdn;
Dn newDn;
if ( newSuperiorDn == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_12074 ) );
}
if ( modifiedDn == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_12075 ) );
}
if ( modifiedDn.size() == 0 )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_12076 ) );
}
currentParent = modifiedDn;
currentRdn = currentParent.getRdn();
currentParent = currentParent.getParent();
newDn = newSuperiorDn;
newDn = newDn.add( modifiedDn.getRdn() );
entry.setChangeType( ChangeType.ModDn );
entry.setDn( newDn );
entry.setNewRdn( currentRdn.getName() );
entry.setNewSuperior( currentParent.getName() );
entry.setDeleteOldRdn( false );
return entry;
}
示例2: hasDescendantElement
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
* @return True if one of the node below the current node has one element,
* False otherwise
* @param dn The Dn we want to get the element for
*/
public synchronized boolean hasDescendantElement( Dn dn )
{
DnNode<N> node = getNode( dn );
if ( node == null )
{
return false;
}
// We must be at the right place in the tree
if ( node.getDn().size() != dn.size() )
{
return false;
}
if ( node.hasChildren() )
{
for ( DnNode<N> child : node.getChildren().values() )
{
if ( hasDescendantElement( child ) )
{
return true;
}
}
}
return false;
}
示例3: getDescendantElements
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
* @return True if one of the node below the current node has one element,
* False otherwise
* @param dn The Dn we want to get the element for
*/
public synchronized List<N> getDescendantElements( Dn dn )
{
List<N> descendants = new ArrayList<>();
DnNode<N> node = getNode( dn );
if ( node == null )
{
return descendants;
}
// We must be at the right place in the tree
if ( node.getDn().size() != dn.size() )
{
return descendants;
}
if ( node.hasChildren() )
{
for ( DnNode<N> child : node.getChildren().values() )
{
getDescendantElements( child, descendants );
}
}
return descendants;
}
示例4: 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();
}
}
示例5: getNode
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
* Get the Node for a given Dn, 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.
* <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> getNode( Dn dn )
{
DnNode<N> currentNode = this;
DnNode<N> parentNode = null;
// Iterate through all the Rdn until we find the associated partition
for ( int i = dn.size() - 1; i >= 0; i-- )
{
Rdn rdn = dn.getRdn( i );
if ( currentNode.hasChildren() )
{
currentNode = currentNode.children.get( rdn.getNormName() );
if ( currentNode == null )
{
break;
}
parentNode = currentNode;
}
else
{
break;
}
}
return parentNode;
}
示例6: 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 );
}
示例7: 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 );
}