org.apache.directory.server.core.normalization
Class NormalizingVisitor

java.lang.Object
  extended by org.apache.directory.server.core.normalization.NormalizingVisitor
All Implemented Interfaces:
org.apache.directory.shared.ldap.filter.FilterVisitor

public class NormalizingVisitor
extends java.lang.Object
implements org.apache.directory.shared.ldap.filter.FilterVisitor

A filter visitor which normalizes leaf node values as it visits them. It also removes leaf nodes from branches whose attributeType is undefined. It obviously cannot remove a leaf node from a filter which is only a leaf node. Checks to see if a filter is a leaf node with undefined attributeTypes should be done outside this visitor. Since this visitor may remove filter nodes it may produce negative results on filters, like NOT branch nodes without a child or AND and OR nodes with one or less children. This might make some partition implementations choke. To avoid this problem we clean up branch nodes that don't make sense. For example all BranchNodes without children are just removed. An AND and OR BranchNode with a single child is replaced with it's child for all but the topmost branchnode which we cannot replace. So again the top most branch node must be inspected by code outside of this visitor.

Version:
$Rev: 675520 $
Author:
Apache Directory Project

Constructor Summary
NormalizingVisitor(org.apache.directory.shared.ldap.name.NameComponentNormalizer ncn, Registries registries)
          Creates a new instance of NormalizingVisitor.
 
Method Summary
 boolean canVisit(org.apache.directory.shared.ldap.filter.ExprNode node)
           
 java.util.List<org.apache.directory.shared.ldap.filter.ExprNode> getOrder(org.apache.directory.shared.ldap.filter.BranchNode node, java.util.List<org.apache.directory.shared.ldap.filter.ExprNode> children)
           
static boolean isFilterChar(char c)
          Check if the given char is a filter escaped char <filterEscapedChars> ::= '\0' | '(' | ')' | '*' | '\'
 boolean isPrefix()
           
 java.lang.Object visit(org.apache.directory.shared.ldap.filter.ExprNode node)
          Visit the tree, normalizing the leaves and recusrsively visit the branches.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NormalizingVisitor

public NormalizingVisitor(org.apache.directory.shared.ldap.name.NameComponentNormalizer ncn,
                          Registries registries)
Creates a new instance of NormalizingVisitor.

Parameters:
ncn - The name component normalizer to use
registries - The global registries
Method Detail

isFilterChar

public static boolean isFilterChar(char c)
Check if the given char is a filter escaped char <filterEscapedChars> ::= '\0' | '(' | ')' | '*' | '\'

Parameters:
c - the char we want to test
Returns:
true if the char is a pair char only

visit

public java.lang.Object visit(org.apache.directory.shared.ldap.filter.ExprNode node)
Visit the tree, normalizing the leaves and recusrsively visit the branches. Here are the leaves we are visiting : - PresenceNode ( attr =* ) - ExtensibleNode ( ? ) - SubStringNode ( attr = *X*Y* ) - ApproximateNode ( attr ~= value ) - EqualityNode ( attr = value ) - GreaterEqNode ( attr >= value ) - LessEqNode ( attr <= value ) The PresencNode is managed differently from other nodes, as it just check for the attribute, not the value.

Specified by:
visit in interface org.apache.directory.shared.ldap.filter.FilterVisitor
Parameters:
node - the node to visit
Returns:
the visited node

canVisit

public boolean canVisit(org.apache.directory.shared.ldap.filter.ExprNode node)
Specified by:
canVisit in interface org.apache.directory.shared.ldap.filter.FilterVisitor

isPrefix

public boolean isPrefix()
Specified by:
isPrefix in interface org.apache.directory.shared.ldap.filter.FilterVisitor

getOrder

public java.util.List<org.apache.directory.shared.ldap.filter.ExprNode> getOrder(org.apache.directory.shared.ldap.filter.BranchNode node,
                                                                                 java.util.List<org.apache.directory.shared.ldap.filter.ExprNode> children)
Specified by:
getOrder in interface org.apache.directory.shared.ldap.filter.FilterVisitor


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.