directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r577351 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/
Date Wed, 19 Sep 2007 16:42:08 GMT
Author: elecharny
Date: Wed Sep 19 09:42:01 2007
New Revision: 577351

URL: http://svn.apache.org/viewvc?rev=577351&view=rev
Log:
Updated the nodes :
 o using the toString() methods instead of the prtintToBuffer() one
 o the accept() method has been moved to the parent node when needed
 o idem for equals()
 o visit() now returns an Object

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AndNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterVisitor.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java Wed Sep 19 09:42:01 2007
@@ -81,4 +81,16 @@
     {
         return annotations;
     }
+    
+    public String toString()
+    {
+        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
+        {
+            return ":[" + getAnnotations().get( "count" ) + "]";
+        }
+        else 
+        {
+        	return "";
+        }
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AndNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AndNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AndNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AndNode.java Wed Sep 19 09:42:01 2007
@@ -94,38 +94,6 @@
         return false;
     }
 
-
-    /**
-     * Recursively prints the String representation of this node and all its
-     * descendents to a buffer.
-     * 
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(java.lang.StringBuffer)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        buf.append( "(&" );
-
-        for ( ExprNode node:children )
-        {
-        	node.printToBuffer( buf );
-        }
-        
-        buf.append( ')' );
-        
-        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( '[' );
-            buf.append( ( ( Long ) getAnnotations().get( "count" ) ).toString() );
-            buf.append( "] " );
-        }
-        else
-        {
-            buf.append( ' ' );
-        }
-
-        return buf;
-    }
-
     
     /**
      * @see ExprNode#printRefinementToBuffer(StringBuffer)
@@ -163,58 +131,20 @@
     public String toString()
     {
         StringBuffer buf = new StringBuffer();
-        buf.append( "AND" );
-        
-        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( '[' );
-            buf.append( ( ( Long ) getAnnotations().get( "count" ) ) );
-            buf.append( "] " );
-        }
-        else
-        {
-            buf.append( ' ' );
-        }
-
-        return buf.toString();
-    }
+        buf.append( "(&" );
 
+        buf.append( super.toString() );
 
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.isPrefix() )
+        for ( ExprNode child:getChildren() )
         {
-            List<ExprNode> children = visitor.getOrder( this, this.children );
-
-            if ( visitor.canVisit( this ) )
-            {
-                visitor.visit( this );
-            }
-
-            for ( ExprNode node:children )
-            {
-                node.accept( visitor );
-            }
+        	buf.append( child );
         }
-        else
-        {
-            List<ExprNode> children = visitor.getOrder( this, this.children );
-
-            for ( ExprNode node:children )
-            {
-                node.accept( visitor );
-            }
+        
+        buf.append( ')' );
 
-            if ( visitor.canVisit( this ) )
-            {
-                visitor.visit( this );
-            }
-        }
+        return buf.toString();
     }
+
 
     /**
      * @see Object#hashCode()

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java Wed Sep 19 09:42:01 2007
@@ -51,50 +51,20 @@
         super( attribute, value );
     }
 
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(
-     *      java.lang.StringBuilder)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        buf.append( '(' ).append( getAttribute() ).append( "~=" ).append( value ).append( ')' );
 
-    	return super.printToBuffer( buf );
-    }
-
-    
     /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.canVisit( this ) )
-        {
-            visitor.visit( this );
-        }
-    }
-
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#equals(java.lang.Object)
+     * @see Object#toString()
      */
-    public boolean equals( Object other )
+    public String toString()
     {
-        if ( this == other )
-        {
-            return true;
-        }
+    	StringBuilder buf = new StringBuilder();
+    	
+        buf.append( '(' ).append( getAttribute() ).append( "~=" ).append( value );
 
-        if ( !( other instanceof ApproximateNode ) )
-        {
-            return false;
-        }
-
-        ApproximateNode otherNode = (ApproximateNode) other; 
+        buf.append( super.toString() );
+        
+        buf.append( ')' );
         
-        return ( value == null ? otherNode.value == null : value.equals( otherNode.value ) );
+    	return buf.toString();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java Wed Sep 19 09:42:01 2007
@@ -35,9 +35,6 @@
     /** Setting scan count to max */
     private static final Long MAX = Long.MAX_VALUE;
 
-    /** Setting display string to [MAX] */
-    private static final String MAX_STR = "[" + MAX.toString() + "]";
-
     /** The assertion or predicate to apply */
     private final Assertion assertion;
 
@@ -109,15 +106,6 @@
 
 
     /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(java.lang.StringBuffer)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        return buf.append( desc ).append( MAX_STR );
-    }
-
-    
-    /**
      * @see ExprNode#printRefinementToBuffer(StringBuffer)
      */
     public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
@@ -130,8 +118,23 @@
      * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
      *      org.apache.directory.shared.ldap.filter.FilterVisitor)
      */
-    public void accept( FilterVisitor visitor )
+    public Object accept( FilterVisitor visitor )
+    {
+        return visitor.visit( this );
+    }
+
+    /**
+     * @see Object#toString
+     */
+    public String toString()
     {
-        visitor.visit( this );
+    	StringBuilder buf = new StringBuilder();
+    	
+    	buf.append( "(@" );
+    	buf.append( desc );
+    	buf.append( super.toString() );
+    	buf.append( ')' );
+    	
+        return buf.toString();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNode.java Wed Sep 19 09:42:01 2007
@@ -116,7 +116,7 @@
      * 
      * @param list the list of children to set.
      */
-    void setChildren( List<ExprNode> list )
+    public void setChildren( List<ExprNode> list )
     {
         children = list;
     }
@@ -143,35 +143,85 @@
      * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
      *      org.apache.directory.shared.ldap.filter.FilterVisitor)
      */
-    public void accept( FilterVisitor visitor )
+    public final Object accept( FilterVisitor visitor )
     {
         if ( visitor.isPrefix() )
         {
             List<ExprNode> children = visitor.getOrder( this, this.children );
+            ExprNode result = null;
 
             if ( visitor.canVisit( this ) )
             {
-                visitor.visit( this );
+                result = (ExprNode)visitor.visit( this );
             }
 
             for ( ExprNode node:children )
             {
                 node.accept( visitor );
             }
+
+            return result;
         }
         else
         {
-            List<ExprNode> children = visitor.getOrder( this, this.children );
-
-            for ( ExprNode node:children )
+            if ( visitor.canVisit( this ) )
             {
-                node.accept( visitor );
+                return visitor.visit( this );
             }
-
-            if ( visitor.canVisit( this ) )
+            else
             {
-                visitor.visit( this );
+            	return null;
             }
         }
+    }
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals( Object other )
+    {
+        if ( this == other )
+        {
+            return true;
+        }
+
+        if ( !( other instanceof BranchNode ) )
+        {
+            return false;
+        }
+        
+        if ( other.getClass() != this.getClass() )
+        {
+        	return false;
+        }
+
+        BranchNode otherExprNode = ( BranchNode ) other;
+
+        List<ExprNode> otherChildren = otherExprNode.getChildren();
+
+        if ( otherChildren == children )
+        {
+            return true;
+        }
+
+        if ( children.size() != otherChildren.size() )
+        {
+        	return false;
+        }
+        
+        for ( int i = 0; i < children.size(); i++ )
+        {
+        	ExprNode child = children.get( i );
+        	ExprNode otherChild = children.get( i );
+        	
+        	if ( !child.equals( otherChild ) )
+        	{
+        		return false;
+        	}
+        }
+        
+        return true;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java Wed Sep 19 09:42:01 2007
@@ -44,18 +44,18 @@
  */
 public class BranchNormalizedVisitor implements FilterVisitor
 {
-    public void visit( ExprNode node )
+    public Object visit( ExprNode node )
     {
         if ( !( node instanceof BranchNode ) )
         {
-            return;
+            return null;
         }
 
         BranchNode branch = ( BranchNode ) node;
 
         if ( branch instanceof NotNode )
         {
-            return;
+            return null;
         }
 
         Comparator<ExprNode> nodeComparator = new NodeComparator();
@@ -68,15 +68,24 @@
         {
             if ( !child.isLeaf() )
             {
-                visit( child );
+            	ExprNode newChild = (ExprNode)visit( child );
+            	
+            	if ( newChild != null )
+            	{
+            		set.add( newChild );
+            	}
+            }
+            else
+            {
+            	set.add( child );
             }
-
-            set.add( child );
         }
 
         children.clear();
 
         children.addAll( set );
+        
+        return branch;
     }
 
 
@@ -137,13 +146,9 @@
     {
         BranchNormalizedVisitor visitor = new BranchNormalizedVisitor();
 
-        visitor.visit( filter );
-
-        StringBuilder normalized = new StringBuilder();
-
-        filter.printToBuffer( normalized );
+        ExprNode result = (ExprNode)visitor.visit( filter );
 
-        return normalized.toString().trim();
+        return result.toString().trim();
     }
 
     class NodeComparator implements Comparator<ExprNode>
@@ -156,7 +161,7 @@
 
             String s1 = null;
 
-            o1.printToBuffer( buf );
+            buf.append( o1.toString() );
 
             s1 = buf.toString();
 
@@ -164,7 +169,7 @@
 
             String s2 = null;
 
-            o2.printToBuffer( buf );
+            buf.append( o2.toString() );
 
             s2 = buf.toString();
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java Wed Sep 19 09:42:01 2007
@@ -51,49 +51,20 @@
         super( attribute, value );
     }
 
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(
-     *      java.lang.StringBuilder)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        buf.append( '(' ).append( getAttribute() ).append( "=" ).append( value ).append( ')' );
-    	return super.printToBuffer( buf );
-    }
 
-    
     /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
+     * @see Object#toString()
      */
-    public void accept( FilterVisitor visitor )
+    public String toString()
     {
-        if ( visitor.canVisit( this ) )
-        {
-            visitor.visit( this );
-        }
-    }
+    	StringBuilder buf = new StringBuilder();
+    	
+        buf.append( '(' ).append( getAttribute() ).append( "=" ).append( value );
 
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals( Object other )
-    {
-        if ( this == other )
-        {
-            return true;
-        }
-
-        if ( !( other instanceof EqualityNode ) )
-        {
-            return false;
-        }
-
-        EqualityNode otherNode = (EqualityNode) other; 
+        buf.append( super.toString() );
+        
+        buf.append( ')' );
         
-        return ( value == null ? otherNode.value == null : value.equals( otherNode.value ) );
+    	return buf.toString();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java Wed Sep 19 09:42:01 2007
@@ -57,15 +57,6 @@
 
 
     /**
-     * Recursively appends this String representation of this node and its
-     * descendents in prefix notation to a buffer.
-     * 
-     * @param buf the buffer to append to.
-     */
-    StringBuilder printToBuffer( StringBuilder buf );
-
-
-    /**
      * Recursively appends the refinement string representation of this node and its
      * descendents in prefix notation to a buffer.
      * 
@@ -79,6 +70,7 @@
      * Element/node accept method for visitor pattern.
      * 
      * @param visitor the filter expression tree structure visitor
+     * @return The modified element
      */
-    void accept( FilterVisitor visitor );
+    Object accept( FilterVisitor visitor );
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java Wed Sep 19 09:42:01 2007
@@ -107,38 +107,6 @@
 
 
     /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(
-     *      java.lang.StringBuilder)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        buf.append( '(' ).append( getAttribute() );
-        buf.append( "-" );
-        buf.append( this.dnAttributes );
-        buf.append( "-EXTENSIBLE-" );
-        buf.append( this.matchingRuleId );
-        buf.append( "-" );
-        buf.append( StringTools.utf8ToString( value ) );
-        buf.append( "/" );
-        buf.append( StringTools.dumpBytes( value ) );
-        buf.append( ')' );
-
-        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( '[' );
-            buf.append( getAnnotations().get( "count" ).toString() );
-            buf.append( "] " );
-        }
-        else
-        {
-            buf.append( ' ' );
-        }
-
-        return buf;
-    }
-
-    
-    /**
      * @see ExprNode#printRefinementToBuffer(StringBuilder)
      */
     public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
@@ -153,21 +121,21 @@
     public String toString()
     {
     	StringBuilder buf = new StringBuilder();
-        printToBuffer( buf );
-
-        return ( buf.toString() );
-    }
-
+    	
+        buf.append( '(' ).append( getAttribute() );
+        buf.append( "-" );
+        buf.append( dnAttributes );
+        buf.append( "-EXTENSIBLE-" );
+        buf.append( matchingRuleId );
+        buf.append( "-" );
+        buf.append( StringTools.utf8ToString( value ) );
+        buf.append( "/" );
+        buf.append( StringTools.dumpBytes( value ) );
 
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.canVisit( this ) )
-        {
-            visitor.visit( this );
-        }
+        buf.append( super.toString() );
+        
+        buf.append( ')' );
+        
+        return buf.toString();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterVisitor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterVisitor.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterVisitor.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterVisitor.java Wed Sep 19 09:42:01 2007
@@ -48,17 +48,15 @@
     /**
      * Visits a filter expression AST using a specific visitation order.
      * 
-     * @param node
-     *            the node to visit
+     * @param node the node to visit
      */
-    void visit( ExprNode node );
+    Object visit( ExprNode node );
 
 
     /**
      * Checks to see if a node can be visited.
      * 
-     * @param node
-     *            the node to be visited
+     * @param node the node to be visited
      * @return whether or node the node should be visited
      */
     boolean canVisit( ExprNode node );
@@ -77,10 +75,8 @@
      * child visitations. Some children may not be returned at all if canVisit()
      * returns false on them.
      * 
-     * @param node
-     *            the parent branch node
-     * @param children
-     *            the child node array
+     * @param node the parent branch node
+     * @param children the child node array
      * @return the new reordered array of children
      */
     List<ExprNode> getOrder( BranchNode node, List<ExprNode> children );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java Wed Sep 19 09:42:01 2007
@@ -51,50 +51,20 @@
         super( attribute, value );
     }
 
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(
-     *      java.lang.StringBuilder)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        buf.append( '(' ).append( getAttribute() ).append( ">=" ).append( value ).append( ')' );
-        
-    	return super.printToBuffer( buf );
-    }
 
-    
     /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.canVisit( this ) )
-        {
-            visitor.visit( this );
-        }
-    }
-
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#equals(java.lang.Object)
+     * @see Object#toString()
      */
-    public boolean equals( Object other )
+    public String toString()
     {
-        if ( this == other )
-        {
-            return true;
-        }
+    	StringBuilder buf = new StringBuilder();
+    	
+        buf.append( '(' ).append( getAttribute() ).append( ">=" ).append( value );
 
-        if ( !( other instanceof GreaterEqNode ) )
-        {
-            return false;
-        }
-
-        GreaterEqNode otherNode = (GreaterEqNode) other; 
+        buf.append( super.toString() );
+        
+        buf.append( ')' );
         
-        return ( value == null ? otherNode.value == null : value.equals( otherNode.value ) );
+    	return buf.toString();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java Wed Sep 19 09:42:01 2007
@@ -95,11 +95,28 @@
             return false;
         }
 
-        if ( !super.equals( other ) )
+        if ( other.getClass() != this.getClass() )
         {
-            return false;
+        	return false;
         }
-
+            
         return attribute.equals( ( ( LeafNode ) other ).getAttribute() );
+    }
+
+
+    /**
+     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
+     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
+     */
+    public final Object accept( FilterVisitor visitor )
+    {
+        if ( visitor.canVisit( this ) )
+        {
+            return visitor.visit( this );
+        }
+        else
+        {
+        	return null;
+        }
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java Wed Sep 19 09:42:01 2007
@@ -51,50 +51,20 @@
         super( attribute, value );
     }
 
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(
-     *      java.lang.StringBuilder)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        buf.append( '(' ).append( getAttribute() ).append( "<=" ).append( value ).append( ')' );
 
-        return super.printToBuffer( buf );
-    }
-
-    
     /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.canVisit( this ) )
-        {
-            visitor.visit( this );
-        }
-    }
-
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#equals(java.lang.Object)
+     * @see Object#toString()
      */
-    public boolean equals( Object other )
+    public String toString()
     {
-        if ( this == other )
-        {
-            return true;
-        }
+    	StringBuilder buf = new StringBuilder();
+    	
+        buf.append( '(' ).append( getAttribute() ).append( "<=" ).append( value );
 
-        if ( !( other instanceof LessEqNode ) )
-        {
-            return false;
-        }
-
-        LessEqNode otherNode = (LessEqNode) other; 
+        buf.append( super.toString() );
+        
+        buf.append( ')' );
         
-        return ( value == null ? otherNode.value == null : value.equals( otherNode.value ) );
+    	return buf.toString();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java Wed Sep 19 09:42:01 2007
@@ -96,7 +96,7 @@
      */
     public void setChildren( List<ExprNode> list )
     {
-    	if ( ( list != null ) && ( list.size() >= 1 ) )
+    	if ( ( list != null ) && ( list.size() > 1 ) )
     	{
     		throw new IllegalStateException( "Cannot add more than one element to a negation node." );    		
     	}
@@ -150,38 +150,6 @@
 
 
     /**
-     * Recursively prints the String representation of this node and all its
-     * descendents to a buffer.
-     * 
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(java.lang.StringBuffer)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        buf.append( "(!" );
-
-        for ( ExprNode node:children )
-        {
-        	node.printToBuffer( buf );
-        }
-        
-        buf.append( ')' );
-        
-        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( '[' );
-            buf.append( ( ( Long ) getAnnotations().get( "count" ) ).toString() );
-            buf.append( "] " );
-        }
-        else
-        {
-            buf.append( ' ' );
-        }
-
-        return buf;
-    }
-
-    
-    /**
      * @see ExprNode#printRefinementToBuffer(StringBuffer)
      */
     public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
@@ -216,61 +184,19 @@
      */
     public String toString()
     {
-        StringBuffer buf = new StringBuffer();
-        buf.append( "NOT" );
+        StringBuilder buf = new StringBuilder();
+        buf.append( "(!" );
         
-        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( '[' );
-            buf.append( ( ( Long ) getAnnotations().get( "count" ) ) );
-            buf.append( "] " );
-        }
-        else
-        {
-            buf.append( ' ' );
-        }
+        buf.append( super.toString() );
 
+        buf.append( getFirstChild() );
+        buf.append( ')' );
+        
         return buf.toString();
     }
 
 
     /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.isPrefix() )
-        {
-            List<ExprNode> children = visitor.getOrder( this, this.children );
-
-            if ( visitor.canVisit( this ) )
-            {
-                visitor.visit( this );
-            }
-
-            for ( ExprNode node:children )
-            {
-                node.accept( visitor );
-            }
-        }
-        else
-        {
-            List<ExprNode> children = visitor.getOrder( this, this.children );
-
-            for ( ExprNode node:children )
-            {
-                node.accept( visitor );
-            }
-
-            if ( visitor.canVisit( this ) )
-            {
-                visitor.visit( this );
-            }
-        }
-    }
-
-    /**
      * @see Object#hashCode()
      */
     public int hashCode()
@@ -279,51 +205,5 @@
         hash = hash*31 + AssertionEnum.NOT.hashCode();
         hash = hash*31 + ( annotations == null ? 0 : annotations.hashCode() );
         return hash;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals( Object other )
-    {
-        if ( this == other )
-        {
-            return true;
-        }
-
-        if ( !( other instanceof NotNode ) )
-        {
-            return false;
-        }
-
-        NotNode otherExprNode = ( NotNode ) other;
-
-        List<ExprNode> otherChildren = otherExprNode.getChildren();
-
-        if ( otherChildren == children )
-        {
-            return true;
-        }
-
-        if ( children.size() != otherChildren.size() )
-        {
-        	return false;
-        }
-        
-        for ( int i = 0; i < children.size(); i++ )
-        {
-        	ExprNode child = children.get( i );
-        	ExprNode otherChild = children.get( i );
-        	
-        	if ( !child.equals( otherChild ) )
-        	{
-        		return false;
-        	}
-        }
-        
-        return true;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java Wed Sep 19 09:42:01 2007
@@ -98,38 +98,6 @@
 
 
     /**
-     * Recursively prints the String representation of this node and all its
-     * descendents to a buffer.
-     * 
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(java.lang.StringBuffer)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        buf.append( "(|" );
-
-        for ( ExprNode node:children )
-        {
-        	node.printToBuffer( buf );
-        }
-        
-        buf.append( ')' );
-        
-        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( '[' );
-            buf.append( ( ( Long ) getAnnotations().get( "count" ) ).toString() );
-            buf.append( "] " );
-        }
-        else
-        {
-            buf.append( ' ' );
-        }
-
-        return buf;
-    }
-
-    
-    /**
      * @see ExprNode#printRefinementToBuffer(StringBuffer)
      */
     public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
@@ -164,59 +132,21 @@
      */
     public String toString()
     {
-        StringBuffer buf = new StringBuffer();
-        buf.append( "OR" );
+        StringBuilder buf = new StringBuilder();
+        buf.append( "(|" );
         
-        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( '[' );
-            buf.append( ( ( Long ) getAnnotations().get( "count" ) ) );
-            buf.append( "] " );
-        }
-        else
+        buf.append( super.toString() );
+
+        for ( ExprNode child:getChildren() )
         {
-            buf.append( ' ' );
+        	buf.append( child );
         }
-
+        
+        buf.append( ')' );
+	
         return buf.toString();
     }
 
-
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.isPrefix() )
-        {
-            List<ExprNode> children = visitor.getOrder( this, this.children );
-
-            if ( visitor.canVisit( this ) )
-            {
-                visitor.visit( this );
-            }
-
-            for ( ExprNode node:children )
-            {
-                node.accept( visitor );
-            }
-        }
-        else
-        {
-            List<ExprNode> children = visitor.getOrder( this, this.children );
-
-            for ( ExprNode node:children )
-            {
-                node.accept( visitor );
-            }
-
-            if ( visitor.canVisit( this ) )
-            {
-                visitor.visit( this );
-            }
-        }
-    }
 
     /**
      * @see Object#hashCode()

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java Wed Sep 19 09:42:01 2007
@@ -41,36 +41,19 @@
 
 
     /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(java.lang.StringBuilder)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
-        buf.append( '(' ).append( getAttribute() ).append( "=*)" );
-
-        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( '[' );
-            buf.append( getAnnotations().get( "count" ).toString() );
-            buf.append( "] " );
-        }
-        else
-        {
-            buf.append( ' ' );
-        }
-
-        return buf;
-    }
-
-
-    /**
      * @see java.lang.Object#toString()
      */
     public String toString()
     {
     	StringBuilder buf = new StringBuilder();
-        printToBuffer( buf );
+    	
+        buf.append( '(' ).append( getAttribute() ).append( "=*" );
+
+        buf.append( super.toString() );
+
+        buf.append( ')' );
         
-        return ( buf.toString() );
+        return buf.toString();
     }
 
     
@@ -80,18 +63,5 @@
     public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
     {
         throw new UnsupportedOperationException( "PresenceNode can't be part of a refinement" );
-    }
-
-
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.canVisit( this ) )
-        {
-            visitor.visit( this );
-        }
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java Wed Sep 19 09:42:01 2007
@@ -127,10 +127,39 @@
 
 
     /**
-     * @see ExprNode#printToBuffer(StringBuilder)
+     * @see ExprNode#printRefinementToBuffer(StringBuilder)
+     */
+    public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
+    {
+        throw new UnsupportedOperationException( "ScopeNode can't be part of a refinement" );
+    }
+
+
+    /**
+     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
+     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
      */
-    public StringBuilder printToBuffer( StringBuilder buf )
+    public Object accept( FilterVisitor visitor )
     {
+        if ( visitor.canVisit( this ) )
+        {
+            return visitor.visit( this );
+        }
+        else
+        {
+        	return null;
+        }
+    }
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+    	StringBuilder buf = new StringBuilder();
+    	
+    	buf.append( "(#{" );
+
         switch ( scope )
         {
             case ( SearchControls.OBJECT_SCOPE  ):
@@ -139,7 +168,7 @@
                 break;
 
             case ( SearchControls.ONELEVEL_SCOPE  ):
-                buf.append( "ONELEVEL_SCOPE" );
+                buf.append( "ONE_LEVEL_SCOPE" );
 
                 break;
 
@@ -151,36 +180,15 @@
             default:
                 buf.append( "UNKNOWN" );
         }
-
-        if ( getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( " [" );
-            buf.append( getAnnotations().get( "count" ).toString() );
-            buf.append( ']' );
-        }
-
-        return buf;
-    }
-    
-    
-    /**
-     * @see ExprNode#printRefinementToBuffer(StringBuilder)
-     */
-    public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
-    {
-        throw new UnsupportedOperationException( "ScopeNode can't be part of a refinement" );
-    }
-
-
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.canVisit( this ) )
-        {
-            visitor.visit( this );
-        }
+    	
+    	buf.append( ", '" );
+    	buf.append( baseDn );
+    	buf.append( "', " );
+    	buf.append( derefAliases );
+    	buf.append( "}" );
+    	buf.append( super.toString() );
+    	buf.append( ')' );
+    	
+    	return buf.toString();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java Wed Sep 19 09:42:01 2007
@@ -28,7 +28,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Revision$
  */
-public class SimpleNode extends LeafNode
+public abstract class SimpleNode extends LeafNode
 {
 	/** the value */
     protected Object value;
@@ -43,7 +43,7 @@
      * @param attribute the attribute name
      * @param value the value to test for
      */
-    public SimpleNode( String attribute, byte[] value )
+    protected SimpleNode( String attribute, byte[] value )
     {
         super( attribute );
         this.value = value;
@@ -56,7 +56,7 @@
      * @param attribute the attribute name
      * @param value the value to test for
      */
-    public SimpleNode( String attribute, String value )
+    protected SimpleNode( String attribute, String value )
     {
         super( attribute );
         this.value = value;
@@ -93,14 +93,12 @@
     {
         if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
         {
-            buf.append( '[' );
+            buf.append( ":[" );
             buf.append( getAnnotations().get( "count" ).toString() );
             buf.append( "] " );
         }
-        else
-        {
-            buf.append( ' ' );
-        }
+
+        buf.append( ')' );
 
         return buf;
     }
@@ -123,29 +121,19 @@
 
 
     /**
-     * @see java.lang.Object#toString()
+     * @see Object#hashCode()
      */
-    public String toString()
+    public int hashCode()
     {
-    	StringBuilder buf = new StringBuilder();
-        printToBuffer( buf );
-        return ( buf.toString() );
-    }
-
-
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.canVisit( this ) )
-        {
-            visitor.visit( this );
-        }
+    	int h = 31;
+    	h += value.hashCode()*13;
+    	h += getAttribute().hashCode()*13;
+    	h += this.getClass().hashCode()*13;
+    	
+    	return h;
     }
 
-
+    
     /*
      * (non-Javadoc)
      * 
@@ -162,9 +150,26 @@
         {
             return false;
         }
+        
+        if ( other.getClass() != this.getClass() )
+        {
+        	return false;
+        }
+        
+        if ( !super.equals( other ) )
+        {
+        	return false;
+        }
 
         SimpleNode otherNode = (SimpleNode)other;
 
-        return ( value == null ? otherNode.value == null : value.equals( otherNode.value ) );
+        if ( value == null )
+        {
+        	return otherNode.value == null;
+        }
+        else
+        {
+        	return value.equals( otherNode.value );
+    	}
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java?rev=577351&r1=577350&r2=577351&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java Wed Sep 19 09:42:01 2007
@@ -40,13 +40,13 @@
 public class SubstringNode extends LeafNode
 {
     /** The initial fragment before any wildcards */
-    private final String initialPattern;
+    private String initialPattern;
 
     /** The end fragment after wildcards */
-    private final String finalPattern;
+    private String finalPattern;
 
     /** List of fragments between wildcards */
-    private final List<String> anyPattern;
+    private List<String> anyPattern;
 
     /**
      * Creates a new SubstringNode object with only one wildcard and no internal
@@ -94,7 +94,15 @@
     {
         return initialPattern;
     }
-
+    
+    /**
+     * Set the initial pattern
+     * @param initialPattern The initial pattern
+     */
+	public void setInitial( String initialPattern ) 
+	{
+		this.initialPattern = initialPattern;
+	}
 
     /**
      * Gets the final fragment or suffix.
@@ -108,6 +116,16 @@
 
 
     /**
+     * Set the final pattern
+     * @param finalPattern The final pattern
+     */
+	public void setFinal( String finalPattern ) 
+	{
+		this.finalPattern = finalPattern;
+	}
+
+
+    /**
      * Gets the list of wildcard surrounded any fragments.
      * 
      * @return the any fragments
@@ -119,6 +137,16 @@
 
 
     /**
+     * Set the any patterns
+     * @param anyPattern The any patterns
+     */
+	public void setAny( List<String> anyPattern ) 
+	{
+		this.anyPattern = anyPattern;
+	}
+
+
+    /**
      * Gets the compiled regular expression for the substring expression.
      * 
      * @return the equivalent compiled regular expression
@@ -126,7 +154,7 @@
      */
     public final Pattern getRegex( Normalizer normalizer ) throws PatternSyntaxException, NamingException
     {
-        if ( anyPattern.size() > 0 )
+        if ( ( anyPattern != null ) && ( anyPattern.size() > 0 ) )
         {
             String[] any = new String[anyPattern.size()];
 
@@ -180,18 +208,8 @@
      */
     public String toString()
     {
-        StringBuilder buf = new StringBuilder();
-        printToBuffer( buf );
-
-        return ( buf.toString() );
-    }
-
-
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#printToBuffer(java.lang.StringBuilder)
-     */
-    public StringBuilder printToBuffer( StringBuilder buf )
-    {
+    	StringBuilder buf = new StringBuilder();
+    	
         buf.append( '(' ).append( getAttribute() ).append( '=' );
 
         if ( null != initialPattern )
@@ -203,10 +221,13 @@
             buf.append( '*' );
         }
 
-        for ( String any:anyPattern )
+        if ( null != anyPattern )
         {
-            buf.append( any );
-            buf.append( '*' );
+	        for ( String any:anyPattern )
+	        {
+	            buf.append( any );
+	            buf.append( '*' );
+	        }
         }
 
         if ( null != finalPattern )
@@ -214,41 +235,19 @@
             buf.append( finalPattern );
         }
 
+        buf.append( super.toString() );
+        
         buf.append( ')' );
-
-        if ( ( null != getAnnotations() ) && getAnnotations().containsKey( "count" ) )
-        {
-            buf.append( '[' );
-            buf.append( getAnnotations().get( "count" ).toString() );
-            buf.append( "] " );
-        }
-        else
-        {
-            buf.append( ' ' );
-        }
-
-        return buf;
+        
+        return buf.toString();
     }
 
-    
+
     /**
      * @see ExprNode#printRefinementToBuffer(StringBuilder)
      */
     public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
     {
         throw new UnsupportedOperationException( "SubstringNode can't be part of a refinement" );
-    }
-
-
-    /**
-     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
-     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
-     */
-    public void accept( FilterVisitor visitor )
-    {
-        if ( visitor.canVisit( this ) )
-        {
-            visitor.visit( this );
-        }
     }
 }



Mime
View raw message