}
public Object visit( ExprNode node )
{
BranchNode bnode = ( BranchNode ) node;
// --------------------------------------------------------------------
// we want to check each child leaf node to see if it must be expanded
// children that are branch nodes are recursively visited
// --------------------------------------------------------------------
final List<ExprNode> children = bnode.getChildren();
int childNumber = 0;
for ( ExprNode child : children )
{
if ( child instanceof LeafNode )
{
LeafNode leaf = ( LeafNode ) child;
try
{
if ( schemaManager.getAttributeTypeRegistry().hasDescendants( leaf.getAttribute() ) )
{
// create a new OR node to hold all descendent forms
// add to this node the generalized leaf node and
// replace the old leaf with the new OR branch node
BranchNode orNode = new OrNode();
orNode.getChildren().add( leaf );
children.set( childNumber++, orNode );
// iterate through descendants adding them to the orNode
Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( leaf.getAttribute() );
while ( descendants.hasNext() )
{
LeafNode newLeaf = null;
AttributeType descendant = descendants.next();
if ( leaf instanceof PresenceNode )
{
newLeaf = new PresenceNode( descendant.getOid() );
}
else if ( leaf instanceof ApproximateNode )
{
ApproximateNode approximateNode = ( ApproximateNode ) leaf;
newLeaf = new ApproximateNode( descendant.getOid(), approximateNode.getValue() );
}
else if ( leaf instanceof EqualityNode )
{
EqualityNode equalityNode = ( EqualityNode ) leaf;
newLeaf = new EqualityNode( descendant.getOid(), equalityNode.getValue() );
}
else if ( leaf instanceof GreaterEqNode )
{
GreaterEqNode greaterEqNode = ( GreaterEqNode ) leaf;
newLeaf = new GreaterEqNode( descendant.getOid(), greaterEqNode.getValue() );
}
else if ( leaf instanceof LessEqNode )
{
LessEqNode lessEqNode = ( LessEqNode ) leaf;
newLeaf = new LessEqNode( descendant.getOid(), lessEqNode.getValue() );
}
else if ( leaf instanceof ExtensibleNode )
{
ExtensibleNode extensibleNode = ( ExtensibleNode ) leaf;
newLeaf = new ExtensibleNode( descendant.getOid(), extensibleNode.getValue(),
extensibleNode.getMatchingRuleId(), extensibleNode.hasDnAttributes() );
}
else if ( leaf instanceof SubstringNode )
{
SubstringNode substringNode = ( SubstringNode ) leaf;
newLeaf = new SubstringNode( descendant.getOid(), substringNode.getInitial(),
substringNode.getFinal() );
}
else
{
throw new IllegalStateException( I18n.err( I18n.ERR_260, leaf ) );
}
orNode.addNode( newLeaf );
}
}
}
catch ( NamingException e )
{