directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r664290 [7/13] - in /directory/shared/branches/bigbang: ./ asn1/src/main/java/org/apache/directory/shared/asn1/ asn1/src/main/java/org/apache/directory/shared/asn1/ber/ asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/ asn1/s...
Date Sat, 07 Jun 2008 06:28:15 GMT
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java Fri Jun  6 23:28:06 2008
@@ -20,12 +20,11 @@
 package org.apache.directory.shared.ldap.filter;
 
 
+import java.text.ParseException;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.Comparator;
-import java.io.IOException;
-import java.text.ParseException;
 
 
 /**
@@ -68,16 +67,16 @@
         {
             if ( !child.isLeaf() )
             {
-            	ExprNode newChild = (ExprNode)visit( child );
-            	
-            	if ( newChild != null )
-            	{
-            		set.add( newChild );
-            	}
+                ExprNode newChild = (ExprNode)visit( child );
+                
+                if ( newChild != null )
+                {
+                    set.add( newChild );
+                }
             }
             else
             {
-            	set.add( child );
+                set.add( child );
             }
         }
 
@@ -119,12 +118,10 @@
      * @param filter
      *            the filter to normalize
      * @return the normalized version of the filter
-     * @throws java.io.IOException
-     *             if filter parser cannot be created
      * @throws java.text.ParseException
      *             if the filter is malformed
      */
-    public static String getNormalizedFilter( String filter ) throws IOException, ParseException
+    public static String getNormalizedFilter( String filter ) throws ParseException
     {
         ExprNode originalNode = FilterParser.parse( filter );
 
@@ -153,7 +150,7 @@
     {
         public int compare( ExprNode o1, ExprNode o2 )
         {
-        	StringBuilder buf = new StringBuilder();
+            StringBuilder buf = new StringBuilder();
 
             buf.setLength( 0 );
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java Fri Jun  6 23:28:06 2008
@@ -44,16 +44,21 @@
 
 
     /**
-     * @see Object#hashCode()
+     * Creates a new Equality object.
+     * 
+     * @param attribute the attribute name
+     * @param value the value to test for
+     * @param assertionType The node's type
      */
-    public int hashCode()
+    protected EqualityNode( String attribute, Value<T> value, AssertionType assertionType )
     {
-        return super.hashCode();
+        super( attribute, value, assertionType );
     }
 
-    
+
     /**
      * @see Object#toString()
+     * @return A string representing the AndNode
      */
     public String toString()
     {

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExprNode.java Fri Jun  6 23:28:06 2008
@@ -71,10 +71,11 @@
      * TODO - Why is this here? Why not put it in some utility class?
      * 
      * @param buf the buffer to append to.
+     * @return The buffer in which the refinement has been appended
      * @throws UnsupportedOperationException if this node isn't a part of a refinement.
      * @return the refinement buffer
      */
-    StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException;
+    StringBuilder printRefinementToBuffer( StringBuilder buf );
     
     
     /**

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java Fri Jun  6 23:28:06 2008
@@ -129,6 +129,8 @@
 
     /**
      * Sets the matching rule id as an OID string.
+     * 
+     * @param matchingRuleId The maching rule ID
      */
     public void setMatchingRuleId( String matchingRuleId )
     {
@@ -156,6 +158,8 @@
 
     /**
      * Sets the value.
+     * 
+     * @param value the value
      */
     public final void setValue( String value)
     {
@@ -164,16 +168,8 @@
 
     
     /**
-     * @see ExprNode#printRefinementToBuffer(StringBuilder)
-     */
-    public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
-    {
-        throw new UnsupportedOperationException( "ExtensibleNode can't be part of a refinement" );
-    }
-
-
-    /**
      * @see Object#hashCode()
+     * @return the instance's hash code 
      */
     public int hashCode()
     {
@@ -190,11 +186,12 @@
 
     /**
      * @see java.lang.Object#toString()
+     * @return A string representing the AndNode
      */
     public String toString()
     {
-    	StringBuilder buf = new StringBuilder();
-    	
+        StringBuilder buf = new StringBuilder();
+        
         buf.append( '(' ).append( getAttribute() );
         buf.append( "-" );
         buf.append( dnAttributes );

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java Fri Jun  6 23:28:06 2008
@@ -604,7 +604,7 @@
         // StringTools.trimLeft( filter, pos );
 
         // Check for the left '('
-        if ( StringTools.isCharASCII( filter, pos.start, '(' ) == false )
+        if ( !StringTools.isCharASCII( filter, pos.start, '(' ) )
         {
             // No more node, get out
             if ( ( pos.start == 0 ) && ( pos.length != 0 ) )
@@ -634,7 +634,7 @@
         // StringTools.trimLeft( filter, pos );
 
         // Check that we have a right ')'
-        if ( StringTools.isCharASCII( filter, pos.start, ')' ) == false )
+        if ( !StringTools.isCharASCII( filter, pos.start, ')' ) )
         {
             throw new ParseException( "The filter has no right parenthese", pos.start );
         }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterVisitor.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterVisitor.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterVisitor.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterVisitor.java Fri Jun  6 23:28:06 2008
@@ -49,6 +49,7 @@
      * Visits a filter expression AST using a specific visitation order.
      * 
      * @param node the node to visit
+     * @return node the resulting modified node
      */
     Object visit( ExprNode node );
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java Fri Jun  6 23:28:06 2008
@@ -44,16 +44,8 @@
 
 
     /**
-     * @see Object#hashCode()
-     */
-    public int hashCode()
-    {
-        return super.hashCode();
-    }
-
-
-    /**
      * @see Object#toString()
+     * @return A string representing the AndNode
      */
     public String toString()
     {

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LeafNode.java Fri Jun  6 23:28:06 2008
@@ -26,7 +26,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public abstract class LeafNode extends AbstractExprNode
+public class LeafNode extends AbstractExprNode
 {
     /** attribute on which this leaf is based */
     private String attribute;
@@ -36,6 +36,7 @@
      * Creates a leaf node.
      * 
      * @param attribute the attribute this node is based on
+     * @param assertionType the type of this leaf node
      */
     protected LeafNode( String attribute, AssertionType assertionType )
     {
@@ -78,7 +79,28 @@
 
     
     /**
+     * @see org.apache.directory.shared.ldap.filter.ExprNode#accept(
+     *      org.apache.directory.shared.ldap.filter.FilterVisitor)
+     * 
+     * @param visitor the filter expression tree structure visitor
+     * @return The modified element
+     */
+    public final Object accept( FilterVisitor visitor )
+    {
+        if ( visitor.canVisit( this ) )
+        {
+            return visitor.visit( this );
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
      * @see Object#hashCode()
+     * @return the instance's hash code 
      */
     public int hashCode()
     {
@@ -111,26 +133,9 @@
         //noinspection SimplifiableIfStatement
         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/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java Fri Jun  6 23:28:06 2008
@@ -44,16 +44,8 @@
 
 
     /**
-     * @see Object#hashCode()
-     */
-    public int hashCode()
-    {
-        return super.hashCode();
-    }
-
-
-    /**
      * @see Object#toString()
+     * @return A string representing the AndNode
      */
     public String toString()
     {

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/NotNode.java Fri Jun  6 23:28:06 2008
@@ -38,14 +38,14 @@
      * 
      * @param childList the child nodes under this branch node.
      */
-    public NotNode( List<ExprNode> children )
+    public NotNode( List<ExprNode> childList )
     {
         super( AssertionType.NOT );
-        
-    	if ( this.children.size() > 1 )
-    	{
-    		throw new IllegalStateException( "Cannot add more than one element to a negation node." );    		
-    	}
+
+        if ( childList != null )
+        {
+            setChildren( childList );
+        }
     }
 
 
@@ -64,11 +64,11 @@
      */
     public void addNode( ExprNode node )
     {
-    	if ( children.size() >= 1 )
-    	{
-    		throw new IllegalStateException( "Cannot add more than one element to a negation node." );    		
-    	}
-    	
+        if ( ( children != null ) && ( children.size() >= 1 ) )
+        {
+            throw new IllegalStateException( "Cannot add more than one element to a negation node." );
+        }
+        
         children.add( node );
     }
 
@@ -80,11 +80,11 @@
      */
     public void addNodeToHead( ExprNode node )
     {
-    	if ( children.size() >= 1 )
-    	{
-    		throw new IllegalStateException( "Cannot add more than one element to a negation node." );    		
-    	}
-    	
+        if ( children.size() >= 1 )
+        {
+            throw new IllegalStateException( "Cannot add more than one element to a negation node." );            
+        }
+        
         children.add( node );
     }
 
@@ -92,16 +92,16 @@
     /**
      * Sets the list of children under this node.
      * 
-     * @param list the list of children to set.
+     * @param childList the list of children to set.
      */
-    public void setChildren( List<ExprNode> list )
+    public void setChildren( List<ExprNode> childList )
     {
-    	if ( ( list != null ) && ( list.size() > 1 ) )
-    	{
-    		throw new IllegalStateException( "Cannot add more than one element to a negation node." );    		
-    	}
+        if ( ( childList != null ) && ( childList.size() > 1 ) )
+        {
+            throw new IllegalStateException( "Cannot add more than one element to a negation node." );            
+        }
 
-    	children = list;
+        children = childList;
     }
 
     
@@ -151,23 +151,26 @@
 
     /**
      * @see ExprNode#printRefinementToBuffer(StringBuffer)
+     * 
+     * @return The buffer in which the refinement has been appended
+     * @throws UnsupportedOperationException if this node isn't a part of a refinement.
      */
-    public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
+    public StringBuilder printRefinementToBuffer( StringBuilder buf )
     {
         buf.append( "not: {" );
         boolean isFirst = true;
         
         for ( ExprNode node:children )
         {
-        	if ( isFirst )
-        	{
-        		isFirst = false;
-        	}
-        	else
-        	{
-        		buf.append( ", " );
-        	}
-        	
+            if ( isFirst )
+            {
+                isFirst = false;
+            }
+            else
+            {
+                buf.append( ", " );
+            }
+            
             node.printRefinementToBuffer( buf );
         }
         
@@ -181,6 +184,7 @@
      * down.
      * 
      * @see java.lang.Object#toString()
+     * @return A string representing the AndNode
      */
     public String toString()
     {
@@ -194,16 +198,4 @@
         
         return buf.toString();
     }
-
-
-    /**
-     * @see Object#hashCode()
-     */
-    public int hashCode()
-    {
-        int hash = 37;
-        hash = hash*17 + AssertionType.NOT.hashCode();
-        hash = hash*17 + ( annotations == null ? 0 : annotations.hashCode() );
-        return hash;
-    }
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/OrNode.java Fri Jun  6 23:28:06 2008
@@ -36,9 +36,9 @@
      * 
      * @param childList the child nodes under this branch node.
      */
-    public OrNode( List<ExprNode> children)
+    public OrNode( List<ExprNode> childList)
     {
-        super( children, AssertionType.OR );
+        super( childList, AssertionType.OR );
     }
 
 
@@ -99,23 +99,26 @@
 
     /**
      * @see ExprNode#printRefinementToBuffer(StringBuffer)
+     * 
+     * @return The buffer in which the refinement has been appended
+     * @throws UnsupportedOperationException if this node isn't a part of a refinement.
      */
-    public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
+    public StringBuilder printRefinementToBuffer( StringBuilder buf )
     {
         buf.append( "or: {" );
         boolean isFirst = true;
         
         for ( ExprNode node:children )
         {
-        	if ( isFirst )
-        	{
-        		isFirst = false;
-        	}
-        	else
-        	{
-        		buf.append( ", " );
-        	}
-        	
+            if ( isFirst )
+            {
+                isFirst = false;
+            }
+            else
+            {
+                buf.append( ", " );
+            }
+            
             node.printRefinementToBuffer( buf );
         }
         
@@ -129,6 +132,7 @@
      * down.
      * 
      * @see java.lang.Object#toString()
+     * @return A string representing the AndNode
      */
     public String toString()
     {
@@ -139,17 +143,18 @@
 
         for ( ExprNode child:getChildren() )
         {
-        	buf.append( child );
+            buf.append( child );
         }
         
         buf.append( ')' );
-	
+    
         return buf.toString();
     }
 
 
     /**
      * @see Object#hashCode()
+     * @return the instance's hash code 
      */
     public int hashCode()
     {
@@ -188,18 +193,18 @@
 
         if ( children.size() != otherChildren.size() )
         {
-        	return false;
+            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;
-        	}
+            ExprNode child = children.get( i );
+            ExprNode otherChild = children.get( i );
+            
+            if ( !child.equals( otherChild ) )
+            {
+                return false;
+            }
         }
         
         return true;

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/PresenceNode.java Fri Jun  6 23:28:06 2008
@@ -42,11 +42,12 @@
 
     /**
      * @see java.lang.Object#toString()
+     * @return A string representing the AndNode
      */
     public String toString()
     {
-    	StringBuilder buf = new StringBuilder();
-    	
+        StringBuilder buf = new StringBuilder();
+        
         buf.append( '(' ).append( getAttribute() ).append( "=*" );
 
         buf.append( super.toString() );
@@ -55,13 +56,4 @@
         
         return buf.toString();
     }
-
-    
-    /**
-     * @see ExprNode#printRefinementToBuffer(StringBuilder)
-     */
-    public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
-    {
-        throw new UnsupportedOperationException( "PresenceNode can't be part of a refinement" );
-    }
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java Fri Jun  6 23:28:06 2008
@@ -62,6 +62,7 @@
      * Always returns true since a scope node has no children.
      * 
      * @see ExprNode#isLeaf()
+     * @return <code>true</code>
      */
     public boolean isLeaf()
     {
@@ -103,17 +104,11 @@
 
 
     /**
-     * @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)
+     * 
+     * @param visitor the filter expression tree structure visitor
+     * @return The modified element
      */
     public Object accept( FilterVisitor visitor )
     {
@@ -123,13 +118,14 @@
         }
         else
         {
-        	return null;
+            return null;
         }
     }
-    
+
 
     /**
      * @see Object#hashCode()
+     * @return the instance's hash code 
      */
     public int hashCode()
     {
@@ -146,12 +142,13 @@
 
     /**
      * @see Object#toString()
+     * @return A string representing the AndNode
      */
     public String toString()
     {
-    	StringBuilder buf = new StringBuilder();
-    	
-    	buf.append( "(#{" );
+        StringBuilder buf = new StringBuilder();
+        
+        buf.append( "(#{" );
 
         switch ( scope )
         {
@@ -172,16 +169,17 @@
 
             default:
                 buf.append( "UNKNOWN" );
+                break;
         }
-    	
-    	buf.append( ", '" );
-    	buf.append( baseDn );
-    	buf.append( "', " );
-    	buf.append( aliasDerefAliases );
-    	buf.append( "}" );
-    	buf.append( super.toString() );
-    	buf.append( ')' );
-    	
-    	return buf.toString();
+        
+        buf.append( ", '" );
+        buf.append( baseDn );
+        buf.append( "', " );
+        buf.append( aliasDerefAliases );
+        buf.append( "}" );
+        buf.append( super.toString() );
+        buf.append( ')' );
+        
+        return buf.toString();
     }
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java Fri Jun  6 23:28:06 2008
@@ -35,13 +35,13 @@
     /** the value */
     protected Value<T> value;
 
-    /**
-     * Constants for comparisons
-     *
-     * TODO - why are these here if not used?
-     */
-    public final static boolean EVAL_GREATER = true;
-    public final static boolean EVAL_LESSER = false;
+    /* TODO - why are these here if not used? */
+    /** Constants for comparisons : > */
+    public static final boolean EVAL_GREATER = true;
+    
+    /* TODO - why are these here if not used? */
+    /** Constants for comparisons : < */
+    public static final boolean EVAL_LESSER = false;
 
 
     /**
@@ -105,8 +105,10 @@
 
     /**
      * @see ExprNode#printRefinementToBuffer(StringBuilder)
+     * @return The buffer in which the refinement has been appended
+     * @throws UnsupportedOperationException if this node isn't a part of a refinement.
      */
-    public StringBuilder printRefinementToBuffer( StringBuilder buf ) throws UnsupportedOperationException
+    public StringBuilder printRefinementToBuffer( StringBuilder buf )
     {
         if ( getAttribute() == null || !SchemaConstants.OBJECT_CLASS_AT.equalsIgnoreCase( getAttribute() ) )
         {
@@ -121,6 +123,7 @@
 
     /**
      * @see Object#hashCode()
+     * @return the instance's hash code 
      */
     public int hashCode()
     {

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java Fri Jun  6 23:28:06 2008
@@ -23,7 +23,6 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
 
 import javax.naming.NamingException;
 
@@ -114,10 +113,10 @@
      * Set the initial pattern
      * @param initialPattern The initial pattern
      */
-	public void setInitial( String initialPattern ) 
-	{
-		this.initialPattern = initialPattern;
-	}
+    public void setInitial( String initialPattern ) 
+    {
+        this.initialPattern = initialPattern;
+    }
 
     /**
      * Gets the final fragment or suffix.
@@ -134,10 +133,10 @@
      * Set the final pattern
      * @param finalPattern The final pattern
      */
-	public void setFinal( String finalPattern ) 
-	{
-		this.finalPattern = finalPattern;
-	}
+    public void setFinal( String finalPattern ) 
+    {
+        this.finalPattern = finalPattern;
+    }
 
 
     /**
@@ -155,10 +154,10 @@
      * Set the any patterns
      * @param anyPattern The any patterns
      */
-	public void setAny( List<String> anyPattern ) 
-	{
-		this.anyPattern = anyPattern;
-	}
+    public void setAny( List<String> anyPattern ) 
+    {
+        this.anyPattern = anyPattern;
+    }
 
 
     /**
@@ -176,10 +175,9 @@
      * 
      * @param normalizer the normalizer to use for pattern component normalization
      * @return the equivalent compiled regular expression
-     * @throws PatternSyntaxException if the regular expression is invalid
      * @throws NamingException if there are problems while normalizing
      */
-    public final Pattern getRegex( Normalizer normalizer ) throws PatternSyntaxException, NamingException
+    public final Pattern getRegex( Normalizer normalizer ) throws NamingException
     {
         if ( ( anyPattern != null ) && ( anyPattern.size() > 0 ) )
         {
@@ -232,6 +230,7 @@
 
     /**
      * @see Object#hashCode()
+     * @return the instance's hash code 
      */
     public int hashCode()
     {
@@ -256,11 +255,12 @@
 
     /**
      * @see java.lang.Object#toString()
+     * @return A string representing the AndNode
      */
     public String toString()
     {
-    	StringBuilder buf = new StringBuilder();
-    	
+        StringBuilder buf = new StringBuilder();
+        
         buf.append( '(' ).append( getAttribute() ).append( '=' );
 
         if ( null != initialPattern )
@@ -274,11 +274,11 @@
 
         if ( null != anyPattern )
         {
-	        for ( String any:anyPattern )
-	        {
-	            buf.append( any );
-	            buf.append( '*' );
-	        }
+            for ( String any:anyPattern )
+            {
+                buf.append( any );
+                buf.append( '*' );
+            }
         }
 
         if ( null != finalPattern )
@@ -292,13 +292,4 @@
         
         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" );
-    }
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/ChangeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/ChangeType.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/ChangeType.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/ChangeType.java Fri Jun  6 23:28:06 2008
@@ -34,10 +34,19 @@
     ModRdn( 3 ),
     Delete( 4 );
     
+    /** Add ordinal value */
     public static final int ADD_ORDINAL = 0;
+
+    /** Modify ordinal value */
     public static final int MODIFY_ORDINAL = 1;
+
+    /** ModDN ordinal value */
     public static final int MODDN_ORDINAL = 2;
+
+    /** ModRDN ordinal value */
     public static final int MODRDN_ORDINAL = 3;
+
+    /** Delete ordinal value */
     public static final int DELETE_ORDINAL = 4;
 
     /* the ordinal value for a change type */
@@ -60,7 +69,7 @@
      * 
      * @return the changeType
      */
-    public final int getChangeType()
+    public int getChangeType()
     {
         return changeType;
     }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReader.java Fri Jun  6 23:28:06 2008
@@ -22,7 +22,6 @@
 import java.io.BufferedReader;
 import java.io.StringReader;
 import java.util.ArrayList;
-import java.util.Iterator;
 
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -35,12 +34,16 @@
 
 /**
  * <pre>
- *  &lt;ldif-file&gt; ::= &quot;version:&quot; &lt;fill&gt; &lt;number&gt; &lt;seps&gt; &lt;dn-spec&gt; &lt;sep&gt; &lt;ldif-content-change&gt;
+ *  &lt;ldif-file&gt; ::= &quot;version:&quot; &lt;fill&gt; &lt;number&gt; &lt;seps&gt; &lt;dn-spec&gt; &lt;sep&gt; 
+ *  &lt;ldif-content-change&gt;
  *  
  *  &lt;ldif-content-change&gt; ::= 
- *    &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; &lt;ldif-attrval-record-e&gt; | 
- *    &lt;alpha&gt; &lt;chars-e&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; &lt;ldif-attrval-record-e&gt; | 
- *    &quot;control:&quot; &lt;fill&gt; &lt;number&gt; &lt;oid&gt; &lt;spaces-e&gt; &lt;criticality&gt; &lt;value-spec-e&gt; &lt;sep&gt; &lt;controls-e&gt; 
+ *    &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; 
+ *    &lt;ldif-attrval-record-e&gt; | 
+ *    &lt;alpha&gt; &lt;chars-e&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; 
+ *    &lt;ldif-attrval-record-e&gt; | 
+ *    &quot;control:&quot; &lt;fill&gt; &lt;number&gt; &lt;oid&gt; &lt;spaces-e&gt; &lt;criticality&gt; 
+ *    &lt;value-spec-e&gt; &lt;sep&gt; &lt;controls-e&gt; 
  *        &quot;changetype:&quot; &lt;fill&gt; &lt;changerecord-type&gt; &lt;ldif-change-record-e&gt; |
  *    &quot;changetype:&quot; &lt;fill&gt; &lt;changerecord-type&gt; &lt;ldif-change-record-e&gt;
  *                              
@@ -60,7 +63,8 @@
  *                              
  *  &lt;oid&gt; ::= '.' &lt;number&gt; &lt;oid&gt; | e
  *                              
- *  &lt;attrval-specs-e&gt; ::= &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; | 
+ *  &lt;attrval-specs-e&gt; ::= &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; 
+ *  &lt;attrval-specs-e&gt; | 
  *    &lt;alpha&gt; &lt;chars-e&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; | e
  *                              
  *  &lt;value-spec-e&gt; ::= &lt;value-spec&gt; | e
@@ -75,11 +79,15 @@
  *                              
  *  &lt;chars-e&gt; ::= &lt;char&gt; &lt;chars-e&gt; |  e
  *  
- *  &lt;changerecord-type&gt; ::= &quot;add&quot; &lt;sep&gt; &lt;attributeType&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; | 
+ *  &lt;changerecord-type&gt; ::= &quot;add&quot; &lt;sep&gt; &lt;attributeType&gt; &lt;options-e&gt; &lt;value-spec&gt; 
+ *  &lt;sep&gt; &lt;attrval-specs-e&gt; | 
  *    &quot;delete&quot; &lt;sep&gt; | 
- *    &quot;modify&quot; &lt;sep&gt; &lt;mod-type&gt; &lt;fill&gt; &lt;attributeType&gt; &lt;options-e&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; &lt;sep&gt; '-' &lt;sep&gt; &lt;mod-specs-e&gt; | 
- *    &quot;moddn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; &lt;fill&gt; &lt;0-1&gt; &lt;sep&gt; &lt;newsuperior-e&gt; &lt;sep&gt; |
- *    &quot;modrdn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; &lt;fill&gt; &lt;0-1&gt; &lt;sep&gt; &lt;newsuperior-e&gt; &lt;sep&gt;
+ *    &quot;modify&quot; &lt;sep&gt; &lt;mod-type&gt; &lt;fill&gt; &lt;attributeType&gt; &lt;options-e&gt; &lt;sep&gt; 
+ *    &lt;attrval-specs-e&gt; &lt;sep&gt; '-' &lt;sep&gt; &lt;mod-specs-e&gt; | 
+ *    &quot;moddn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; &lt;fill&gt; &lt;0-1&gt; &lt;sep&gt; 
+ *    &lt;newsuperior-e&gt; &lt;sep&gt; |
+ *    &quot;modrdn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; &lt;fill&gt; &lt;0-1&gt; &lt;sep&gt; 
+ *    &lt;newsuperior-e&gt; &lt;sep&gt;
  *  
  *  &lt;newrdn&gt; ::= ':' &lt;fill&gt; &lt;safe-string&gt; | &quot;::&quot; &lt;fill&gt; &lt;base64-chars&gt;
  *  
@@ -129,6 +137,7 @@
  * </pre>
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class LdifAttributesReader extends LdifReader
 {
@@ -149,11 +158,10 @@
     /**
      * Parse an AttributeType/AttributeValue
      * 
-     * @param entry The entry where to store the value
+     * @param attributes The entry where to store the value
      * @param line The line to parse
      * @param lowerLine The same line, lowercased
-     * @throws NamingException
-     *             If anything goes wrong
+     * @throws NamingException If anything goes wrong
      */
     private void parseAttribute( Attributes attributes, String line, String lowerLine ) throws NamingException
     {
@@ -192,6 +200,9 @@
      * &lt;dn-spec&gt; &lt;sep&gt; &lt;controls-e&gt; &lt;changerecord&gt; &lt;dn-spec&gt; ::= "dn:" &lt;fill&gt;
      * &lt;distinguishedName&gt; | "dn::" &lt;fill&gt; &lt;base64-distinguishedName&gt;
      * &lt;changerecord&gt; ::= "changetype:" &lt;fill&gt; &lt;change-op&gt;
+     * 
+     * @return The read entry
+     * @throws NamingException If the entry can't be read or is invalid
      */
     private Attributes parseAttributes() throws NamingException
     {
@@ -201,21 +212,14 @@
             return null;
         }
 
-        String line = lines.get( 0 );
-
         Attributes attributes = new BasicAttributes( true );
 
         // Now, let's iterate through the other lines
-        Iterator<String> iter = lines.iterator();
-
-        String lowerLine = null;
-
-        while ( iter.hasNext() )
+        for ( String line:lines )
         {
             // Each line could start either with an OID, an attribute type, with
             // "control:" or with "changetype:"
-            line = iter.next();
-            lowerLine = line.toLowerCase();
+            String lowerLine = line.toLowerCase();
 
             // We have three cases :
             // 1) The first line after the DN is a "control:" -> this is an error

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposer.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposer.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposer.java Fri Jun  6 23:28:06 2008
@@ -42,5 +42,5 @@
      *            the entry to export to ldif
      * @return the ldif of an entry
      */
-    String compose( MultiMap an_entry );
+    String compose( MultiMap<String,?> an_entry );
 }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposerImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposerImpl.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposerImpl.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposerImpl.java Fri Jun  6 23:28:06 2008
@@ -24,7 +24,6 @@
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Collection;
-import java.util.Iterator;
 
 import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.shared.ldap.util.MultiMap;
@@ -33,7 +32,109 @@
 /**
  * An LDAP Data Interchange Format (LDIF) composer.
  * 
- * TODO Get the RFC for LDIF syntax in this javadoc.
+ * <pre>
+ *  &lt;ldif-file&gt; ::= &quot;version:&quot; &lt;fill&gt; &lt;number&gt; &lt;seps&gt; &lt;dn-spec&gt; &lt;sep&gt; 
+ *  &lt;ldif-content-change&gt;
+ *  
+ *  &lt;ldif-content-change&gt; ::= 
+ *    &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; 
+ *    &lt;ldif-attrval-record-e&gt; | 
+ *    &lt;alpha&gt; &lt;chars-e&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; 
+ *    &lt;ldif-attrval-record-e&gt; | 
+ *    &quot;control:&quot; &lt;fill&gt; &lt;number&gt; &lt;oid&gt; &lt;spaces-e&gt; &lt;criticality&gt; 
+ *    &lt;value-spec-e&gt; &lt;sep&gt; &lt;controls-e&gt; 
+ *        &quot;changetype:&quot; &lt;fill&gt; &lt;changerecord-type&gt; &lt;ldif-change-record-e&gt; |
+ *    &quot;changetype:&quot; &lt;fill&gt; &lt;changerecord-type&gt; &lt;ldif-change-record-e&gt;
+ *                              
+ *  &lt;ldif-attrval-record-e&gt; ::= &lt;seps&gt; &lt;dn-spec&gt; &lt;sep&gt; &lt;attributeType&gt; 
+ *    &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; 
+ *    &lt;ldif-attrval-record-e&gt; | e
+ *                              
+ *  &lt;ldif-change-record-e&gt; ::= &lt;seps&gt; &lt;dn-spec&gt; &lt;sep&gt; &lt;controls-e&gt; 
+ *    &quot;changetype:&quot; &lt;fill&gt; &lt;changerecord-type&gt; &lt;ldif-change-record-e&gt; | e
+ *                              
+ *  &lt;dn-spec&gt; ::= &quot;dn:&quot; &lt;fill&gt; &lt;safe-string&gt; | &quot;dn::&quot; &lt;fill&gt; &lt;base64-string&gt;
+ *                              
+ *  &lt;controls-e&gt; ::= &quot;control:&quot; &lt;fill&gt; &lt;number&gt; &lt;oid&gt; &lt;spaces-e&gt; &lt;criticality&gt; 
+ *    &lt;value-spec-e&gt; &lt;sep&gt; &lt;controls-e&gt; | e
+ *                              
+ *  &lt;criticality&gt; ::= &quot;true&quot; | &quot;false&quot; | e
+ *                              
+ *  &lt;oid&gt; ::= '.' &lt;number&gt; &lt;oid&gt; | e
+ *                              
+ *  &lt;attrval-specs-e&gt; ::= &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; 
+ *  &lt;attrval-specs-e&gt; | 
+ *    &lt;alpha&gt; &lt;chars-e&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; | e
+ *                              
+ *  &lt;value-spec-e&gt; ::= &lt;value-spec&gt; | e
+ *  
+ *  &lt;value-spec&gt; ::= ':' &lt;fill&gt; &lt;safe-string-e&gt; | 
+ *    &quot;::&quot; &lt;fill&gt; &lt;base64-chars&gt; | 
+ *    &quot;:&lt;&quot; &lt;fill&gt; &lt;url&gt;
+ *  
+ *  &lt;attributeType&gt; ::= &lt;number&gt; &lt;oid&gt; | &lt;alpha&gt; &lt;chars-e&gt;
+ *  
+ *  &lt;options-e&gt; ::= ';' &lt;char&gt; &lt;chars-e&gt; &lt;options-e&gt; |e
+ *                              
+ *  &lt;chars-e&gt; ::= &lt;char&gt; &lt;chars-e&gt; |  e
+ *  
+ *  &lt;changerecord-type&gt; ::= &quot;add&quot; &lt;sep&gt; &lt;attributeType&gt; 
+ *  &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; | 
+ *    &quot;delete&quot; &lt;sep&gt; | 
+ *    &quot;modify&quot; &lt;sep&gt; &lt;mod-type&gt; &lt;fill&gt; &lt;attributeType&gt; &lt;options-e&gt; 
+ *    &lt;sep&gt; &lt;attrval-specs-e&gt; &lt;sep&gt; '-' &lt;sep&gt; &lt;mod-specs-e&gt; | 
+ *    &quot;moddn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; &lt;fill&gt; 
+ *    &lt;0-1&gt; &lt;sep&gt; &lt;newsuperior-e&gt; &lt;sep&gt; |
+ *    &quot;modrdn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; &lt;fill&gt; 
+ *    &lt;0-1&gt; &lt;sep&gt; &lt;newsuperior-e&gt; &lt;sep&gt;
+ *  
+ *  &lt;newrdn&gt; ::= ':' &lt;fill&gt; &lt;safe-string&gt; | &quot;::&quot; &lt;fill&gt; &lt;base64-chars&gt;
+ *  
+ *  &lt;newsuperior-e&gt; ::= &quot;newsuperior&quot; &lt;newrdn&gt; | e
+ *  
+ *  &lt;mod-specs-e&gt; ::= &lt;mod-type&gt; &lt;fill&gt; &lt;attributeType&gt; &lt;options-e&gt; 
+ *    &lt;sep&gt; &lt;attrval-specs-e&gt; &lt;sep&gt; '-' &lt;sep&gt; &lt;mod-specs-e&gt; | e
+ *  
+ *  &lt;mod-type&gt; ::= &quot;add:&quot; | &quot;delete:&quot; | &quot;replace:&quot;
+ *  
+ *  &lt;url&gt; ::= &lt;a Uniform Resource Locator, as defined in [6]&gt;
+ *  
+ *  
+ *  
+ *  LEXICAL
+ *  -------
+ *  
+ *  &lt;fill&gt;           ::= ' ' &lt;fill&gt; | e
+ *  &lt;char&gt;           ::= &lt;alpha&gt; | &lt;digit&gt; | '-'
+ *  &lt;number&gt;         ::= &lt;digit&gt; &lt;digits&gt;
+ *  &lt;0-1&gt;            ::= '0' | '1'
+ *  &lt;digits&gt;         ::= &lt;digit&gt; &lt;digits&gt; | e
+ *  &lt;digit&gt;          ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
+ *  &lt;seps&gt;           ::= &lt;sep&gt; &lt;seps-e&gt; 
+ *  &lt;seps-e&gt;         ::= &lt;sep&gt; &lt;seps-e&gt; | e
+ *  &lt;sep&gt;            ::= 0x0D 0x0A | 0x0A
+ *  &lt;spaces&gt;         ::= ' ' &lt;spaces-e&gt;
+ *  &lt;spaces-e&gt;       ::= ' ' &lt;spaces-e&gt; | e
+ *  &lt;safe-string-e&gt;  ::= &lt;safe-string&gt; | e
+ *  &lt;safe-string&gt;    ::= &lt;safe-init-char&gt; &lt;safe-chars&gt;
+ *  &lt;safe-init-char&gt; ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39] | 0x3B | [0x3D-0x7F]
+ *  &lt;safe-chars&gt;     ::= &lt;safe-char&gt; &lt;safe-chars&gt; | e
+ *  &lt;safe-char&gt;      ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F]
+ *  &lt;base64-string&gt;  ::= &lt;base64-char&gt; &lt;base64-chars&gt;
+ *  &lt;base64-chars&gt;   ::= &lt;base64-char&gt; &lt;base64-chars&gt; | e
+ *  &lt;base64-char&gt;    ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-9x5A] | [0x61-0x7A]
+ *  &lt;alpha&gt;          ::= [0x41-0x5A] | [0x61-0x7A]
+ *  
+ *  COMMENTS
+ *  --------
+ *  - The ldap-oid VN is not correct in the RFC-2849. It has been changed from 1*DIGIT 0*1(&quot;.&quot; 1*DIGIT) to
+ *  DIGIT+ (&quot;.&quot; DIGIT+)*
+ *  - The mod-spec lacks a sep between *attrval-spec and &quot;-&quot;.
+ *  - The BASE64-UTF8-STRING should be BASE64-CHAR BASE64-STRING
+ *  - The ValueSpec rule must accept multilines values. In this case, we have a LF followed by a 
+ *  single space before the continued value.
+ * </pre>
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Revision$
  */
@@ -42,25 +143,17 @@
     /**
      * Generates an LDIF from a multi map.
      * 
-     * @param attrHash
-     *            the multi map of single and multivalued attributes.
+     * @param attrHash the multi map of single and multivalued attributes.
      * @return the LDIF as a String.
      */
-    public String compose( MultiMap attrHash )
+    public String compose( MultiMap<String,?> attrHash )
     {
-        Object val = null;
-        String key = null;
-        Iterator<String> keys = attrHash.keySet().iterator();
-        Iterator values = null;
-        Collection valueCol = null;
         StringWriter sw = new StringWriter();
         PrintWriter out = new PrintWriter( sw );
 
-        while ( keys.hasNext() )
+        for ( String key:attrHash.keySet() )
         {
-            key = keys.next();
-            valueCol = ( Collection ) attrHash.get( key );
-            values = valueCol.iterator();
+            Collection<?> valueCol = ( Collection<?> ) attrHash.get( key );
 
             if ( valueCol.isEmpty() )
             {
@@ -70,7 +163,7 @@
             {
                 out.print( key );
                 out.print( ':' );
-                val = values.next();
+                Object val = valueCol.iterator().next();
 
                 if ( val.getClass().isArray() )
                 {
@@ -85,11 +178,10 @@
                 continue;
             }
 
-            while ( values.hasNext() )
+            for ( Object val:valueCol )
             {
                 out.print( key );
                 out.print( ':' );
-                val = values.next();
 
                 if ( val.getClass().isArray() )
                 {

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java Fri Jun  6 23:28:06 2008
@@ -30,10 +30,11 @@
  * file.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class LdifControl implements Control
 {
-    static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
     /** The control OID */
     private OID oid;
@@ -59,6 +60,7 @@
 
     /**
      * Returns the criticality of the current control
+     * @return <code>true</code> if the control is critical
      */
     public boolean isCritical()
     {
@@ -78,6 +80,7 @@
 
     /**
      * Return the control's OID as a String
+     * @return The control's OID
      */
     public String getID()
     {
@@ -87,8 +90,7 @@
     /**
      * Set the control's OID
      * 
-     * @param oid
-     *            The control's OID
+     * @param oid The control's OID
      */
     public void setOid( OID oid )
     {
@@ -97,6 +99,7 @@
 
     /**
      * Returns the BER encoded value of the control
+     * @return the BER encoded value
      */
     public byte[] getEncodedValue()
     {

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java Fri Jun  6 23:28:06 2008
@@ -20,12 +20,11 @@
 
 package org.apache.directory.shared.ldap.ldif;
 
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
-import org.apache.directory.shared.ldap.message.ModificationItemImpl;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.name.Rdn;
-import org.apache.directory.shared.ldap.util.StringTools;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
 
 import javax.naming.InvalidNameException;
 import javax.naming.NamingEnumeration;
@@ -33,12 +32,15 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.Control;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -52,9 +54,12 @@
  * - DN modified entries
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class LdifEntry implements Cloneable, Serializable
 {
+    private static final long serialVersionUID = 2L;
+    
     /** Used in toArray() */
     public static final ModificationItemImpl[] EMPTY_MODS = new ModificationItemImpl[0];
 
@@ -168,14 +173,12 @@
     /**
      * Add a modification item (used by modify operations)
      * 
-     * @param modOp
-     *            The operation. One of : DirContext.ADD_ATTRIBUTE
+     * @param modOp The operation. One of : DirContext.ADD_ATTRIBUTE
      *            DirContext.REMOVE_ATTRIBUTE DirContext.REPLACE_ATTRIBUTE
      * 
-     * @param attr
-     *            The attribute to be added
+     * @param attr The attribute to be added
      */
-    public void addModificationItem( int modOp, Attribute attr ) throws NamingException
+    public void addModificationItem( int modOp, Attribute attr )
     {
         if ( changeType == ChangeType.Modify )
         {
@@ -192,12 +195,11 @@
      *            The operation. One of : DirContext.ADD_ATTRIBUTE
      *            DirContext.REMOVE_ATTRIBUTE DirContext.REPLACE_ATTRIBUTE
      * 
-     * @param id
-     *            The attribute's ID
-     * @param value
-     *            The attribute's value
+     * @param modOp The modification operation value
+     * @param id The attribute's ID
+     * @param value The attribute's value
      */
-    public void addModificationItem( int modOp, String id, Object value ) throws NamingException
+    public void addModificationItem( int modOp, String id, Object value )
     {
         if ( changeType == ChangeType.Modify )
         {
@@ -446,6 +448,11 @@
         return changeType == ChangeType.Modify;
     }
 
+    /**
+     * Tells if the current entry is a added one
+     *
+     * @return <code>true</code> if the entry is added
+     */
     public boolean isEntry()
     {
         return changeType == ChangeType.Add;
@@ -472,6 +479,8 @@
 
     /**
      * Clone method
+     * @return a clone of the current instance
+     * @exception CloneNotSupportedException If there is some problem while cloning the instance
      */
     public LdifEntry clone() throws CloneNotSupportedException
     {
@@ -481,8 +490,8 @@
         {
             for ( ModificationItemImpl modif:modificationList )
             {
-                ModificationItemImpl modifClone = new ModificationItemImpl( modif.getModificationOp(), (Attribute) modif.getAttribute()
-                        .clone() );
+                ModificationItemImpl modifClone = new ModificationItemImpl( modif.getModificationOp(), 
+                    (Attribute) modif.getAttribute().clone() );
                 clone.modificationList.add( modifClone );
             }
         }
@@ -492,8 +501,8 @@
             for ( String key:modificationItems.keySet() )
             {
                 ModificationItemImpl modif = modificationItems.get( key );
-                ModificationItemImpl modifClone = new ModificationItemImpl( modif.getModificationOp(), (Attribute) modif.getAttribute()
-                        .clone() );
+                ModificationItemImpl modifClone = new ModificationItemImpl( modif.getModificationOp(), 
+                    (Attribute) modif.getAttribute().clone() );
                 clone.modificationItems.put( key, modifClone );
             }
 
@@ -509,23 +518,32 @@
     
     /**
      * Dumps the attributes
+     * @return A String representing the attributes
      */
     private String dumpAttributes()
     {
         StringBuffer sb = new StringBuffer();
+        Attribute attribute = null;
         
         try
         {
-            for ( NamingEnumeration<? extends Attribute> attrs = attributes.getAll(); attrs.hasMoreElements(); )
+            for ( NamingEnumeration<? extends Attribute> attrs = attributes.getAll(); 
+                  attrs.hasMoreElements(); 
+                  attribute = attrs.nextElement())
             {
-                Attribute attribute = attrs.nextElement();
-    
+                if ( attribute == null )
+                {
+                    sb.append( "        Null attribute\n" );
+                    continue;
+                }
+                
                 sb.append( "        ").append( attribute.getID() ).append( ":\n" );
-    
-                for ( NamingEnumeration<?> values = attribute.getAll(); values.hasMoreElements(); )
+                Object value = null;
+                
+                for ( NamingEnumeration<?> values = attribute.getAll(); 
+                      values.hasMoreElements(); 
+                      value = values.nextElement())
                 {
-                    Object value = values.nextElement();
-                    
                     if ( value instanceof String )
                     {
                         sb.append(  "            " ).append( (String)value ).append('\n' );
@@ -547,6 +565,7 @@
     
     /**
      * Dumps the modifications
+     * @return A String representing the modifications
      */
     private String dumpModificationItems()
     {
@@ -569,6 +588,9 @@
                 case DirContext.REPLACE_ATTRIBUTE :
                     sb.append( "REPLACE \n" );
                     break;
+                    
+                default :
+                    break; // Do nothing
             }
             
             Attribute attribute = modif.getAttribute();
@@ -579,10 +601,11 @@
             {
                 try
                 {
-                    for ( NamingEnumeration<?> values = attribute.getAll(); values.hasMoreElements(); )
+                    Object value = null;
+                    for ( NamingEnumeration<?> values = attribute.getAll(); 
+                          values.hasMoreElements(); 
+                          value = values.nextElement() )
                     {
-                        Object value = values.nextElement();
-    
                         if ( value instanceof String )
                         {
                             sb.append(  "                " ).append( (String)value ).append('\n' );
@@ -605,7 +628,7 @@
 
     
     /**
-     * Return a String representing the Entry
+     * @return a String representing the Entry
      */
     public String toString()
     {
@@ -641,12 +664,15 @@
                 sb.append( "    Delete old RDN : " ).append( deleteOldRdn ? "true\n" : "false\n" );
                 sb.append( "    New RDN : " ).append( newRdn ).append( '\n' );
                 
-                if ( StringTools.isEmpty( newSuperior ) == false )
+                if ( !StringTools.isEmpty( newSuperior ) )
                 {
                     sb.append( "    New superior : " ).append( newSuperior ).append( '\n' );
                 }
 
                 break;
+                
+            default :
+                break; // Do nothing
         }
         
         return sb.toString();
@@ -654,7 +680,84 @@
     
     
     /**
+     * @see Object#hashCode()
+     * 
+     * @return the instance's hash code
+     */
+    public int hashCode()
+    {
+        int result = 37;
+
+        if ( dn != null )
+        {
+            result = result*17 + dn.hashCode();
+        }
+        
+        if ( changeType != null )
+        {
+            result = result*17 + changeType.hashCode();
+            
+            // Check each different cases
+            switch ( changeType )
+            {
+                case Add :
+                    // Checks the attributes
+                    if ( attributes != null )
+                    {
+                        result = result * 17 + attributes.hashCode();
+                    }
+                    
+                    break;
+
+                case Delete :
+                    // Nothing to compute
+                    break;
+                    
+                case Modify :
+                    if ( modificationList != null )
+                    {
+                        result = result * 17 + modificationList.hashCode();
+                        
+                        for ( ModificationItem modification:modificationList )
+                        {
+                            result = result * 17 + modification.hashCode();
+                        }
+                    }
+                    
+                    break;
+                    
+                case ModDn :
+                case ModRdn :
+                    result = result * 17 + ( deleteOldRdn ? 1 : -1 ); 
+                    
+                    if ( newRdn != null )
+                    {
+                        result = result*17 + newRdn.hashCode();
+                    }
+                    
+                    if ( newSuperior != null )
+                    {
+                        result = result*17 + newSuperior.hashCode();
+                    }
+                    
+                    break;
+                    
+                default :
+                    break; // do nothing
+            }
+        }
+
+        if ( control != null )
+        {
+            result = result * 17 + control.hashCode();
+        }
+
+        return result;
+    }
+    
+    /**
      * @see Object#equals(Object)
+     * @return <code>true</code> if both values are equal
      */
     public boolean equals( Object o )
     {
@@ -666,7 +769,7 @@
         
         if ( o == null )
         {
-            return false;
+           return false;
         }
         
         if ( ! (o instanceof LdifEntry ) )
@@ -818,6 +921,9 @@
                 }
                 
                 break;
+                
+            default :
+                break; // do nothing
         }
         
         if ( control != null )

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?rev=664290&r1=664289&r2=664290&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java Fri Jun  6 23:28:06 2008
@@ -57,12 +57,16 @@
 
 /**
  * <pre>
- *  &lt;ldif-file&gt; ::= &quot;version:&quot; &lt;fill&gt; &lt;number&gt; &lt;seps&gt; &lt;dn-spec&gt; &lt;sep&gt; &lt;ldif-content-change&gt;
+ *  &lt;ldif-file&gt; ::= &quot;version:&quot; &lt;fill&gt; &lt;number&gt; &lt;seps&gt; &lt;dn-spec&gt; &lt;sep&gt; 
+ *  &lt;ldif-content-change&gt;
  *  
  *  &lt;ldif-content-change&gt; ::= 
- *    &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; &lt;ldif-attrval-record-e&gt; | 
- *    &lt;alpha&gt; &lt;chars-e&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; &lt;ldif-attrval-record-e&gt; | 
- *    &quot;control:&quot; &lt;fill&gt; &lt;number&gt; &lt;oid&gt; &lt;spaces-e&gt; &lt;criticality&gt; &lt;value-spec-e&gt; &lt;sep&gt; &lt;controls-e&gt; 
+ *    &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; 
+ *    &lt;attrval-specs-e&gt; &lt;ldif-attrval-record-e&gt; | 
+ *    &lt;alpha&gt; &lt;chars-e&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; 
+ *    &lt;attrval-specs-e&gt; &lt;ldif-attrval-record-e&gt; | 
+ *    &quot;control:&quot; &lt;fill&gt; &lt;number&gt; &lt;oid&gt; &lt;spaces-e&gt; 
+ *    &lt;criticality&gt; &lt;value-spec-e&gt; &lt;sep&gt; &lt;controls-e&gt; 
  *        &quot;changetype:&quot; &lt;fill&gt; &lt;changerecord-type&gt; &lt;ldif-change-record-e&gt; |
  *    &quot;changetype:&quot; &lt;fill&gt; &lt;changerecord-type&gt; &lt;ldif-change-record-e&gt;
  *                              
@@ -82,7 +86,8 @@
  *                              
  *  &lt;oid&gt; ::= '.' &lt;number&gt; &lt;oid&gt; | e
  *                              
- *  &lt;attrval-specs-e&gt; ::= &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; | 
+ *  &lt;attrval-specs-e&gt; ::= &lt;number&gt; &lt;oid&gt; &lt;options-e&gt; &lt;value-spec&gt; 
+ *  &lt;sep&gt; &lt;attrval-specs-e&gt; | 
  *    &lt;alpha&gt; &lt;chars-e&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; | e
  *                              
  *  &lt;value-spec-e&gt; ::= &lt;value-spec&gt; | e
@@ -97,11 +102,15 @@
  *                              
  *  &lt;chars-e&gt; ::= &lt;char&gt; &lt;chars-e&gt; |  e
  *  
- *  &lt;changerecord-type&gt; ::= &quot;add&quot; &lt;sep&gt; &lt;attributeType&gt; &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; | 
+ *  &lt;changerecord-type&gt; ::= &quot;add&quot; &lt;sep&gt; &lt;attributeType&gt; 
+ *  &lt;options-e&gt; &lt;value-spec&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; | 
  *    &quot;delete&quot; &lt;sep&gt; | 
- *    &quot;modify&quot; &lt;sep&gt; &lt;mod-type&gt; &lt;fill&gt; &lt;attributeType&gt; &lt;options-e&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; &lt;sep&gt; '-' &lt;sep&gt; &lt;mod-specs-e&gt; | 
- *    &quot;moddn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; &lt;fill&gt; &lt;0-1&gt; &lt;sep&gt; &lt;newsuperior-e&gt; &lt;sep&gt; |
- *    &quot;modrdn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; &lt;fill&gt; &lt;0-1&gt; &lt;sep&gt; &lt;newsuperior-e&gt; &lt;sep&gt;
+ *    &quot;modify&quot; &lt;sep&gt; &lt;mod-type&gt; &lt;fill&gt; &lt;attributeType&gt; 
+ *    &lt;options-e&gt; &lt;sep&gt; &lt;attrval-specs-e&gt; &lt;sep&gt; '-' &lt;sep&gt; &lt;mod-specs-e&gt; | 
+ *    &quot;moddn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; 
+ *    &lt;fill&gt; &lt;0-1&gt; &lt;sep&gt; &lt;newsuperior-e&gt; &lt;sep&gt; |
+ *    &quot;modrdn&quot; &lt;sep&gt; &lt;newrdn&gt; &lt;sep&gt; &quot;deleteoldrdn:&quot; 
+ *    &lt;fill&gt; &lt;0-1&gt; &lt;sep&gt; &lt;newsuperior-e&gt; &lt;sep&gt;
  *  
  *  &lt;newrdn&gt; ::= ':' &lt;fill&gt; &lt;safe-string&gt; | &quot;::&quot; &lt;fill&gt; &lt;base64-chars&gt;
  *  
@@ -151,27 +160,45 @@
  * </pre>
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
-public class LdifReader implements Iterator<LdifEntry>
+public class LdifReader implements Iterable<LdifEntry>
 {
     /** A logger */
     private static final Logger LOG = LoggerFactory.getLogger( LdifReader.class );
 
-    /** A private class to track the current position in a line */
-    protected class Position
-    {
-        public int pos;
-
+    /** 
+     * A private class to track the current position in a line 
+     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+     * @version $Rev$, $Date$
+     */
+    public class Position
+    {
+        /** The current position */
+        private int pos;
+
+        /**
+         * Creates a new instance of Position.
+         */
         public Position()
         {
             pos = 0;
         }
 
+        /**
+         * Increment the current position by one
+         *
+         */
         public void inc()
         {
             pos++;
         }
 
+        /**
+         * Increment the current position by the given value
+         *
+         * @param val The value to add to the current position
+         */
         public void inc( int val )
         {
             pos += val;
@@ -191,7 +218,7 @@
     protected int version;
 
     /** Type of element read */
-    protected static final int ENTRY = 0;
+    protected static final int LDIF_ENTRY = 0;
 
     protected static final int CHANGE = 1;
 
@@ -263,13 +290,13 @@
     {
         File inf = new File( ldifFileName );
 
-        if ( inf.exists() == false )
+        if ( !inf.exists() )
         {
             LOG.error( "File {} cannot be found", inf.getAbsoluteFile() );
             throw new NamingException( "Cannot find file " + inf.getAbsoluteFile() );
         }
 
-        if ( inf.canRead() == false )
+        if ( !inf.canRead() )
         {
             LOG.error( "File {} cannot be read", inf.getName() );
             throw new NamingException( "Cannot read file " + inf.getName() );
@@ -335,13 +362,13 @@
      */
     public LdifReader( File in ) throws NamingException
     {
-        if ( in.exists() == false )
+        if ( !in.exists() )
         {
             LOG.error( "File {} cannot be found", in.getAbsoluteFile() );
             throw new NamingException( "Cannot find file " + in.getAbsoluteFile() );
         }
 
-        if ( in.canRead() == false )
+        if ( !in.canRead() )
         {
             LOG.error( "File {} cannot be read", in.getName() );
             throw new NamingException( "Cannot read file " + in.getName() );
@@ -402,6 +429,10 @@
      * ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
      * 
      * Check that the number is in the interval
+     * 
+     * @param document The document containing the number to parse
+     * @param position The current position in the document
+     * @return a String representing the parsed number
      */
     private static String parseNumber( char[] document, Position position )
     {
@@ -611,7 +642,7 @@
 
                         File file = new File( fileName );
 
-                        if ( file.exists() == false )
+                        if ( !file.exists() )
                         {
                             LOG.error( "File {} not found", fileName );
                             throw new NamingException( "Bad URL, file not found" );
@@ -652,17 +683,14 @@
                                 }
                                 finally
                                 {
-                                    if ( inf != null )
+                                    try
+                                    {
+                                        inf.close();
+                                    }
+                                    catch ( IOException ioe )
                                     {
-                                        try
-                                        {
-                                            inf.close();
-                                        }
-                                        catch ( IOException ioe )
-                                        {
-                                            LOG.error( "Error while closing the stream : {}", ioe.getMessage() );
-                                            // Just do nothing ...
-                                        }
+                                        LOG.error( "Error while closing the stream : {}", ioe.getMessage() );
+                                        // Just do nothing ...
                                     }
                                 }
                             }
@@ -702,9 +730,10 @@
      * "false") ] [ ":" &lt;fill&gt; &lt;SAFE-STRING-e&gt; | "::" &lt;fill&gt; &lt;BASE64-STRING&gt; | ":<"
      * &lt;fill&gt; &lt;url&gt; ]
      * 
-     * @param line
-     *            The line containing the control
+     * @param line The line containing the control
      * @return A control
+     * @exception NamingException If the control has no OID or if the OID is incorrect,
+     * of if the criticality is not set when it's mandatory.
      */
     private Control parseControl( String line ) throws NamingException
     {
@@ -824,6 +853,7 @@
      * Parse an AttributeType/AttributeValue
      * 
      * @param line The line to parse
+     * @return the parsed Attribute
      */
     public static Attribute parseAttributeValue( String line )
     {
@@ -846,14 +876,10 @@
     /**
      * Parse an AttributeType/AttributeValue
      * 
-     * @param entry
-     *            The entry where to store the value
-     * @param line
-     *            The line to parse
-     * @param lowerLine
-     *            The same line, lowercased
-     * @throws NamingException
-     *             If anything goes wrong
+     * @param entry The entry where to store the value
+     * @param line The line to parse
+     * @param lowerLine The same line, lowercased
+     * @throws NamingException If anything goes wrong
      */
     public void parseAttributeValue( LdifEntry entry, String line, String lowerLine ) throws NamingException
     {
@@ -950,10 +976,9 @@
      * ATTRIBUTE-DESCRIPTION SEP &lt;attrval-specs-e&gt; "-" SEP &lt;attrval-specs-e&gt; ::=
      * ATTRVAL-SPEC &lt;attrval-specs&gt; | e *
      * 
-     * @param entry
-     *            The entry to feed
-     * @param iter
-     *            The lines
+     * @param entry The entry to feed
+     * @param iter The lines
+     * @exception NamingException If the modify operation is invalid
      */
     private void parseModify( LdifEntry entry, Iterator<String> iter ) throws NamingException
     {
@@ -1050,7 +1075,7 @@
 
                 String attributeType = line.substring( 0, colonIndex );
 
-                if ( attributeType.equalsIgnoreCase( modified ) == false )
+                if ( !attributeType.equalsIgnoreCase( modified ) )
                 {
                     LOG.error( "The modified attribute and the attribute value spec must be equal" );
                     throw new NamingException( "Bad modify attribute" );
@@ -1095,17 +1120,12 @@
      * ::= FILL ATTRIBUTE-DESCRIPTION SEP ATTRVAL-SPEC &lt;attrval-specs-e&gt; "-" SEP
      * &lt;attrval-specs-e&gt; ::= ATTRVAL-SPEC &lt;attrval-specs&gt; | e
      * 
-     * @param entry
-     *            The entry to feed
-     * @param iter
-     *            The lines iterator
-     * @param operation
-     *            The change operation (add, modify, delete, moddn or modrdn)
-     * @param control
-     *            The associated control, if any
-     * @return A modification entry
+     * @param entry The entry to feed
+     * @param iter The lines iterator
+     * @param operation The change operation (add, modify, delete, moddn or modrdn)
+     * @exception NamingException If the change operation is invalid
      */
-    private void parseChange( LdifEntry entry, Iterator<String> iter, ChangeType operation, Control control ) throws NamingException
+    private void parseChange( LdifEntry entry, Iterator<String> iter, ChangeType operation ) throws NamingException
     {
         // The changetype and operation has already been parsed.
         entry.setChangeType( operation );
@@ -1186,6 +1206,9 @@
      * &lt;dn-spec&gt; &lt;sep&gt; &lt;controls-e&gt; &lt;changerecord&gt; &lt;dn-spec&gt; ::= "dn:" &lt;fill&gt;
      * &lt;distinguishedName&gt; | "dn::" &lt;fill&gt; &lt;base64-distinguishedName&gt;
      * &lt;changerecord&gt; ::= "changetype:" &lt;fill&gt; &lt;change-op&gt;
+     * 
+     * @return the parsed ldifEntry
+     * @exception NamingException If the ldif file does not contain a valid entry 
      */
     private LdifEntry parseEntry() throws NamingException
     {
@@ -1279,7 +1302,7 @@
                 operation = parseChangeType( line );
 
                 // Parse the change operation in a separate function
-                parseChange( entry, iter, operation, control );
+                parseChange( entry, iter, operation );
                 changeTypeSeen = true;
             }
             else if ( line.indexOf( ':' ) > 0 )
@@ -1299,7 +1322,7 @@
                 }
 
                 parseAttributeValue( entry, line, lowerLine );
-                type = ENTRY;
+                type = LDIF_ENTRY;
             }
             else
             {
@@ -1309,7 +1332,7 @@
             }
         }
 
-        if ( type == ENTRY )
+        if ( type == LDIF_ENTRY )
         {
             LOG.debug( "Read an entry : {}", entry );
         }
@@ -1527,26 +1550,25 @@
 
         File file = new File( fileName );
 
-        if ( file.exists() == false )
+        if ( !file.exists() )
         {
             LOG.error( "Cannot parse the file {}, it does not exist", fileName );
             throw new NamingException( "Filename " + fileName + " not found." );
         }
 
         // Open the file and then get a channel from the stream
-        BufferedReader inf;
-
         try
         {
-            inf = new BufferedReader( new InputStreamReader( new FileInputStream( file ), Charset.forName( encoding ) ) );
+            BufferedReader inf = new BufferedReader( new InputStreamReader( new FileInputStream( file ), 
+                Charset.forName( encoding ) ) );
+
+            return parseLdif( inf );
         }
         catch (FileNotFoundException fnfe)
         {
             LOG.error( "Cannot find file {}", fileName );
             throw new NamingException( "Filename " + fileName + " not found." );
         }
-
-        return parseLdif( inf );
     }
 
     /**
@@ -1596,8 +1618,9 @@
      * Gets the next LDIF on the channel.
      * 
      * @return the next LDIF as a String.
+     * @exception NoSuchElementException If we can't read the next entry
      */
-    public LdifEntry next() throws NoSuchElementException
+    private LdifEntry nextInternal()
     {
         try
         {
@@ -1613,6 +1636,7 @@
             catch (NamingException ne)
             {
                 error = ne;
+                throw new NoSuchElementException( ne.getMessage() );
             }
 
             LOG.debug( "next(): -- returning ldif {}\n", entry );
@@ -1627,6 +1651,30 @@
         }
     }
 
+    
+    /**
+     * Gets the next LDIF on the channel.
+     * 
+     * @return the next LDIF as a String.
+     * @exception NoSuchElementException If we can't read the next entry
+     */
+    public LdifEntry next()
+    {
+        return nextInternal();
+    }
+
+
+    /**
+     * Tests to see if another LDIF is on the input channel.
+     * 
+     * @return true if another LDIF is available false otherwise.
+     */
+    private boolean hasNextInternal()
+    {
+        return null != prefetched;
+    }
+
+    
     /**
      * Tests to see if another LDIF is on the input channel.
      * 
@@ -1636,25 +1684,53 @@
     {
         LOG.debug( "hasNext(): -- returning {}", ( prefetched != null ) ? Boolean.TRUE : Boolean.FALSE );
 
-        return null != prefetched;
+        return hasNextInternal();
     }
 
+
     /**
      * Always throws UnsupportedOperationException!
      * 
      * @see java.util.Iterator#remove()
      */
-    public void remove()
+    private void removeInternal()
     {
         throw new UnsupportedOperationException();
     }
 
+    
+    /**
+     * Always throws UnsupportedOperationException!
+     * 
+     * @see java.util.Iterator#remove()
+     */
+    public void remove()
+    {
+        removeInternal();
+    }
+
     /**
      * @return An iterator on the file
      */
     public Iterator<LdifEntry> iterator()
     {
-        return this;
+        return new Iterator<LdifEntry>() 
+        {
+            public boolean hasNext() 
+            {
+                return hasNextInternal();
+            }
+          
+            public LdifEntry next() 
+            {
+                return nextInternal();
+            }
+          
+            public void remove() 
+            {
+                throw new UnsupportedOperationException();
+            }
+        };
     }
 
     /**
@@ -1695,19 +1771,20 @@
         prefetched = parseEntry();
 
         // When done, get the entries one by one.
-        while ( hasNext() )
+        try
         {
-            LdifEntry entry = next();
-
-            if ( error != null )
-            {
-                throw new NamingException( "Error while parsing ldif : " + error.getMessage() );
-            }
-            else if ( entry != null )
+            for ( LdifEntry entry:this )
             {
-                entries.add( entry );
+                if ( entry != null )
+                {
+                    entries.add( entry );
+                }
             }
         }
+        catch ( NoSuchElementException nsee )
+        {
+            throw new NamingException( "Error while parsing ldif : " + error.getMessage() );
+        }
 
         return entries;
     }



Mime
View raw message