directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1158759 - in /directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm: ./ search/impl/
Date Wed, 17 Aug 2011 15:03:22 GMT
Author: elecharny
Date: Wed Aug 17 15:03:21 2011
New Revision: 1158759

URL: http://svn.apache.org/viewvc?rev=1158759&view=rev
Log:
o Moved the 'available' field to the AbstractIndexCursor class
o Created a setAvailable() method
o Modified all the classes inheriting from the AbstractIndexCursor to use their parent's available field

Modified:
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/EmptyIndexCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java Wed Aug 17 15:03:21 2011
@@ -34,6 +34,28 @@ import org.apache.directory.shared.ldap.
  */
 public abstract class AbstractIndexCursor<K, E, ID> extends AbstractCursor<IndexEntry<K, E, ID>> implements IndexCursor<K, E, ID>
 {
+    /** Tells if there are some element available in the cursor */
+    private boolean available = false;
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean available()
+    {
+        return available;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected boolean setAvailable( boolean available )
+    {
+        return this.available = available;
+    }
+
+
     /**
      * {@inheritDoc}
      */

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/EmptyIndexCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/EmptyIndexCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/EmptyIndexCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/EmptyIndexCursor.java Wed Aug 17 15:03:21 2011
@@ -30,12 +30,6 @@ import org.apache.directory.shared.ldap.
  */
 public class EmptyIndexCursor<K, E, ID> extends AbstractIndexCursor<K, E, ID>
 {
-    public boolean available()
-    {
-        return false;
-    }
-
-
     public void before( IndexEntry<K, E, ID> element ) throws Exception
     {
         checkNotClosed( "before()" );

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java Wed Aug 17 15:03:21 2011
@@ -45,7 +45,6 @@ public class AndCursor<V, ID> extends Ab
     private static final String UNSUPPORTED_MSG = I18n.err( I18n.ERR_707 );
     private final IndexCursor<V, Entry, ID> wrapped;
     private final List<Evaluator<? extends ExprNode, Entry, ID>> evaluators;
-    private boolean available = false;
 
 
     public AndCursor( IndexCursor<V, Entry, ID> wrapped,
@@ -56,12 +55,6 @@ public class AndCursor<V, ID> extends Ab
     }
 
 
-    public boolean available()
-    {
-        return available;
-    }
-
-
     public void beforeValue( ID id, V value )
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
@@ -90,7 +83,7 @@ public class AndCursor<V, ID> extends Ab
     {
         checkNotClosed( "beforeFirst()" );
         wrapped.beforeFirst();
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -98,7 +91,7 @@ public class AndCursor<V, ID> extends Ab
     {
         checkNotClosed( "afterLast()" );
         wrapped.afterLast();
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -123,13 +116,14 @@ public class AndCursor<V, ID> extends Ab
             checkNotClosed( "previous()" );
 
             IndexEntry<?, Entry, ID> candidate = wrapped.get();
+            
             if ( matches( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
@@ -142,18 +136,19 @@ public class AndCursor<V, ID> extends Ab
             
             if ( matches( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false);
     }
 
 
     public IndexEntry<V, Entry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
-        if ( available )
+        
+        if ( available() )
         {
             return wrapped.get();
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java Wed Aug 17 15:03:21 2011
@@ -56,10 +56,6 @@ public class ApproximateCursor<V, ID ext
     /** NDN Cursor on all entries in  (set when no index on user attribute) */
     private final IndexCursor<String, Entry, ID> uuidIdxCursor;
 
-    /** used only when ndnIdxCursor is used (no index on attribute) */
-    private boolean available = false;
-
-
     @SuppressWarnings("unchecked")
     public ApproximateCursor( Store<Entry, ID> db, ApproximateEvaluator<V, ID> approximateEvaluator ) throws Exception
     {
@@ -89,7 +85,7 @@ public class ApproximateCursor<V, ID ext
             return userIdxCursor.available();
         }
 
-        return available;
+        return super.available();
     }
 
 
@@ -160,7 +156,7 @@ public class ApproximateCursor<V, ID ext
         else
         {
             uuidIdxCursor.beforeFirst();
-            available = false;
+            setAvailable( false );
         }
     }
 
@@ -175,7 +171,7 @@ public class ApproximateCursor<V, ID ext
         else
         {
             uuidIdxCursor.afterLast();
-            available = false;
+            setAvailable( false );
         }
     }
 
@@ -205,13 +201,14 @@ public class ApproximateCursor<V, ID ext
         {
             checkNotClosed( "previous()" );
             IndexEntry<?, Entry, ID> candidate = uuidIdxCursor.get();
+            
             if ( approximateEvaluator.evaluate( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
@@ -226,13 +223,14 @@ public class ApproximateCursor<V, ID ext
         {
             checkNotClosed( "next()" );
             IndexEntry<?, Entry, ID> candidate = uuidIdxCursor.get();
+            
             if ( approximateEvaluator.evaluate( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
@@ -245,7 +243,7 @@ public class ApproximateCursor<V, ID ext
             return userIdxCursor.get();
         }
 
-        if ( available )
+        if ( available() )
         {
             return ( IndexEntry<V, Entry, ID> ) uuidIdxCursor.get();
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java Wed Aug 17 15:03:21 2011
@@ -54,9 +54,6 @@ public class EqualityCursor<V, ID extend
     /** NDN Cursor on all entries in  (set when no index on user attribute) */
     private final IndexCursor<String, Entry, ID> uuidIdxCursor;
 
-    /** used only when ndnIdxCursor is used (no index on attribute) */
-    private boolean available = false;
-
 
     @SuppressWarnings("unchecked")
     public EqualityCursor( Store<Entry, ID> db, EqualityEvaluator<V, ID> equalityEvaluator ) throws Exception
@@ -90,7 +87,7 @@ public class EqualityCursor<V, ID extend
             return userIdxCursor.available();
         }
 
-        return available;
+        return super.available();
     }
 
 
@@ -182,7 +179,7 @@ public class EqualityCursor<V, ID extend
             uuidIdxCursor.beforeFirst();
         }
 
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -202,7 +199,7 @@ public class EqualityCursor<V, ID extend
             uuidIdxCursor.afterLast();
         }
 
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -243,13 +240,14 @@ public class EqualityCursor<V, ID extend
         {
             checkNotClosed( "previous()" );
             IndexEntry<?, Entry, ID> candidate = uuidIdxCursor.get();
+            
             if ( equalityEvaluator.evaluate( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
@@ -271,11 +269,11 @@ public class EqualityCursor<V, ID extend
             
             if ( equalityEvaluator.evaluate( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
@@ -292,7 +290,7 @@ public class EqualityCursor<V, ID extend
             return userIdxCursor.get();
         }
 
-        if ( available )
+        if ( available() )
         {
             return ( IndexEntry<V, Entry, ID> ) uuidIdxCursor.get();
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java Wed Aug 17 15:03:21 2011
@@ -61,9 +61,6 @@ public class GreaterEqCursor<V, ID exten
      */
     IndexEntry<String, Entry, ID> ndnCandidate;
 
-    /** used in both modes */
-    private boolean available = false;
-
 
     @SuppressWarnings("unchecked")
     public GreaterEqCursor( Store<Entry, ID> db, GreaterEqEvaluator greaterEqEvaluator ) throws Exception
@@ -85,12 +82,6 @@ public class GreaterEqCursor<V, ID exten
     }
 
 
-    public boolean available()
-    {
-        return available;
-    }
-
-
     @SuppressWarnings("unchecked")
     public void beforeValue( ID id, V value ) throws Exception
     {
@@ -114,7 +105,7 @@ public class GreaterEqCursor<V, ID exten
             }
 
             userIdxCursor.beforeValue( id, value );
-            available = false;
+            setAvailable( false );
         }
         else
         {
@@ -143,7 +134,7 @@ public class GreaterEqCursor<V, ID exten
             if ( comparedValue == 0 )
             {
                 userIdxCursor.afterValue( id, value );
-                available = false;
+                setAvailable( false );
                 return;
             }
             else if ( comparedValue < 0 )
@@ -154,7 +145,7 @@ public class GreaterEqCursor<V, ID exten
 
             // Element is in the valid range as specified by assertion
             userIdxCursor.afterValue( id, value );
-            available = false;
+            setAvailable( false );
         }
         else
         {
@@ -186,7 +177,7 @@ public class GreaterEqCursor<V, ID exten
             }
 
             userIdxCursor.before( element );
-            available = false;
+            setAvailable( false );
         }
         else
         {
@@ -215,18 +206,20 @@ public class GreaterEqCursor<V, ID exten
             if ( comparedValue == 0 )
             {
                 userIdxCursor.after( element );
-                available = false;
+                setAvailable( false );
+                
                 return;
             }
             else if ( comparedValue < 0 )
             {
                 beforeFirst();
+                
                 return;
             }
 
             // Element is in the valid range as specified by assertion
             userIdxCursor.after( element );
-            available = false;
+            setAvailable( false );
         }
         else
         {
@@ -251,7 +244,7 @@ public class GreaterEqCursor<V, ID exten
             ndnCandidate = null;
         }
 
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -268,7 +261,7 @@ public class GreaterEqCursor<V, ID exten
             ndnCandidate = null;
         }
 
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -300,53 +293,57 @@ public class GreaterEqCursor<V, ID exten
             {
                 checkNotClosed( "previous()" );
                 IndexEntry<?, Entry, ID> candidate = userIdxCursor.get();
+                
                 if ( greaterEqEvaluator.getComparator().compare( candidate.getValue(),
                     greaterEqEvaluator.getExpression().getValue().getValue() ) >= 0 )
                 {
-                    return available = true;
+                    return setAvailable( true );
                 }
             }
 
-            return available = false;
+            return setAvailable( false );
         }
 
         while ( ndnIdxCursor.previous() )
         {
             checkNotClosed( "previous()" );
             ndnCandidate = ndnIdxCursor.get();
+            
             if ( greaterEqEvaluator.evaluate( ndnCandidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
     public boolean next() throws Exception
     {
         checkNotClosed( "next()" );
+        
         if ( userIdxCursor != null )
         {
             /*
              * No need to do the same check that is done in previous() since
              * values are increasing with calls to next().
              */
-            return available = userIdxCursor.next();
+            return setAvailable( userIdxCursor.next() );
         }
 
         while ( ndnIdxCursor.next() )
         {
             checkNotClosed( "next()" );
             ndnCandidate = ndnIdxCursor.get();
+            
             if ( greaterEqEvaluator.evaluate( ndnCandidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
@@ -354,9 +351,10 @@ public class GreaterEqCursor<V, ID exten
     public IndexEntry<V, Entry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
+        
         if ( userIdxCursor != null )
         {
-            if ( available )
+            if ( available() )
             {
                 return userIdxCursor.get();
             }
@@ -364,7 +362,7 @@ public class GreaterEqCursor<V, ID exten
             throw new InvalidCursorPositionException( I18n.err( I18n.ERR_708 ) );
         }
 
-        if ( available )
+        if ( available() )
         {
             return ( IndexEntry<V, Entry, ID> ) ndnCandidate;
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java Wed Aug 17 15:03:21 2011
@@ -61,9 +61,6 @@ public class LessEqCursor<V, ID extends 
      */
     IndexEntry<V, Entry, ID> ndnCandidate;
 
-    /** used in both modes */
-    private boolean available = false;
-
 
     @SuppressWarnings("unchecked")
     public LessEqCursor( Store<Entry, ID> db, LessEqEvaluator<V, ID> lessEqEvaluator ) throws Exception
@@ -85,12 +82,6 @@ public class LessEqCursor<V, ID extends 
     }
 
 
-    public boolean available()
-    {
-        return available;
-    }
-
-
     public void beforeValue( ID id, V value ) throws Exception
     {
         checkNotClosed( "beforeValue()" );
@@ -123,12 +114,12 @@ public class LessEqCursor<V, ID extends 
             {
                 last();
                 previous();
-                available = false;
+                setAvailable( false );
                 return;
             }
 
             userIdxCursor.beforeValue( id, value );
-            available = false;
+            setAvailable( false );
         }
         else
         {
@@ -167,12 +158,12 @@ public class LessEqCursor<V, ID extends 
             {
                 last();
                 previous();
-                available = false;
+                setAvailable( false );
                 return;
             }
 
             userIdxCursor.before( element );
-            available = false;
+            setAvailable( false );
         }
         else
         {
@@ -208,7 +199,7 @@ public class LessEqCursor<V, ID extends 
 
             // Element is in the valid range as specified by assertion
             userIdxCursor.afterValue( id, value );
-            available = false;
+            setAvailable( false );
         }
         else
         {
@@ -244,7 +235,7 @@ public class LessEqCursor<V, ID extends 
 
             // Element is in the valid range as specified by assertion
             userIdxCursor.after( element );
-            available = false;
+            setAvailable( false );
         }
         else
         {
@@ -266,7 +257,7 @@ public class LessEqCursor<V, ID extends 
             ndnCandidate = null;
         }
 
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -286,7 +277,7 @@ public class LessEqCursor<V, ID extends 
             ndnCandidate = null;
         }
 
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -315,7 +306,7 @@ public class LessEqCursor<V, ID extends 
              * values are decreasing with calls to previous().  We will
              * always have lesser values.
              */
-            return available = userIdxCursor.previous();
+            return setAvailable( userIdxCursor.previous() );
         }
 
         while ( uuidIdxCursor.previous() )
@@ -324,7 +315,7 @@ public class LessEqCursor<V, ID extends 
             ndnCandidate = uuidIdxCursor.get();
             if ( lessEqEvaluator.evaluate( ndnCandidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
             else
             {
@@ -332,13 +323,14 @@ public class LessEqCursor<V, ID extends 
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
     public boolean next() throws Exception
     {
         checkNotClosed( "next()" );
+        
         if ( userIdxCursor != null )
         {
             /*
@@ -351,23 +343,25 @@ public class LessEqCursor<V, ID extends 
             {
                 checkNotClosed( "next()" );
                 IndexEntry<?, Entry, ID> candidate = userIdxCursor.get();
+                
                 if ( lessEqEvaluator.getComparator().compare( candidate.getValue(),
                     lessEqEvaluator.getExpression().getValue().getValue() ) <= 0 )
                 {
-                    return available = true;
+                    return setAvailable( true );
                 }
             }
 
-            return available = false;
+            return setAvailable( false );
         }
 
         while ( uuidIdxCursor.next() )
         {
             checkNotClosed( "next()" );
             ndnCandidate = uuidIdxCursor.get();
+            
             if ( lessEqEvaluator.evaluate( ndnCandidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
             else
             {
@@ -375,16 +369,17 @@ public class LessEqCursor<V, ID extends 
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
     public IndexEntry<V, Entry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
+        
         if ( userIdxCursor != null )
         {
-            if ( available )
+            if ( available() )
             {
                 return userIdxCursor.get();
             }
@@ -392,7 +387,7 @@ public class LessEqCursor<V, ID extends 
             throw new InvalidCursorPositionException( I18n.err( I18n.ERR_708 ) );
         }
 
-        if ( available )
+        if ( available() )
         {
             return ndnCandidate;
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java Wed Aug 17 15:03:21 2011
@@ -41,7 +41,6 @@ public class NotCursor<V, ID extends Com
     private static final String UNSUPPORTED_MSG = I18n.err( I18n.ERR_718 );
     private final IndexCursor<V, Entry, ID> uuidCursor;
     private final Evaluator<? extends ExprNode, Entry, ID> childEvaluator;
-    private boolean available = false;
 
 
     @SuppressWarnings("unchecked")
@@ -53,12 +52,6 @@ public class NotCursor<V, ID extends Com
     }
 
 
-    public boolean available()
-    {
-        return available;
-    }
-
-
     public void beforeValue( ID id, V value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
@@ -87,7 +80,7 @@ public class NotCursor<V, ID extends Com
     {
         checkNotClosed( "beforeFirst()" );
         uuidCursor.beforeFirst();
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -95,13 +88,14 @@ public class NotCursor<V, ID extends Com
     {
         checkNotClosed( "afterLast()" );
         uuidCursor.afterLast();
-        available = false;
+        setAvailable( false );
     }
 
 
     public boolean first() throws Exception
     {
         beforeFirst();
+        
         return next();
     }
 
@@ -109,6 +103,7 @@ public class NotCursor<V, ID extends Com
     public boolean last() throws Exception
     {
         afterLast();
+        
         return previous();
     }
 
@@ -119,13 +114,14 @@ public class NotCursor<V, ID extends Com
         {
             checkNotClosed( "previous()" );
             IndexEntry<?, Entry, ID> candidate = uuidCursor.get();
+            
             if ( !childEvaluator.evaluate( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
@@ -135,20 +131,22 @@ public class NotCursor<V, ID extends Com
         {
             checkNotClosed( "next()" );
             IndexEntry<?, Entry, ID> candidate = uuidCursor.get();
+            
             if ( !childEvaluator.evaluate( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
     public IndexEntry<V, Entry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
-        if ( available )
+        
+        if ( available() )
         {
             return uuidCursor.get();
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java Wed Aug 17 15:03:21 2011
@@ -57,9 +57,6 @@ public class OneLevelScopeCursor<ID exte
     /** Currently active Cursor: we switch between two cursors */
     private Cursor<IndexEntry<ID, Entry, ID>> cursor;
 
-    /** Whether or not this Cursor is positioned so an entry is available */
-    private boolean available = false;
-
 
     /**
      * Creates a Cursor over entries satisfying one level scope criteria.
@@ -87,12 +84,6 @@ public class OneLevelScopeCursor<ID exte
     }
 
 
-    public boolean available()
-    {
-        return available;
-    }
-
-
     public void beforeValue( ID id, ID value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
@@ -122,7 +113,7 @@ public class OneLevelScopeCursor<ID exte
         checkNotClosed( "beforeFirst()" );
         cursor = scopeCursor;
         cursor.beforeFirst();
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -139,7 +130,7 @@ public class OneLevelScopeCursor<ID exte
         }
 
         cursor.afterLast();
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -179,21 +170,21 @@ public class OneLevelScopeCursor<ID exte
                 do
                 {
                     checkNotClosed( "previous()" );
-                    available = cursor.previous();
+                    setAvailable( cursor.previous() );
 
-                    if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                    if ( available() && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
                     {
                         break;
                     }
                 }
-                while ( available );
+                while ( available() );
             }
             else
             {
-                available = cursor.previous();
+                setAvailable( cursor.previous() );
             }
 
-            return available;
+            return available();
         }
 
         /*
@@ -202,8 +193,9 @@ public class OneLevelScopeCursor<ID exte
          * scopeCursor and try a previous call after positioning past it's 
          * last element.
          */
-        available = cursor.previous();
-        if ( !available )
+        setAvailable( cursor.previous() );
+        
+        if ( !available() )
         {
             cursor = scopeCursor;
             cursor.afterLast();
@@ -212,16 +204,16 @@ public class OneLevelScopeCursor<ID exte
             do
             {
                 checkNotClosed( "previous()" );
-                available = cursor.previous();
+                setAvailable( cursor.previous() );
 
-                if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                if ( available() && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
                 {
                     break;
                 }
             }
-            while ( available );
+            while ( available() );
 
-            return available;
+            return available();
         }
 
         return true;
@@ -247,24 +239,24 @@ public class OneLevelScopeCursor<ID exte
             do
             {
                 checkNotClosed( "next()" );
-                available = cursor.next();
+                setAvailable( cursor.next() );
 
-                if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                if ( available() && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
                 {
                     break;
                 }
             }
-            while ( available );
+            while ( available() );
         }
         else
         {
-            available = cursor.next();
+            setAvailable( cursor.next() );
         }
 
         // if we're using dereferencedCursor (2nd) then we return the result
         if ( cursor == dereferencedCursor )
         {
-            return available;
+            return available();
         }
 
         /*
@@ -273,13 +265,13 @@ public class OneLevelScopeCursor<ID exte
          * dereferencedCursor and try a previous call after positioning past
          * it's last element.
          */
-        if ( !available )
+        if ( !available() )
         {
             if ( dereferencedCursor != null )
             {
                 cursor = dereferencedCursor;
                 cursor.beforeFirst();
-                return available = cursor.next();
+                return setAvailable( cursor.next() );
             }
 
             return false;
@@ -292,7 +284,8 @@ public class OneLevelScopeCursor<ID exte
     public IndexEntry<ID, Entry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
-        if ( available )
+        
+        if ( available() )
         {
             return cursor.get();
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java Wed Aug 17 15:03:21 2011
@@ -48,7 +48,6 @@ public class OrCursor<V, ID> extends Abs
     private final List<Evaluator<? extends ExprNode, Entry, ID>> evaluators;
     private final List<Set<ID>> blacklists;
     private int cursorIndex = -1;
-    private boolean available = false;
 
 
     // TODO - do same evaluator fail fast optimization that we do in AndCursor
@@ -72,12 +71,6 @@ public class OrCursor<V, ID> extends Abs
     }
 
 
-    public boolean available()
-    {
-        return available;
-    }
-
-
     public void before( IndexEntry<V, Entry, ID> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
@@ -107,7 +100,7 @@ public class OrCursor<V, ID> extends Abs
         checkNotClosed( "beforeFirst()" );
         cursorIndex = 0;
         cursors.get( cursorIndex ).beforeFirst();
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -116,21 +109,23 @@ public class OrCursor<V, ID> extends Abs
         checkNotClosed( "afterLast()" );
         cursorIndex = cursors.size() - 1;
         cursors.get( cursorIndex ).afterLast();
-        available = false;
+        setAvailable( false );
     }
 
 
     public boolean first() throws Exception
     {
         beforeFirst();
-        return available = next();
+        
+        return setAvailable( next() );
     }
 
 
     public boolean last() throws Exception
     {
         afterLast();
-        return available = previous();
+        
+        return setAvailable( previous() );
     }
 
 
@@ -173,7 +168,8 @@ public class OrCursor<V, ID> extends Abs
             if ( !isBlackListed( candidate.getId() ) )
             {
                 blackListIfDuplicate( candidate );
-                return available = true;
+                
+                return setAvailable( true );
             }
         }
 
@@ -190,12 +186,13 @@ public class OrCursor<V, ID> extends Abs
                 if ( !isBlackListed( candidate.getId() ) )
                 {
                     blackListIfDuplicate( candidate );
-                    return available = true;
+                    
+                    return setAvailable( true );
                 }
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
@@ -208,7 +205,8 @@ public class OrCursor<V, ID> extends Abs
             if ( !isBlackListed( candidate.getId() ) )
             {
                 blackListIfDuplicate( candidate );
-                return available = true;
+                
+                return setAvailable( true );
             }
         }
 
@@ -225,19 +223,21 @@ public class OrCursor<V, ID> extends Abs
                 if ( !isBlackListed( candidate.getId() ) )
                 {
                     blackListIfDuplicate( candidate );
-                    return available = true;
+                    
+                    return setAvailable( true );
                 }
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
     public IndexEntry<V, Entry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
-        if ( available )
+        
+        if ( available() )
         {
             return cursors.get( cursorIndex ).get();
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java Wed Aug 17 15:03:21 2011
@@ -41,7 +41,6 @@ public class PresenceCursor<ID extends C
     private final IndexCursor<String, Entry, ID> uuidCursor;
     private final IndexCursor<String, Entry, ID> presenceCursor;
     private final PresenceEvaluator<ID> presenceEvaluator;
-    private boolean available = false;
 
 
     public PresenceCursor( Store<Entry, ID> store, PresenceEvaluator<ID> presenceEvaluator ) throws Exception
@@ -72,7 +71,7 @@ public class PresenceCursor<ID extends C
             return presenceCursor.available();
         }
 
-        return available;
+        return super.available();
     }
 
 
@@ -83,6 +82,7 @@ public class PresenceCursor<ID extends C
         if ( presenceCursor != null )
         {
             presenceCursor.beforeValue( id, value );
+            
             return;
         }
 
@@ -93,9 +93,11 @@ public class PresenceCursor<ID extends C
     public void before( IndexEntry<String, Entry, ID> element ) throws Exception
     {
         checkNotClosed( "before()" );
+        
         if ( presenceCursor != null )
         {
             presenceCursor.before( element );
+            
             return;
         }
 
@@ -106,9 +108,11 @@ public class PresenceCursor<ID extends C
     public void afterValue( ID id, String value ) throws Exception
     {
         checkNotClosed( "afterValue()" );
+        
         if ( presenceCursor != null )
         {
             presenceCursor.afterValue( id, value );
+            
             return;
         }
 
@@ -119,9 +123,11 @@ public class PresenceCursor<ID extends C
     public void after( IndexEntry<String, Entry, ID> element ) throws Exception
     {
         checkNotClosed( "after()" );
+        
         if ( presenceCursor != null )
         {
             presenceCursor.after( element );
+            
             return;
         }
 
@@ -132,20 +138,23 @@ public class PresenceCursor<ID extends C
     public void beforeFirst() throws Exception
     {
         checkNotClosed( "beforeFirst()" );
+        
         if ( presenceCursor != null )
         {
             presenceCursor.beforeFirst();
+            
             return;
         }
 
         uuidCursor.beforeFirst();
-        available = false;
+        setAvailable( false );
     }
 
 
     public void afterLast() throws Exception
     {
         checkNotClosed( "afterLast()" );
+        
         if ( presenceCursor != null )
         {
             presenceCursor.afterLast();
@@ -153,7 +162,7 @@ public class PresenceCursor<ID extends C
         }
 
         uuidCursor.afterLast();
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -173,12 +182,14 @@ public class PresenceCursor<ID extends C
     public boolean last() throws Exception
     {
         checkNotClosed( "last()" );
+        
         if ( presenceCursor != null )
         {
             return presenceCursor.last();
         }
 
         afterLast();
+        
         return previous();
     }
 
@@ -186,6 +197,7 @@ public class PresenceCursor<ID extends C
     public boolean previous() throws Exception
     {
         checkNotClosed( "previous()" );
+        
         if ( presenceCursor != null )
         {
             return presenceCursor.previous();
@@ -195,13 +207,14 @@ public class PresenceCursor<ID extends C
         {
             checkNotClosed( "previous()" );
             IndexEntry<?, Entry, ID> candidate = uuidCursor.get();
+            
             if ( presenceEvaluator.evaluate( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
@@ -217,19 +230,21 @@ public class PresenceCursor<ID extends C
         {
             checkNotClosed( "next()" );
             IndexEntry<?, Entry, ID> candidate = uuidCursor.get();
+            
             if ( presenceEvaluator.evaluate( candidate ) )
             {
-                return available = true;
+                return setAvailable( true );
             }
         }
 
-        return available = false;
+        return setAvailable( false );
     }
 
 
     public IndexEntry<String, Entry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
+        
         if ( presenceCursor != null )
         {
             if ( presenceCursor.available() )
@@ -240,7 +255,7 @@ public class PresenceCursor<ID extends C
             throw new InvalidCursorPositionException( I18n.err( I18n.ERR_708 ) );
         }
 
-        if ( available )
+        if ( available() )
         {
             /*
              * The value of NDN indices is the normalized dn and we want the
@@ -249,6 +264,7 @@ public class PresenceCursor<ID extends C
              */
             IndexEntry<String, Entry, ID> indexEntry = uuidCursor.get();
             indexEntry.setValue( presenceEvaluator.getAttributeType().getOid() );
+            
             return indexEntry;
         }
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java Wed Aug 17 15:03:21 2011
@@ -43,7 +43,6 @@ public class SubstringCursor<ID extends 
     private final IndexCursor<String, Entry, ID> wrapped;
     private final SubstringEvaluator<ID> evaluator;
     private final ForwardIndexEntry<String, Entry, ID> indexEntry = new ForwardIndexEntry<String, Entry, ID>();
-    private boolean available = false;
 
 
     @SuppressWarnings("unchecked")
@@ -76,12 +75,6 @@ public class SubstringCursor<ID extends 
     }
 
 
-    public boolean available()
-    {
-        return available;
-    }
-
-
     public void beforeValue( ID id, String value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
@@ -126,7 +119,7 @@ public class SubstringCursor<ID extends 
 
     private void clear()
     {
-        available = false;
+        setAvailable( false );
         indexEntry.setObject( null );
         indexEntry.setId( null );
         indexEntry.setValue( null );
@@ -180,7 +173,7 @@ public class SubstringCursor<ID extends 
             IndexEntry<String, Entry, ID> entry = wrapped.get();
             if ( evaluateCandidate( entry ) )
             {
-                available = true;
+                setAvailable( true );
                 this.indexEntry.setId( entry.getId() );
                 this.indexEntry.setValue( entry.getValue() );
                 this.indexEntry.setObject( entry.getObject() );
@@ -201,7 +194,7 @@ public class SubstringCursor<ID extends 
             IndexEntry<String, Entry, ID> entry = wrapped.get();
             if ( evaluateCandidate( entry ) )
             {
-                available = true;
+                setAvailable( true );
                 this.indexEntry.setId( entry.getId() );
                 this.indexEntry.setValue( entry.getValue() );
                 this.indexEntry.setObject( entry.getObject() );
@@ -217,7 +210,8 @@ public class SubstringCursor<ID extends 
     public IndexEntry<String, Entry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
-        if ( available )
+        
+        if ( available() )
         {
             return indexEntry;
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java?rev=1158759&r1=1158758&r2=1158759&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java Wed Aug 17 15:03:21 2011
@@ -55,9 +55,6 @@ public class SubtreeScopeCursor<ID exten
     /** Currently active Cursor: we switch between two cursors */
     private IndexCursor<ID, Entry, ID> cursor;
 
-    /** Whether or not this Cursor is positioned so an entry is available */
-    private boolean available = false;
-
     private ID contextEntryId;
 
 
@@ -120,12 +117,6 @@ public class SubtreeScopeCursor<ID exten
     }
 
 
-    public boolean available()
-    {
-        return available;
-    }
-
-
     public void beforeValue( ID id, ID value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
@@ -155,7 +146,7 @@ public class SubtreeScopeCursor<ID exten
         checkNotClosed( "beforeFirst()" );
         cursor = scopeCursor;
         cursor.beforeFirst();
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -172,7 +163,7 @@ public class SubtreeScopeCursor<ID exten
         }
 
         cursor.afterLast();
-        available = false;
+        setAvailable( false );
     }
 
 
@@ -212,20 +203,21 @@ public class SubtreeScopeCursor<ID exten
                 do
                 {
                     checkNotClosed( "previous()" );
-                    available = cursor.previous();
-                    if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                    setAvailable( cursor.previous() );
+                    
+                    if ( available() && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
                     {
                         break;
                     }
                 }
-                while ( available );
+                while ( available() );
             }
             else
             {
-                available = cursor.previous();
+                setAvailable( cursor.previous() );
             }
 
-            return available;
+            return available();
         }
 
         /*
@@ -234,8 +226,9 @@ public class SubtreeScopeCursor<ID exten
          * scopeCursor and try a previous call after positioning past it's
          * last element.
          */
-        available = cursor.previous();
-        if ( !available )
+        setAvailable( cursor.previous() );
+        
+        if ( !available() )
         {
             cursor = scopeCursor;
             cursor.afterLast();
@@ -244,16 +237,16 @@ public class SubtreeScopeCursor<ID exten
             do
             {
                 checkNotClosed( "previous()" );
-                available = cursor.previous();
+                setAvailable( cursor.previous() );
 
-                if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                if ( available() && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
                 {
                     break;
                 }
             }
-            while ( available );
+            while ( available() );
 
-            return available;
+            return available();
         }
 
         return true;
@@ -279,24 +272,24 @@ public class SubtreeScopeCursor<ID exten
             do
             {
                 checkNotClosed( "next()" );
-                available = cursor.next();
+                setAvailable( cursor.next() );
 
-                if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                if ( available() && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
                 {
                     break;
                 }
             }
-            while ( available );
+            while ( available() );
         }
         else
         {
-            available = cursor.next();
+            setAvailable( cursor.next() );
         }
 
         // if we're using dereferencedCursor (2nd) then we return the result
         if ( cursor == dereferencedCursor )
         {
-            return available;
+            return available();
         }
 
         /*
@@ -305,13 +298,14 @@ public class SubtreeScopeCursor<ID exten
          * dereferencedCursor and try a previous call after positioning past
          * it's last element.
          */
-        if ( !available )
+        if ( !available() )
         {
             if ( dereferencedCursor != null )
             {
                 cursor = dereferencedCursor;
                 cursor.beforeFirst();
-                return available = cursor.next();
+                
+                return setAvailable( cursor.next() );
             }
 
             return false;
@@ -324,7 +318,8 @@ public class SubtreeScopeCursor<ID exten
     public IndexEntry<ID, Entry, ID> get() throws Exception
     {
         checkNotClosed( "get()" );
-        if ( available )
+        
+        if ( available() )
         {
             return cursor.get();
         }



Mime
View raw message