directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r992958 - in /directory/shared/trunk: cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ i18n/src/main/java/org/apache/directory/shared/i18n/ i18n/src/main/resources/org/apache/directory/shared/i18n/
Date Mon, 06 Sep 2010 07:26:48 GMT
Author: elecharny
Date: Mon Sep  6 07:26:48 2010
New Revision: 992958

URL: http://svn.apache.org/viewvc?rev=992958&view=rev
Log:
cursor files reviewed. Some fixes for error code

Modified:
    directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java
    directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/SingletonCursor.java
    directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
    directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties

Modified: directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java?rev=992958&r1=992957&r2=992958&view=diff
==============================================================================
--- directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java
(original)
+++ directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/ListCursor.java
Mon Sep  6 07:26:48 2010
@@ -71,6 +71,7 @@ public class ListCursor<E> extends Abstr
         {
             list = Collections.emptyList();
         }
+
         if ( ( start < 0 ) || ( start > list.size() ) )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_02005_START_INDEX_OUT_OF_RANGE,
start ) );
@@ -229,8 +230,7 @@ public class ListCursor<E> extends Abstr
 
 
     /**
-     * @throws IllegalStateException if the underlying list is not sorted
-     * and/or a comparator is not provided.
+     * {@inheritDoc}
      */
     public void before( E element ) throws Exception
     {
@@ -258,8 +258,7 @@ public class ListCursor<E> extends Abstr
             }
         }
 
-        // TODO might want to add some code here to utilize the comparator
-        throw new UnsupportedOperationException( I18n.err( I18n.ERR_02008 ) );
+        throw new UnsupportedOperationException( I18n.err( I18n.ERR_02008_LIST_MAY_BE_SORTED
) );
     }
 
 
@@ -292,8 +291,7 @@ public class ListCursor<E> extends Abstr
             }
         }
 
-        // TODO might want to add some code here to utilize the comparator
-        throw new UnsupportedOperationException( I18n.err( I18n.ERR_02008 ) );
+        throw new UnsupportedOperationException( I18n.err( I18n.ERR_02008_LIST_MAY_BE_SORTED
) );
     }
 
 
@@ -327,6 +325,7 @@ public class ListCursor<E> extends Abstr
         if ( list.size() > 0 )
         {
             index = start;
+
             return true;
         }
 
@@ -344,6 +343,7 @@ public class ListCursor<E> extends Abstr
         if ( list.size() > 0 )
         {
             index = end - 1;
+
             return true;
         }
 
@@ -358,6 +358,7 @@ public class ListCursor<E> extends Abstr
     public boolean isFirst() throws Exception
     {
         checkNotClosed( "isFirst()" );
+
         return list.size() > 0 && index == start;
     }
 
@@ -369,6 +370,7 @@ public class ListCursor<E> extends Abstr
     public boolean isLast() throws Exception
     {
         checkNotClosed( "isLast()" );
+
         return list.size() > 0 && index == end - 1;
     }
 
@@ -412,6 +414,7 @@ public class ListCursor<E> extends Abstr
         if ( index - 1 >= start )
         {
             index--;
+
             return true;
         }
 
@@ -419,6 +422,7 @@ public class ListCursor<E> extends Abstr
         if ( index <= start )
         {
             index = -1;
+
             return false;
         }
 
@@ -439,23 +443,26 @@ public class ListCursor<E> extends Abstr
         checkNotClosed( "next()" );
 
         // if parked at -1 we advance to the start index and return true
-        if ( list.size() > 0 && index == -1 )
+        if ( ( list.size() > 0 ) && ( index == -1 ) )
         {
             index = start;
+
             return true;
         }
 
         // if the index plus one is less than the end then increment and return true
-        if ( list.size() > 0 && index + 1 < end )
+        if ( ( list.size() > 0 ) && ( index + 1 < end ) )
         {
             index++;
+
             return true;
         }
 
         // if the index plus one is equal to the end then increment and return false
-        if ( list.size() > 0 && index + 1 == end )
+        if ( ( list.size() > 0 ) && ( index + 1 == end ) )
         {
             index++;
+
             return false;
         }
 
@@ -475,7 +482,7 @@ public class ListCursor<E> extends Abstr
     {
         checkNotClosed( "get()" );
 
-        if ( index < start || index >= end )
+        if ( ( index < start ) || ( index >= end ) )
         {
             throw new IOException( I18n.err( I18n.ERR_02009_CURSOR_NOT_POSITIONED ) );
         }

Modified: directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/SingletonCursor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/SingletonCursor.java?rev=992958&r1=992957&r2=992958&view=diff
==============================================================================
--- directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/SingletonCursor.java
(original)
+++ directory/shared/trunk/cursor/src/main/java/org/apache/directory/shared/ldap/cursor/SingletonCursor.java
Mon Sep  6 07:26:48 2010
@@ -32,9 +32,13 @@ import org.apache.directory.shared.i18n.
  */
 public class SingletonCursor<E> extends AbstractCursor<E>
 {
-    /** A flag set to true to a*/
+    /** A flag to tell if the cursor is set before the first element */
     private boolean beforeFirst = true;
+
+    /** A flag to tell if the cursor is set after the last element */
     private boolean afterLast;
+
+    /** A flag to tell if the cursor is on the element */
     private boolean onSingleton;
 
     /** The comparator used for this cursor. */
@@ -57,7 +61,7 @@ public class SingletonCursor<E> extends 
 
     /**
      * Creates a new instance of SingletonCursor, with its associated
-     * conmparator
+     * comparator
      *
      * @param singleton The unique element to store into this cursor
      * @param comparator The associated comparator
@@ -133,7 +137,7 @@ public class SingletonCursor<E> extends 
      */
     public void beforeFirst() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "beforeFirst" );
         beforeFirst = true;
         afterLast = false;
         onSingleton = false;
@@ -145,7 +149,7 @@ public class SingletonCursor<E> extends 
      */
     public void afterLast() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "afterLast" );
         beforeFirst = false;
         afterLast = true;
         onSingleton = false;
@@ -157,10 +161,11 @@ public class SingletonCursor<E> extends 
      */
     public boolean first() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "first" );
         beforeFirst = false;
         onSingleton = true;
         afterLast = false;
+
         return true;
     }
 
@@ -170,10 +175,11 @@ public class SingletonCursor<E> extends 
      */
     public boolean last() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "last" );
         beforeFirst = false;
         onSingleton = true;
         afterLast = false;
+
         return true;
     }
 
@@ -184,7 +190,8 @@ public class SingletonCursor<E> extends 
     @Override
     public boolean isFirst() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "isFirst" );
+
         return onSingleton;
     }
 
@@ -195,7 +202,8 @@ public class SingletonCursor<E> extends 
     @Override
     public boolean isLast() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "isLast" );
+
         return onSingleton;
     }
 
@@ -206,7 +214,8 @@ public class SingletonCursor<E> extends 
     @Override
     public boolean isAfterLast() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "isAfterLast" );
+
         return afterLast;
     }
 
@@ -217,7 +226,8 @@ public class SingletonCursor<E> extends 
     @Override
     public boolean isBeforeFirst() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "isBeforeFirst" );
+
         return beforeFirst;
     }
 
@@ -227,7 +237,7 @@ public class SingletonCursor<E> extends 
      */
     public boolean previous() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "previous" );
 
         if ( beforeFirst )
         {
@@ -239,6 +249,7 @@ public class SingletonCursor<E> extends 
             beforeFirst = false;
             onSingleton = true;
             afterLast = false;
+
             return true;
         }
 
@@ -246,6 +257,7 @@ public class SingletonCursor<E> extends 
         beforeFirst = true;
         onSingleton = false;
         afterLast = false;
+
         return false;
     }
 
@@ -255,13 +267,14 @@ public class SingletonCursor<E> extends 
      */
     public boolean next() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "next" );
 
         if ( beforeFirst )
         {
             beforeFirst = false;
             onSingleton = true;
             afterLast = false;
+
             return true;
         }
 
@@ -274,6 +287,7 @@ public class SingletonCursor<E> extends 
         beforeFirst = false;
         onSingleton = false;
         afterLast = true;
+
         return false;
     }
 
@@ -283,7 +297,7 @@ public class SingletonCursor<E> extends 
      */
     public E get() throws Exception
     {
-        checkNotClosed( "()" );
+        checkNotClosed( "get" );
 
         if ( onSingleton )
         {

Modified: directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java?rev=992958&r1=992957&r2=992958&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java (original)
+++ directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java Mon
Sep  6 07:26:48 2010
@@ -84,7 +84,7 @@ public enum I18n
     ERR_02005_START_INDEX_OUT_OF_RANGE( "ERR_02005_START_INDEX_OUT_OF_RANGE" ),
     ERR_02006_END_INDEX_OUT_OF_RANGE( "ERR_02006_END_INDEX_OUT_OF_RANGE" ),
     ERR_02007_START_INDEX_ABOVE_END_INDEX( "ERR_02007_START_INDEX_ABOVE_END_INDEX" ),
-    ERR_02008( "ERR_02008" ),
+    ERR_02008_LIST_MAY_BE_SORTED( "ERR_02008_LIST_MAY_BE_SORTED" ),
     ERR_02009_CURSOR_NOT_POSITIONED( "ERR_02009_CURSOR_NOT_POSITIONED" ),
     ERR_02010_NO_COMPARATOR_CANT_MOVE_BEFORE( "ERR_02010_NO_COMPARATOR_CANT_MOVE_BEFORE"
),
     ERR_02011_NO_COMPARATOR_CANT_MOVE_AFTER( "ERR_02011_NO_COMPARATOR_CANT_MOVE_AFTER" ),

Modified: directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties?rev=992958&r1=992957&r2=992958&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
(original)
+++ directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
Mon Sep  6 07:26:48 2010
@@ -72,7 +72,7 @@ ERR_02004_EMPTY_CURSOR=This cursor is em
 ERR_02005_START_INDEX_OUT_OF_RANGE=start index ''{0}'' out of range
 ERR_02006_END_INDEX_OUT_OF_RANGE=end index ''{0}'' out of range
 ERR_02007_START_INDEX_ABOVE_END_INDEX=start index ''{0}'' greater than or equal to end index
''{1}'' just does not make sense
-ERR_02008=don't know if list is sorted and checking that is not worth it
+ERR_02008_LIST_MAY_BE_SORTED=don't know if list is sorted and checking that is not worth
it
 ERR_02009_CURSOR_NOT_POSITIONED=Cursor not positioned at an element
 ERR_02010_NO_COMPARATOR_CANT_MOVE_BEFORE=Without a comparator I cannot advance to just before
the specified element.
 ERR_02011_NO_COMPARATOR_CANT_MOVE_AFTER=Without a comparator I cannot advance to just after
the specified element.



Mime
View raw message