directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r604725 - in /directory/sandbox/akarasulu/bigbang/apacheds: core-cursor/src/main/java/org/apache/directory/server/core/cursor/ jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/
Date Sun, 16 Dec 2007 22:30:17 GMT
Author: akarasulu
Date: Sun Dec 16 14:30:17 2007
New Revision: 604725

URL: http://svn.apache.org/viewvc?rev=604725&view=rev
Log:
messing around with using a pattern on complex cursors

Added:
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorStateEnum.java
Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/KeyCursor.java

Added: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java?rev=604725&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java
(added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java
Sun Dec 16 14:30:17 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.cursor;
+
+
+import java.io.IOException;
+
+
+/**
+ * A Cursor's state: cursor states leverage the State Pattern to isolate state
+ * specific transition logic with certain operations.  Not every Cursor is
+ * that complex so the implementor should decide whether or not using the
+ * State Pattern is over kill on a per Cursor implementation basis.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface CursorState<E>
+{
+    void before( E element ) throws IOException;
+
+    void after( E element ) throws IOException;
+
+    void beforeFirst() throws IOException;
+
+    void afterLast() throws IOException;
+
+    boolean relative( int offset ) throws IOException;
+
+    boolean first() throws IOException;
+
+    boolean last() throws IOException;
+
+    boolean previous() throws IOException;
+
+    boolean next() throws IOException;
+}

Added: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorStateEnum.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorStateEnum.java?rev=604725&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorStateEnum.java
(added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorStateEnum.java
Sun Dec 16 14:30:17 2007
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.cursor;
+
+
+/**
+ * An enumeration to represent the various states of a Cursor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum CursorStateEnum
+{
+    /** the Cursor is positioned just before the first element */
+    BEFORE_FIRST,
+    /** the Cursor is positioned just after the last element */
+    AFTER_LAST,
+    /** the Cursor is positioned just before an element but not on any element */
+    BEFORE_ELEMENT,
+    /** the Cursor is positioned just after an element but not on any element */
+    AFTER_ELEMENT,
+    /** the Cursor is positioned on the first element */
+    ON_FIRST,
+    /** the Cursor is positioned on the last element */
+    ON_LAST,
+    /** the Cursor is positioned on an element */
+    ON_INTERIOR_ELEMENT,
+    /** the Cursor is closed and not operations can be performed on it */
+    CLOSED
+}

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/KeyCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/KeyCursor.java?rev=604725&r1=604724&r2=604725&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/KeyCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/KeyCursor.java
Sun Dec 16 14:30:17 2007
@@ -47,7 +47,6 @@
 
     private BTree btree;
     private TupleBrowser browser;
-    private int pos = BEFORE_FIRST;
     private int size;  // cache the size to prevent needless lookups
     private boolean afterLast;
     private boolean beforeFirst;
@@ -70,7 +69,6 @@
     public void before( E element ) throws IOException
     {
         browser = btree.browse( element );
-        pos = UNDEFINED;
         success = false;
         afterLast = false;
         beforeFirst = false;
@@ -107,7 +105,6 @@
             afterLast = true;
             success = false;
             size = btree.size();
-            pos = size;
             browser = btree.browse( null );
         }
     }



Mime
View raw message