Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2F70C7A8E for ; Wed, 17 Aug 2011 15:54:25 +0000 (UTC) Received: (qmail 2198 invoked by uid 500); 17 Aug 2011 15:54:25 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 2138 invoked by uid 500); 17 Aug 2011 15:54:24 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 2129 invoked by uid 99); 17 Aug 2011 15:54:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 15:54:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 15:54:18 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 801A4238897D for ; Wed, 17 Aug 2011 15:53:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1158786 - in /directory/apacheds/trunk/xdbm-partition/src: main/java/org/apache/directory/server/xdbm/ main/java/org/apache/directory/server/xdbm/search/impl/ test/java/org/apache/directory/server/xdbm/ Date: Wed, 17 Aug 2011 15:53:55 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110817155356.801A4238897D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Wed Aug 17 15:53:54 2011 New Revision: 1158786 URL: http://svn.apache.org/viewvc?rev=1158786&view=rev Log: o moved the after() method to the AbstractIndexCursor class o created a getUnsupportedMessage() method 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/SingletonIndexCursor.java directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.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/DefaultSearchEngine.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 directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.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=1158786&r1=1158785&r2=1158786&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:53:54 2011 @@ -32,11 +32,13 @@ import org.apache.directory.shared.ldap. * * @author Apache Directory Project */ -public abstract class AbstractIndexCursor extends AbstractCursor> implements IndexCursor +public abstract class AbstractIndexCursor extends AbstractCursor> implements IndexCursor { /** Tells if there are some element available in the cursor */ private boolean available = false; + /** The message used for unsupported operations */ + protected static final String UNSUPPORTED_MSG = "Unsupported operation"; /** * {@inheritDoc} @@ -45,6 +47,23 @@ public abstract class AbstractIndexCurso { return available; } + + + /** + * Gets the message to return for operations that are not supported + * + * @return The Unsupported message + */ + protected abstract String getUnsupportedMessage(); + + + /** + * {@inheritDoc} + */ + public void after( IndexEntry element ) throws Exception + { + throw new UnsupportedOperationException( getUnsupportedMessage() ); + } /** @@ -59,9 +78,9 @@ public abstract class AbstractIndexCurso /** * {@inheritDoc} */ - public Iterator> iterator() + public Iterator> iterator() { - return new CursorIterator>( this ); + return new CursorIterator>( this ); } 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=1158786&r1=1158785&r2=1158786&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:53:54 2011 @@ -36,6 +36,18 @@ public class EmptyIndexCursor } + /** + * {@inheritDoc} + */ + protected String getUnsupportedMessage() + { + return UNSUPPORTED_MSG; + } + + + /** + * {@inheritDoc} + */ public void after( IndexEntry element ) throws Exception { checkNotClosed( "after()" ); Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/SingletonIndexCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/SingletonIndexCursor.java?rev=1158786&r1=1158785&r2=1158786&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/SingletonIndexCursor.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/SingletonIndexCursor.java Wed Aug 17 15:53:54 2011 @@ -21,6 +21,7 @@ package org.apache.directory.server.xdbm import org.apache.directory.server.i18n.I18n; import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException; +import org.apache.directory.shared.ldap.model.entry.Entry; /** @@ -28,45 +29,48 @@ import org.apache.directory.shared.ldap. * * @author Apache Directory Project */ -public class SingletonIndexCursor extends AbstractIndexCursor +public class SingletonIndexCursor extends AbstractIndexCursor { private boolean beforeFirst = true; private boolean afterLast; private boolean onSingleton; - private final IndexEntry singleton; + private final IndexEntry singleton; - public SingletonIndexCursor( IndexEntry singleton ) + public SingletonIndexCursor( IndexEntry singleton ) { this.singleton = singleton; } - public boolean available() + /** + * {@inheritDoc} + */ + protected String getUnsupportedMessage() { - return onSingleton; + return UNSUPPORTED_MSG; } - - public void before( IndexEntry element ) throws Exception + + public boolean available() { - throw new UnsupportedOperationException(); + return onSingleton; } - public void beforeValue( ID id, K value ) throws Exception + public void before( IndexEntry element ) throws Exception { throw new UnsupportedOperationException(); } - public void afterValue( ID id, K value ) throws Exception + public void beforeValue( ID id, V value ) throws Exception { throw new UnsupportedOperationException(); } - public void after( IndexEntry element ) throws Exception + public void afterValue( ID id, V value ) throws Exception { throw new UnsupportedOperationException(); } @@ -186,7 +190,7 @@ public class SingletonIndexCursor get() throws Exception + public IndexEntry get() throws Exception { checkNotClosed( "()" ); if ( onSingleton ) Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java?rev=1158786&r1=1158785&r2=1158786&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java Wed Aug 17 15:53:54 2011 @@ -39,6 +39,15 @@ public class AllEntriesCursor wrapped; + /** + * {@inheritDoc} + */ + protected String getUnsupportedMessage() + { + return UNSUPPORTED_MSG; + } + + public AllEntriesCursor( Store db ) throws Exception { // Get a reverse cursor because we want to sort by ID @@ -66,8 +75,8 @@ public class AllEntriesCursor indexEntry ) throws Exception { 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=1158786&r1=1158785&r2=1158786&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:53:54 2011 @@ -55,6 +55,15 @@ public class AndCursor extends Ab } + /** + * {@inheritDoc} + */ + protected String getUnsupportedMessage() + { + return UNSUPPORTED_MSG; + } + + public void beforeValue( ID id, V value ) { throw new UnsupportedOperationException( UNSUPPORTED_MSG ); @@ -73,6 +82,9 @@ public class AndCursor extends Ab } + /** + * {@inheritDoc} + */ public void after( IndexEntry element ) throws Exception { throw new UnsupportedOperationException( UNSUPPORTED_MSG ); 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=1158786&r1=1158785&r2=1158786&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:53:54 2011 @@ -78,6 +78,15 @@ public class ApproximateCursor element ) throws Exception { checkNotClosed( "after()" ); + if ( userIdxCursor != null ) { userIdxCursor.after( element ); } else { - throw new UnsupportedOperationException( UNSUPPORTED_MSG ); + super.after( element ); } } Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=1158786&r1=1158785&r2=1158786&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java Wed Aug 17 15:53:54 2011 @@ -164,7 +164,7 @@ public class DefaultSearchEngine( indexEntry ); + return new SingletonIndexCursor( indexEntry ); } else { 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=1158786&r1=1158785&r2=1158786&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:53:54 2011 @@ -80,6 +80,15 @@ public class EqualityCursor element ) throws Exception { checkNotClosed( "after()" ); + if ( userIdxCursor != null ) { int comparedValue = greaterEqEvaluator.getComparator().compare( element.getValue(), @@ -223,7 +235,7 @@ public class GreaterEqCursor element ) throws Exception { checkNotClosed( "after()" ); + if ( userIdxCursor != null ) { int comparedValue = lessEqEvaluator.getComparator().compare( element.getValue(), @@ -239,7 +252,7 @@ public class LessEqCursor element ) throws Exception + + public void beforeValue( ID id, V value ) throws Exception { throw new UnsupportedOperationException( UNSUPPORTED_MSG ); } - public void after( IndexEntry element ) throws Exception + public void before( IndexEntry element ) throws Exception { throw new UnsupportedOperationException( UNSUPPORTED_MSG ); } 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=1158786&r1=1158785&r2=1158786&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:53:54 2011 @@ -84,25 +84,28 @@ public class OneLevelScopeCursor element ) throws Exception + public void afterValue( ID id, ID value ) throws Exception { throw new UnsupportedOperationException( UNSUPPORTED_MSG ); } - public void after( IndexEntry element ) throws Exception + public void before( IndexEntry element ) throws Exception { throw new UnsupportedOperationException( UNSUPPORTED_MSG ); } 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=1158786&r1=1158785&r2=1158786&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:53:54 2011 @@ -71,13 +71,16 @@ public class OrCursor extends Abs } - public void before( IndexEntry element ) throws Exception + /** + * {@inheritDoc} + */ + protected String getUnsupportedMessage() { - throw new UnsupportedOperationException( UNSUPPORTED_MSG ); + return UNSUPPORTED_MSG; } - - public void after( IndexEntry element ) throws Exception + + public void before( IndexEntry element ) throws Exception { throw new UnsupportedOperationException( UNSUPPORTED_MSG ); } 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=1158786&r1=1158785&r2=1158786&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:53:54 2011 @@ -64,6 +64,15 @@ public class PresenceCursor element ) throws Exception { checkNotClosed( "after()" ); @@ -131,7 +143,7 @@ public class PresenceCursor element ) throws Exception + public void afterValue( ID id, String value ) throws Exception { throw new UnsupportedOperationException( UNSUPPORTED_MSG ); } - public void after( IndexEntry element ) throws Exception + public void before( IndexEntry element ) throws Exception { throw new UnsupportedOperationException( UNSUPPORTED_MSG ); } 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=1158786&r1=1158785&r2=1158786&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:53:54 2011 @@ -91,8 +91,16 @@ public class SubtreeScopeCursor element ) throws Exception - { - throw new UnsupportedOperationException( UNSUPPORTED_MSG ); - } - - public void beforeFirst() throws Exception { checkNotClosed( "beforeFirst()" ); Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java?rev=1158786&r1=1158785&r2=1158786&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java Wed Aug 17 15:53:54 2011 @@ -40,7 +40,7 @@ public class SingletonIndexCursorTest { private ForwardIndexEntry indexEntry; - private SingletonIndexCursor indexCursor; + private SingletonIndexCursor indexCursor; @Before @@ -50,14 +50,14 @@ public class SingletonIndexCursorTest indexEntry.setId( 1L ); indexEntry.setObject( new DefaultEntry() ); indexEntry.setValue( "test" ); - indexCursor = new SingletonIndexCursor( indexEntry ); + indexCursor = new SingletonIndexCursor( indexEntry ); } @Test public void testConstructor() { - new SingletonIndexCursor( indexEntry ); + new SingletonIndexCursor( indexEntry ); }