You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/01/24 17:15:29 UTC

svn commit: r1235326 [4/28] - in /directory/apacheds/trunk: jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition...

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyBTreeCursorTest.java Tue Jan 24 16:15:05 2012
@@ -43,7 +43,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-
 /**
  * Document me!
  *
@@ -67,7 +66,7 @@ public class KeyBTreeCursorTest
     public void createCursor() throws Exception
     {
         File tmpDir = null;
-        
+
         if ( System.getProperty( TEST_OUTPUT_PATH, null ) != null )
         {
             tmpDir = new File( System.getProperty( TEST_OUTPUT_PATH ) );
@@ -188,7 +187,7 @@ public class KeyBTreeCursorTest
         assertFalse( cursor.previous() );
         assertTrue( cursor.next() );
         assertEquals( "0", cursor.get() );
-        
+
         bt.remove( "0" );
         bt.remove( "1" );
         bt.remove( "2" );
@@ -272,12 +271,12 @@ public class KeyBTreeCursorTest
         assertEquals( "1", tuple.getKey() );
     }
 
-    
+
     @Test
     public void testMiscelleneous() throws Exception
     {
         // Test available()
-        
+
         assertFalse( cursor.available() );
         cursor.beforeFirst();
         assertFalse( cursor.available() );
@@ -288,7 +287,7 @@ public class KeyBTreeCursorTest
         cursor.last();
         assertTrue( cursor.available() );
     }
-    
+
 
     private void assertInvalidCursor()
     {

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyCursorTest.java Tue Jan 24 16:15:05 2012
@@ -43,7 +43,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-
 /**
  * Document me!
  *
@@ -67,7 +66,7 @@ public class KeyCursorTest
     public void createCursor() throws Exception
     {
         File tmpDir = null;
-        
+
         if ( System.getProperty( TEST_OUTPUT_PATH, null ) != null )
         {
             tmpDir = new File( System.getProperty( TEST_OUTPUT_PATH ) );
@@ -188,7 +187,7 @@ public class KeyCursorTest
         assertFalse( cursor.previous() );
         assertTrue( cursor.next() );
         assertEquals( "0", cursor.get() );
-        
+
         bt.remove( "0" );
         bt.remove( "1" );
         bt.remove( "2" );
@@ -272,12 +271,12 @@ public class KeyCursorTest
         assertEquals( "1", tuple.getKey() );
     }
 
-    
+
     @Test
     public void testMiscelleneous() throws Exception
     {
         // Test available()
-        
+
         assertFalse( cursor.available() );
         cursor.beforeFirst();
         assertFalse( cursor.available() );
@@ -288,7 +287,7 @@ public class KeyCursorTest
         cursor.last();
         assertTrue( cursor.available() );
     }
-    
+
 
     private void assertInvalidCursor()
     {

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleArrayCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleArrayCursorTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleArrayCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleArrayCursorTest.java Tue Jan 24 16:15:05 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
+
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertTrue;
@@ -34,6 +35,7 @@ import org.junit.runner.RunWith;
 import com.mycila.junit.concurrent.Concurrency;
 import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 
+
 /**
  * 
  * Test case for KeyTupleAvlCursor.
@@ -47,43 +49,44 @@ public class KeyTupleArrayCursorTest
 
     ArrayTree<Integer> tree;
     KeyTupleArrayCursor<Integer, Integer> cursor;
-    
+
     private static final Integer KEY = Integer.valueOf( 1 );
-    
+
+
     @Before
     public void createTree()
     {
-        Comparator<Integer> comparator = new Comparator<Integer>() 
+        Comparator<Integer> comparator = new Comparator<Integer>()
         {
 
-          public int compare( Integer i1, Integer i2 )
-          {
-              return i1.compareTo( i2 );
-          }
-        
+            public int compare( Integer i1, Integer i2 )
+            {
+                return i1.compareTo( i2 );
+            }
+
         };
-        
-      tree = new ArrayTree<Integer>( comparator );  
-      
-      cursor = new KeyTupleArrayCursor<Integer, Integer>( tree, KEY );
+
+        tree = new ArrayTree<Integer>( comparator );
+
+        cursor = new KeyTupleArrayCursor<Integer, Integer>( tree, KEY );
     }
-    
-    
-    @Test( expected = InvalidCursorPositionException.class )
+
+
+    @Test(expected = InvalidCursorPositionException.class)
     public void testEmptyCursor() throws Exception
     {
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
-        
+
         assertFalse( cursor.isClosed() );
-        
+
         assertFalse( cursor.first() );
         assertFalse( cursor.last() );
-        
+
         cursor.get(); // should throw InvalidCursorPositionException
     }
-    
-    
+
+
     @Test
     public void testNonEmptyCursor() throws Exception
     {
@@ -94,34 +97,34 @@ public class KeyTupleArrayCursorTest
         tree.insert( 0 );
         tree.insert( 30 );
         tree.insert( 25 );
-        
-        cursor.before( new Tuple<Integer, Integer>( null, 3) );
+
+        cursor.before( new Tuple<Integer, Integer>( null, 3 ) );
         assertTrue( cursor.next() );
         assertEquals( 3, ( int ) cursor.get().getValue() );
-        
+
         cursor.after( new Tuple<Integer, Integer>( null, 34 ) );
         assertFalse( cursor.next() );
 
         cursor.after( new Tuple<Integer, Integer>( null, 13 ) );
         assertTrue( cursor.next() );
         assertEquals( 25, ( int ) cursor.get().getValue() );
-        
+
         cursor.beforeFirst();
         assertFalse( cursor.previous() );
         assertTrue( cursor.next() );
         assertEquals( 0, ( int ) cursor.get().getValue() );
-        
+
         cursor.afterLast();
         assertFalse( cursor.next() );
-        
+
         assertTrue( cursor.first() );
         assertTrue( cursor.available() );
         assertEquals( 0, ( int ) cursor.get().getValue() );
-        
+
         assertTrue( cursor.last() );
         assertTrue( cursor.available() );
         assertEquals( 30, ( int ) cursor.get().getValue() );
-        
+
         assertTrue( cursor.previous() );
         assertEquals( 25, ( int ) cursor.get().getValue() );
 

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleBTreeCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleBTreeCursorTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleBTreeCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleBTreeCursorTest.java Tue Jan 24 16:15:05 2012
@@ -55,12 +55,12 @@ import org.junit.Test;
  */
 public class KeyTupleBTreeCursorTest
 {
-    JdbmTable<String,String> table;
+    JdbmTable<String, String> table;
     Comparator<String> comparator;
     KeyTupleBTreeCursor<String, String> cursor;
     File dbFile;
     RecordManager recman;
-    
+
     private static final String KEY = "1";
     private static final String TEST_OUTPUT_PATH = "test.output.path";
     private static SchemaManager schemaManager;
@@ -88,14 +88,15 @@ public class KeyTupleBTreeCursorTest
 
         if ( !loaded )
         {
-            fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) );
+            fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
     }
-    
+
+
     @Before
     public void createTree() throws Exception
     {
-        comparator = new Comparator<String>() 
+        comparator = new Comparator<String>()
         {
             public int compare( String i1, String i2 )
             {
@@ -104,7 +105,7 @@ public class KeyTupleBTreeCursorTest
         };
 
         File tmpDir = null;
-        
+
         if ( System.getProperty( TEST_OUTPUT_PATH, null ) != null )
         {
             tmpDir = new File( System.getProperty( TEST_OUTPUT_PATH ) );
@@ -112,18 +113,19 @@ public class KeyTupleBTreeCursorTest
 
         dbFile = File.createTempFile( getClass().getSimpleName(), "db", tmpDir );
         recman = new BaseRecordManager( dbFile.getAbsolutePath() );
-        
-        SerializableComparator<String> comparator = new SerializableComparator<String>( SchemaConstants.INTEGER_ORDERING_MATCH_MR_OID );
+
+        SerializableComparator<String> comparator = new SerializableComparator<String>(
+            SchemaConstants.INTEGER_ORDERING_MATCH_MR_OID );
         comparator.setSchemaManager( schemaManager );
 
-        table = new JdbmTable<String,String>( schemaManager, "test", 6, recman,
-                comparator, comparator, new DefaultSerializer(), new DefaultSerializer() );
+        table = new JdbmTable<String, String>( schemaManager, "test", 6, recman,
+            comparator, comparator, new DefaultSerializer(), new DefaultSerializer() );
 
         cursor = new KeyTupleBTreeCursor<String, String>( table.getBTree(), KEY, comparator );
     }
-    
-    
-    @After 
+
+
+    @After
     public void destroyTable() throws Exception
     {
         recman.close();
@@ -136,22 +138,22 @@ public class KeyTupleBTreeCursorTest
 
         dbFile = null;
     }
-    
 
-    @Test( expected = InvalidCursorPositionException.class )
+
+    @Test(expected = InvalidCursorPositionException.class)
     public void testEmptyCursor() throws Exception
     {
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
-        
+
         assertFalse( cursor.isClosed() );
-        
+
         assertFalse( cursor.first() );
         assertFalse( cursor.last() );
-        
+
         cursor.get(); // should throw InvalidCursorPositionException
     }
-    
+
 
     @Test
     public void testNonEmptyCursor() throws Exception
@@ -163,51 +165,52 @@ public class KeyTupleBTreeCursorTest
         table.put( KEY, "0" );
         table.put( KEY, "30" );
         table.put( KEY, "25" );
-       
+
         cursor = new KeyTupleBTreeCursor<String, String>( getDupsContainer(), KEY, comparator );
-   
+
         cursor.before( new Tuple<String, String>( KEY, "3" ) );
         assertTrue( cursor.next() );
         assertEquals( "3", cursor.get().getValue() );
-        
+
         cursor.after( new Tuple<String, String>( KEY, "100" ) );
         assertFalse( cursor.next() );
-        
+
         cursor.beforeFirst();
         cursor.after( new Tuple<String, String>( KEY, "13" ) );
         assertTrue( cursor.next() );
         assertEquals( "25", cursor.get().getValue() );
-        
+
         cursor.beforeFirst();
         assertFalse( cursor.previous() );
         assertTrue( cursor.next() );
         assertEquals( "0", cursor.get().getValue() );
-        
+
         cursor.afterLast();
         assertFalse( cursor.next() );
-        
+
         assertTrue( cursor.first() );
         assertTrue( cursor.available() );
         assertEquals( "0", cursor.get().getValue() );
-        
+
         assertTrue( cursor.last() );
         assertTrue( cursor.available() );
         assertEquals( "30", cursor.get().getValue() );
-        
+
         assertTrue( cursor.previous() );
         assertEquals( "25", cursor.get().getValue() );
-    
+
         assertTrue( cursor.next() );
-        assertEquals( "30", cursor.get().getValue() ); 
-    
+        assertEquals( "30", cursor.get().getValue() );
+
     }
 
+
     private BTree getDupsContainer() throws Exception
     {
         BTree tree = table.getBTree();
-        
+
         DupsContainer<String> values = table.getDupsContainer( ( byte[] ) tree.find( KEY ) );
-        
-        return table.getBTree( values.getBTreeRedirect() );   
+
+        return table.getBTree( values.getBTreeRedirect() );
     }
 }

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java Tue Jan 24 16:15:05 2012
@@ -61,7 +61,7 @@ public class NoDupsCursorTest
     private static final Logger LOG = LoggerFactory.getLogger( NoDupsCursorTest.class.getSimpleName() );
     private static final String TEST_OUTPUT_PATH = "test.output.path";
 
-    Table<String,String> table;
+    Table<String, String> table;
     File dbFile;
     RecordManager recman;
     private static SchemaManager schemaManager;
@@ -89,7 +89,7 @@ public class NoDupsCursorTest
 
         if ( !loaded )
         {
-            fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) );
+            fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
     }
 
@@ -98,7 +98,7 @@ public class NoDupsCursorTest
     public void createTable() throws Exception
     {
         File tmpDir = null;
-        
+
         if ( System.getProperty( TEST_OUTPUT_PATH, null ) != null )
         {
             tmpDir = new File( System.getProperty( TEST_OUTPUT_PATH ) );
@@ -107,10 +107,11 @@ public class NoDupsCursorTest
         dbFile = File.createTempFile( getClass().getSimpleName(), "db", tmpDir );
         recman = new BaseRecordManager( dbFile.getAbsolutePath() );
 
-        SerializableComparator<String> comparator = new SerializableComparator<String>( SchemaConstants.INTEGER_ORDERING_MATCH_MR_OID );
+        SerializableComparator<String> comparator = new SerializableComparator<String>(
+            SchemaConstants.INTEGER_ORDERING_MATCH_MR_OID );
         comparator.setSchemaManager( schemaManager );
 
-        table = new JdbmTable<String,String>( schemaManager, "test", recman, 
+        table = new JdbmTable<String, String>( schemaManager, "test", recman,
             comparator, null, null );
         LOG.debug( "Created new table and populated it with data" );
     }
@@ -131,12 +132,12 @@ public class NoDupsCursorTest
     }
 
 
-    @Test( expected=InvalidCursorPositionException.class )
+    @Test(expected = InvalidCursorPositionException.class)
     public void testEmptyTable() throws Exception
     {
-        Cursor<Tuple<String,String>> cursor = table.cursor();
+        Cursor<Tuple<String, String>> cursor = table.cursor();
         assertNotNull( cursor );
-        
+
         assertFalse( cursor.available() );
         assertFalse( cursor.isClosed() );
 
@@ -146,7 +147,7 @@ public class NoDupsCursorTest
         cursor = table.cursor();
         assertFalse( cursor.next() );
 
-        cursor.after( new Tuple<String,String>( "7", "7" ) );
+        cursor.after( new Tuple<String, String>( "7", "7" ) );
         cursor.get();
     }
 
@@ -155,109 +156,107 @@ public class NoDupsCursorTest
     public void testOnTableWithSingleEntry() throws Exception
     {
         table.put( "1", "1" );
-        Cursor<Tuple<String,String>> cursor = table.cursor();
+        Cursor<Tuple<String, String>> cursor = table.cursor();
         assertTrue( cursor.first() );
-    
-        Tuple<String,String> tuple = cursor.get();
+
+        Tuple<String, String> tuple = cursor.get();
         assertEquals( "1", tuple.getKey() );
         assertEquals( "1", tuple.getValue() );
-    
+
         cursor.beforeFirst();
         assertFalse( cursor.previous() );
         assertTrue( cursor.next() );
     }
 
-    
+
     @Test
     public void testOnTableWithMultipleEntries() throws Exception
     {
-        for( int i=1; i < 10; i++ )
+        for ( int i = 1; i < 10; i++ )
         {
             String istr = Integer.toString( i );
             table.put( istr, istr );
         }
-    
-        Cursor<Tuple<String,String>> cursor = table.cursor();
-        
-        cursor.after( new Tuple<String,String>( "2", "2" ) );
+
+        Cursor<Tuple<String, String>> cursor = table.cursor();
+
+        cursor.after( new Tuple<String, String>( "2", "2" ) );
         assertTrue( cursor.next() );
-    
-        Tuple<String,String> tuple = cursor.get();
+
+        Tuple<String, String> tuple = cursor.get();
         assertEquals( "3", tuple.getKey() );
         assertEquals( "3", tuple.getValue() );
-    
-        cursor.before( new Tuple<String,String>( "7", "7" ) );
+
+        cursor.before( new Tuple<String, String>( "7", "7" ) );
         cursor.next();
         tuple = cursor.get();
         assertEquals( "7", tuple.getKey() );
         assertEquals( "7", tuple.getValue() );
-    
+
         cursor.last();
         cursor.next();
         tuple = cursor.get();
         assertEquals( "9", tuple.getKey() );
         assertEquals( "9", tuple.getValue() );
-    
+
         cursor.beforeFirst();
         cursor.next();
         tuple = cursor.get();
         assertEquals( "1", tuple.getKey() );
         assertEquals( "1", tuple.getValue() );
-    
+
         cursor.afterLast();
         assertFalse( cursor.next() );
 
         cursor.beforeFirst();
         assertFalse( cursor.previous() );
-        
+
         // just to clear the jdbmTuple value so that line 127 inside after(tuple) method
         // can be executed as part of the below after(tuple) call
-        cursor.before(new Tuple<String,String>( "1", "1" )); 
-        cursor.after( new Tuple<String,String>( "0", "0" ) );
-        
+        cursor.before( new Tuple<String, String>( "1", "1" ) );
+        cursor.after( new Tuple<String, String>( "0", "0" ) );
+
         cursor.next();
         tuple = cursor.get();
         assertEquals( "1", tuple.getKey() );
         assertEquals( "1", tuple.getValue() );
     }
-    
+
 
     @Test
     public void testJdbmBrowserSwitch() throws Exception
     {
-        for( int i=1; i < 10; i++ )
+        for ( int i = 1; i < 10; i++ )
         {
             String istr = Integer.toString( i );
             table.put( istr, istr );
         }
-    
-        Cursor<Tuple<String,String>> cursor = table.cursor();
-        
+
+        Cursor<Tuple<String, String>> cursor = table.cursor();
+
         // go to last and call next then previous twice then next
         cursor.afterLast();
         assertFalse( cursor.next() );
         assertTrue( cursor.previous() );
         assertEquals( "9", cursor.get().getKey() );
-        
+
         assertTrue( cursor.previous() );
         assertEquals( "8", cursor.get().getKey() );
 
         assertTrue( cursor.next() );
-         assertEquals( "9", cursor.get().getKey() );
- 
-        
+        assertEquals( "9", cursor.get().getKey() );
+
         // go to last and call previous then next and again previous 
         cursor.afterLast();
         assertTrue( cursor.previous() );
         assertEquals( "9", cursor.get().getKey() );
-        
+
         assertTrue( cursor.next() );
         assertEquals( "9", cursor.get().getKey() );
-        
+
         assertTrue( cursor.previous() );
         assertEquals( "8", cursor.get().getKey() );
-        
-        
+
         // go to first and call previous then next twice and again next
         cursor.beforeFirst();
         assertFalse( cursor.previous() );
@@ -266,11 +265,10 @@ public class NoDupsCursorTest
 
         assertTrue( cursor.next() );
         assertEquals( "2", cursor.get().getKey() );
-        
+
         assertTrue( cursor.previous() );
         assertEquals( "1", cursor.get().getKey() );
 
-
         // go to first and call next twice then previous
         cursor.beforeFirst();
         assertTrue( cursor.next() );
@@ -278,13 +276,13 @@ public class NoDupsCursorTest
 
         assertTrue( cursor.next() );
         assertEquals( "2", cursor.get().getKey() );
-        
+
         assertTrue( cursor.previous() );
         assertEquals( "1", cursor.get().getKey() );
 
     }
-    
-    
+
+
     @Test
     public void testMiscellaneous() throws Exception
     {

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializerTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializerTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializerTest.java Tue Jan 24 16:15:05 2012
@@ -92,7 +92,7 @@ public class ServerEntrySerializerTest
 
         if ( errors.size() != 0 )
         {
-            fail( "Schema load failed : " + Exceptions.printErrors(errors) );
+            fail( "Schema load failed : " + Exceptions.printErrors( errors ) );
         }
 
         oids = new HashMap<String, OidNormalizer>();
@@ -179,7 +179,7 @@ public class ServerEntrySerializerTest
         entry.add( "objectClass", "top", "person", "inetOrgPerson", "organizationalPerson" );
         entry.add( "cn", "text", "test" );
         entry.add( "SN", "Test" );
-        entry.add( "userPassword", Strings.getBytesUtf8("password") );
+        entry.add( "userPassword", Strings.getBytesUtf8( "password" ) );
 
         EntrySerializer ses = new EntrySerializer( schemaManager );
 
@@ -198,7 +198,7 @@ public class ServerEntrySerializerTest
         entry.add( "objectClass", "top", "person", "inetOrgPerson", "organizationalPerson" );
         entry.add( "cn", "text", "test" );
         entry.add( "SN", "Test" );
-        entry.add( "userPassword", Strings.getBytesUtf8("password") );
+        entry.add( "userPassword", Strings.getBytesUtf8( "password" ) );
 
         EntrySerializer ses = new EntrySerializer( schemaManager );
 
@@ -265,7 +265,7 @@ public class ServerEntrySerializerTest
         Entry entry = new DefaultEntry( schemaManager );
 
         EntrySerializer ses = new EntrySerializer( schemaManager );
-        entry.add( "userPassword", Strings.getBytesUtf8("secret") );
+        entry.add( "userPassword", Strings.getBytesUtf8( "secret" ) );
 
         byte[] data = ses.serialize( entry );
 

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializerTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializerTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializerTest.java Tue Jan 24 16:15:05 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
+
 import java.io.IOException;
 
 import org.apache.commons.lang.RandomStringUtils;
@@ -29,6 +30,7 @@ import org.junit.runner.RunWith;
 
 import static org.junit.Assert.assertEquals;
 
+
 /**
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -44,21 +46,21 @@ public class StringSerializerTest
         for ( int ii = 0; ii < 100; ii++ )
         {
             String str = RandomStringUtils.random( ii );
-            byte [] serialized = serializer.serialize( str );
+            byte[] serialized = serializer.serialize( str );
             String deserialized = ( String ) serializer.deserialize( serialized );
             assertEquals( str, deserialized );
         }
     }
-    
-    
+
+
     char getChar( byte[] bites )
     {
         int ch = bites[0] << 8 & 0x0000FF00;
         ch |= bites[1] & 0x000000FF;
         return ( char ) ch;
     }
-    
-    
+
+
     byte[] getBytes( char ch )
     {
         byte[] bites = new byte[2];
@@ -67,7 +69,7 @@ public class StringSerializerTest
         return bites;
     }
 
-    
+
     @Test
     public void testConversion()
     {

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java Tue Jan 24 16:15:05 2012
@@ -20,6 +20,7 @@
 
 package org.apache.directory.server.core.partition.tree;
 
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -76,15 +77,15 @@ public class PartitionTreeTest
 
         if ( !loaded )
         {
-            fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) );
+            fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
     }
 
-    
+
     /**
      * Test the addition of a single partition
      */
-    @Test 
+    @Test
     public void testNewPartitionTree() throws LdapException
     {
         /** A structure to hold all the partitions */
@@ -112,7 +113,7 @@ public class PartitionTreeTest
     /**
      * Test the addition of a two disjointed partition
      */
-    @Test 
+    @Test
     public void testNewPartitionTree2Nodes() throws LdapException
     {
         /** A structure to hold all the partitions */
@@ -152,7 +153,7 @@ public class PartitionTreeTest
     /**
      * Test the addition of a two partitions with the same root
      */
-    @Test 
+    @Test
     public void testNewPartitionTree2NodesWithSameRoot() throws LdapException
     {
         /** A structure to hold all the partitions */

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/ActionRecordManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/ActionRecordManager.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/ActionRecordManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/ActionRecordManager.java Tue Jan 24 16:15:05 2012
@@ -19,8 +19,10 @@
  */
 package jdbm;
 
+
 import jdbm.helper.ActionContext;
 
+
 /**
  * Extends the RecordManager to allow callers to group their RecordManager interface
  * calls into actions. Actions operate in isolation. 
@@ -41,8 +43,8 @@ public interface ActionRecordManager ext
      * @return The created action context
      */
     ActionContext beginAction( boolean readOnly, String whoStarted );
-    
-    
+
+
     /**
      * Ends the action associated with the context. 
      * ReadWrite actions' changes are made visible
@@ -51,8 +53,8 @@ public interface ActionRecordManager ext
      * @param context identifies the action to end
      */
     void endAction( ActionContext context );
-    
-    
+
+
     /**
      * Aborts the given action. For write actions, actions's changes
      * should not be made visible to readers.
@@ -60,8 +62,8 @@ public interface ActionRecordManager ext
      * @param context identifies the action to abort
      */
     void abortAction( ActionContext context );
-    
-    
+
+
     /**
      * Set the context as the current action context for
      * the given thread
@@ -69,8 +71,8 @@ public interface ActionRecordManager ext
      * @param context identifies the context
      */
     public void setCurrentActionContext( ActionContext context );
-    
-    
+
+
     /**
      * Unsets the context as the current action context. 
      * Given context should be current action context for the 

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManager.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManager.java Tue Jan 24 16:15:05 2012
@@ -79,7 +79,7 @@ public interface RecordManager
      */
     long insert( Object obj ) throws IOException;
 
-    
+
     /**
      * Inserts a new record using a custom serializer.
      *
@@ -120,7 +120,7 @@ public interface RecordManager
      */
     void update( long recid, Object obj, Serializer serializer ) throws IOException;
 
-    
+
     /**
      * Fetches a record using standard java object serialization.
      *
@@ -190,4 +190,3 @@ public interface RecordManager
     /** Set the record id of a named object. */
     void setNamedObject( String name, long recid ) throws IOException;
 }
-

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManagerFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManagerFactory.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManagerFactory.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManagerFactory.java Tue Jan 24 16:15:05 2012
@@ -93,23 +93,23 @@ public final class RecordManagerFactory
      */
     public static RecordManager createRecordManager( String name, Properties options ) throws IOException
     {
-        String                 provider;
-        Class<?>               clazz;
-        RecordManagerProvider  factory;
+        String provider;
+        Class<?> clazz;
+        RecordManagerProvider factory;
 
         provider = options.getProperty( RecordManagerOptions.PROVIDER_FACTORY, "jdbm.recman.Provider" );
 
-        try 
+        try
         {
             clazz = Thread.currentThread().getContextClassLoader().loadClass( provider );
             factory = ( RecordManagerProvider ) clazz.newInstance();
-        } 
-        catch ( Exception except ) 
+        }
+        catch ( Exception except )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_567, provider, except.getClass().getName(),
                 except.getLocalizedMessage() ) );
         }
-        
+
         return factory.createRecordManager( name, options );
     }
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManagerOptions.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManagerOptions.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManagerOptions.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/RecordManagerOptions.java Tue Jan 24 16:15:05 2012
@@ -69,34 +69,27 @@ public final class RecordManagerOptions
     /** Option to create a thread-safe record manager. */
     public final static String PROVIDER_FACTORY = "jdbm.provider";
 
-
     /** Option to create a thread-safe record manager. */
     public final static String THREAD_SAFE = "jdbm.threadSafe";
 
-
     /** Option to automatically commit data after each operation. */
     public final static String AUTO_COMMIT = "jdbm.autoCommit";
 
-
     /**
      * Option to disable transaction (to increase performance at the cost of
      * potential data loss).
      */
     public final static String DISABLE_TRANSACTIONS = "jdbm.disableTransactions";
 
-
     /** Cache type. */
     public final static String CACHE_TYPE = "jdbm.cache.type";
 
-
     /** Cache size (when applicable) */
     public final static String CACHE_SIZE = "jdbm.cache.size";
 
-
     /** Use normal (strong) object references for the record cache. */
     public final static String NORMAL_CACHE = "normal";
 
-
     /**
      * Use soft references {$link java.lang.ref.SoftReference} for the record
      * cache instead of the default normal object references.
@@ -106,7 +99,6 @@ public final class RecordManagerOptions
      */
     public final static String SOFT_REF_CACHE = "soft";
 
-
     /**
      * Use weak references {$link java.lang.ref.WeakReference} for the record
      * cache instead of the default normal object references.

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BPage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BPage.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BPage.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BPage.java Tue Jan 24 16:15:05 2012
@@ -82,7 +82,7 @@ import org.apache.directory.server.i18n.
  * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
  */
 public class BPage<K, V> implements Serializer
-{ 
+{
     private static final boolean DEBUG = false;
 
     /** Version id for serialization. */
@@ -114,8 +114,8 @@ public class BPage<K, V> implements Seri
 
     /** Next leaf BPage (only if this BPage is a leaf) */
     protected long next;
-    
-    public static AtomicInteger outstandingBrowsers = new AtomicInteger(0);
+
+    public static AtomicInteger outstandingBrowsers = new AtomicInteger( 0 );
 
 
     /**
@@ -139,7 +139,7 @@ public class BPage<K, V> implements Seri
 
         first = btree.pageSize - 2;
 
-        keys = (K[])new Object[btree.pageSize];
+        keys = ( K[] ) new Object[btree.pageSize];
         keys[btree.pageSize - 2] = overflow.getLargestKey();
         keys[btree.pageSize - 1] = root.getLargestKey();
 
@@ -154,8 +154,9 @@ public class BPage<K, V> implements Seri
     /**
      * Root page (first insert) constructor.
      */
-    @SuppressWarnings("unchecked") // Cannot create an array of generic objects
-    BPage( BTree<K,V> btree, K key, V value ) throws IOException
+    @SuppressWarnings("unchecked")
+    // Cannot create an array of generic objects
+    BPage( BTree<K, V> btree, K key, V value ) throws IOException
     {
         this.btree = btree;
 
@@ -163,11 +164,11 @@ public class BPage<K, V> implements Seri
 
         first = btree.pageSize - 2;
 
-        keys = (K[])new Object[btree.pageSize];
+        keys = ( K[] ) new Object[btree.pageSize];
         keys[btree.pageSize - 2] = key;
         keys[btree.pageSize - 1] = null; // I am the root BPage for now
 
-        values = (V[])new Object[btree.pageSize];
+        values = ( V[] ) new Object[btree.pageSize];
         values[btree.pageSize - 2] = btree.copyValue( value );
         values[btree.pageSize - 1] = null; // I am the root BPage for now
 
@@ -178,7 +179,8 @@ public class BPage<K, V> implements Seri
     /**
      * Overflow page constructor.  Creates an empty BPage.
      */
-    @SuppressWarnings("unchecked") // Cannot create an array of generic objects
+    @SuppressWarnings("unchecked")
+    // Cannot create an array of generic objects
     BPage( BTree btree, boolean isLeaf ) throws IOException
     {
         this.btree = btree;
@@ -188,11 +190,11 @@ public class BPage<K, V> implements Seri
         // page will initially be half-full
         first = btree.pageSize / 2;
 
-        keys = (K[])new Object[btree.pageSize];
-        
+        keys = ( K[] ) new Object[btree.pageSize];
+
         if ( isLeaf )
         {
-            values = (V[])new Object[btree.pageSize];
+            values = ( V[] ) new Object[btree.pageSize];
         }
         else
         {
@@ -201,35 +203,37 @@ public class BPage<K, V> implements Seri
 
         recordId = btree.recordManager.insert( this, this );
     }
-    
-    @SuppressWarnings("unchecked") // Cannot create an array of generic objects
-    BPage<K,V> copyOnWrite()
+
+
+    @SuppressWarnings("unchecked")
+    // Cannot create an array of generic objects
+    BPage<K, V> copyOnWrite()
     {
-        BPage<K, V> newPage = new BPage<K,V>();
-        
+        BPage<K, V> newPage = new BPage<K, V>();
+
         newPage.btree = this.btree;
         newPage.isLeaf = this.isLeaf;
-        
+
         newPage.first = this.first;
         newPage.previous = this.previous;
         newPage.next = this.next;
-        
-        newPage.keys = (K[])new Object[btree.pageSize];
-        newPage.values = (V[])new Object[btree.pageSize];
+
+        newPage.keys = ( K[] ) new Object[btree.pageSize];
+        newPage.values = ( V[] ) new Object[btree.pageSize];
         newPage.children = new long[btree.pageSize];
-        
+
         newPage.recordId = this.recordId;
-        
+
         if ( this.children != null )
         {
             this.copyChildren( this, 0, newPage, 0, btree.pageSize ); // this copies keys as well
         }
-        
-        if (this.values != null )
+
+        if ( this.values != null )
         {
             this.copyEntries( this, 0, newPage, 0, btree.pageSize ); // this copies keys as well
         }
-        
+
         return newPage;
     }
 
@@ -242,8 +246,8 @@ public class BPage<K, V> implements Seri
     {
         return keys[btree.pageSize - 1];
     }
-    
-    
+
+
     /**
      * @return The record ID
      */
@@ -251,8 +255,8 @@ public class BPage<K, V> implements Seri
     {
         return recordId;
     }
-    
-    
+
+
     /**
      * Set the recordId
      *
@@ -298,10 +302,10 @@ public class BPage<K, V> implements Seri
      * @return TupleBrowser positionned just before the given key, or before
      *                      next greater key if key isn't found.
      */
-    TupleBrowser<K, V> find( int height, K key, ActionContext context) throws IOException
+    TupleBrowser<K, V> find( int height, K key, ActionContext context ) throws IOException
     {
         int index = this.findChildren( key );
-        
+
         if ( index < 0 )
         {
             index = -( index + 1 );
@@ -314,14 +318,14 @@ public class BPage<K, V> implements Seri
             // non-leaf BPage
             child = child.loadBPage( child.children[index] );
             index = child.findChildren( key );
-            
+
             if ( index < 0 )
             {
                 index = -( index + 1 );
             }
         }
 
-        return new Browser( child, index, context);
+        return new Browser( child, index, context );
     }
 
 
@@ -339,7 +343,7 @@ public class BPage<K, V> implements Seri
         else
         {
             BPage<K, V> child = childBPage( first );
-            
+
             return child.findFirst( context );
         }
     }
@@ -365,16 +369,16 @@ public class BPage<K, V> implements Seri
 
         int index = findChildren( key );
         boolean keyExists = index < 0;
-        
+
         if ( index < 0 )
         {
             index = -( index + 1 );
         }
 
         height -= 1;
-        
-        BPage<K,V> pageNewCopy = null;
-        
+
+        BPage<K, V> pageNewCopy = null;
+
         if ( height == 0 )
         {
             pageNewCopy = btree.copyOnWrite( this );
@@ -383,7 +387,7 @@ public class BPage<K, V> implements Seri
 
             // inserting on a leaf BPage
             overflow = -1;
-            
+
             if ( DEBUG )
             {
                 System.out.println( "Bpage.insert() Insert on leaf Bpage key=" + key + " value=" + value + " index="
@@ -400,15 +404,15 @@ public class BPage<K, V> implements Seri
                 {
                     System.out.println( "Bpage.insert() Key already exists." );
                 }
-                
+
                 result.existing = values[index];
-                
+
                 if ( replace )
                 {
                     pageNewCopy.values[index] = btree.copyValue( value );
                     btree.recordManager.update( recordId, pageNewCopy, this );
                 }
-                
+
                 // return the existing key
                 return result;
             }
@@ -418,8 +422,8 @@ public class BPage<K, V> implements Seri
             // non-leaf BPage
             BPage<K, V> child = childBPage( index );
             result = child.insert( height, key, value, replace );
-            
-            if( result.pageNewCopy != null)
+
+            if ( result.pageNewCopy != null )
             {
                 child = result.pageNewCopy;
                 result.pageNewCopy = null;
@@ -441,12 +445,12 @@ public class BPage<K, V> implements Seri
             // on this BPage
             pageNewCopy = btree.copyOnWrite( this );
             result.pageNewCopy = pageNewCopy;
-            
+
             if ( DEBUG )
             {
                 System.out.println( "BPage.insert() Overflow page: " + result.overflow.recordId );
             }
-            
+
             key = result.overflow.getLargestKey();
             overflow = result.overflow.recordId;
 
@@ -460,7 +464,7 @@ public class BPage<K, V> implements Seri
         // if we get here, we need to insert a new entry on the BPage
         // before children[ index ]
         if ( !pageNewCopy.isFull() )
-        {            
+        {
             if ( height == 0 )
             {
                 insertEntry( pageNewCopy, index - 1, key, value );
@@ -469,16 +473,16 @@ public class BPage<K, V> implements Seri
             {
                 insertChild( pageNewCopy, index - 1, key, overflow );
             }
-            
+
             btree.recordManager.update( recordId, pageNewCopy, this );
-            
+
             return result;
         }
 
         // page is full, we must divide the page
         int half = btree.pageSize >> 1;
         BPage<K, V> newPage = new BPage<K, V>( btree, pageNewCopy.isLeaf );
-        
+
         if ( index < half )
         {
             // move lower-half of entries to overflow BPage,
@@ -488,7 +492,7 @@ public class BPage<K, V> implements Seri
                 System.out
                     .println( "Bpage.insert() move lower-half of entries to overflow BPage, including new entry." );
             }
-            
+
             if ( height == 0 )
             {
                 copyEntries( pageNewCopy, 0, newPage, half, index );
@@ -510,7 +514,7 @@ public class BPage<K, V> implements Seri
             {
                 System.out.println( "Bpage.insert() move lower-half of entries to overflow BPage. New entry stays" );
             }
-            
+
             if ( height == 0 )
             {
                 copyEntries( pageNewCopy, 0, newPage, half, half );
@@ -545,7 +549,7 @@ public class BPage<K, V> implements Seri
             // link newly created BPage
             newPage.previous = pageNewCopy.previous;
             newPage.next = pageNewCopy.recordId;
-            
+
             if ( pageNewCopy.previous != 0 )
             {
                 BPage<K, V> previousBPage = loadBPage( pageNewCopy.previous );
@@ -553,7 +557,7 @@ public class BPage<K, V> implements Seri
                 previousBPage.next = newPage.recordId;
                 btree.recordManager.update( pageNewCopy.previous, previousBPage, this );
             }
-            
+
             pageNewCopy.previous = newPage.recordId;
         }
 
@@ -579,16 +583,16 @@ public class BPage<K, V> implements Seri
         int half = btree.pageSize / 2;
         int index = findChildren( key );
         boolean keyExists = index < 0;
-        
+
         if ( index < 0 )
         {
             index = -( index + 1 );
         }
 
         height -= 1;
-        
-        BPage<K,V> pageNewCopy = btree.copyOnWrite( this );
-        
+
+        BPage<K, V> pageNewCopy = btree.copyOnWrite( this );
+
         if ( height == 0 )
         {
             // remove leaf entry
@@ -596,7 +600,7 @@ public class BPage<K, V> implements Seri
             {
                 throw new IllegalArgumentException( I18n.err( I18n.ERR_514, key ) );
             }
-            
+
             result = new RemoveResult<K, V>();
             result.value = pageNewCopy.values[index];
             removeEntry( pageNewCopy, index );
@@ -609,7 +613,7 @@ public class BPage<K, V> implements Seri
             // recurse into Btree to remove entry on a children page
             BPage<K, V> child = childBPage( index );
             result = child.remove( height, key );
-            
+
             if ( result.pageNewCopy != null )
             {
                 child = result.pageNewCopy;
@@ -631,21 +635,21 @@ public class BPage<K, V> implements Seri
                 {
                     throw new IllegalStateException( I18n.err( I18n.ERR_513, "1" ) );
                 }
-                
+
                 if ( index < pageNewCopy.children.length - 1 )
                 {
                     // exists greater brother page
                     BPage<K, V> brother = pageNewCopy.childBPage( index + 1 );
                     brother = btree.copyOnWrite( brother );
                     int bfirst = brother.first;
-                    
+
                     if ( bfirst < half )
                     {
                         // steal entries from "brother" page
                         int steal = ( half - bfirst + 1 ) / 2;
                         brother.first += steal;
                         child.first -= steal;
-                        
+
                         if ( child.isLeaf )
                         {
                             copyEntries( child, half + 1, child, half + 1 - steal, half - 1 );
@@ -689,7 +693,7 @@ public class BPage<K, V> implements Seri
                         }
 
                         brother.first = 1;
-                        
+
                         if ( child.isLeaf )
                         {
                             copyEntries( child, half + 1, brother, 1, half - 1 );
@@ -698,21 +702,23 @@ public class BPage<K, V> implements Seri
                         {
                             copyChildren( child, half + 1, brother, 1, half - 1 );
                         }
-                        
+
                         btree.recordManager.update( brother.recordId, brother, this );
 
                         // remove "child" from current BPage
                         if ( pageNewCopy.isLeaf )
                         {
-                            copyEntries( pageNewCopy, pageNewCopy.first, pageNewCopy, pageNewCopy.first + 1, index - pageNewCopy.first );
+                            copyEntries( pageNewCopy, pageNewCopy.first, pageNewCopy, pageNewCopy.first + 1, index
+                                - pageNewCopy.first );
                             setEntry( pageNewCopy, pageNewCopy.first, null, null );
                         }
                         else
                         {
-                            copyChildren( pageNewCopy, pageNewCopy.first, pageNewCopy, pageNewCopy.first + 1, index - pageNewCopy.first );
+                            copyChildren( pageNewCopy, pageNewCopy.first, pageNewCopy, pageNewCopy.first + 1, index
+                                - pageNewCopy.first );
                             setChild( pageNewCopy, pageNewCopy.first, null, -1 );
                         }
-                        
+
                         pageNewCopy.first += 1;
                         btree.recordManager.update( recordId, pageNewCopy, this );
 
@@ -724,7 +730,7 @@ public class BPage<K, V> implements Seri
                             prev.next = child.next;
                             btree.recordManager.update( prev.recordId, prev, this );
                         }
-                        
+
                         if ( child.next != 0 )
                         {
                             BPage<K, V> next = loadBPage( child.next );
@@ -743,14 +749,14 @@ public class BPage<K, V> implements Seri
                     BPage<K, V> brother = pageNewCopy.childBPage( index - 1 );
                     brother = btree.copyOnWrite( brother );
                     int bfirst = brother.first;
-                    
+
                     if ( bfirst < half )
                     {
                         // steal entries from "brother" page
                         int steal = ( half - bfirst + 1 ) / 2;
                         brother.first += steal;
                         child.first -= steal;
-                        
+
                         if ( child.isLeaf )
                         {
                             copyEntries( brother, 2 * half - steal, child, half + 1 - steal, steal );
@@ -794,7 +800,7 @@ public class BPage<K, V> implements Seri
                         }
 
                         child.first = 1;
-                        
+
                         if ( child.isLeaf )
                         {
                             copyEntries( brother, half, child, 1, half );
@@ -803,21 +809,23 @@ public class BPage<K, V> implements Seri
                         {
                             copyChildren( brother, half, child, 1, half );
                         }
-                        
+
                         btree.recordManager.update( child.recordId, child, this );
 
                         // remove "brother" from current BPage
                         if ( pageNewCopy.isLeaf )
                         {
-                            copyEntries( pageNewCopy, pageNewCopy.first, pageNewCopy, pageNewCopy.first + 1, index - 1 - pageNewCopy.first );
+                            copyEntries( pageNewCopy, pageNewCopy.first, pageNewCopy, pageNewCopy.first + 1, index - 1
+                                - pageNewCopy.first );
                             setEntry( pageNewCopy, pageNewCopy.first, null, null );
                         }
                         else
                         {
-                            copyChildren( pageNewCopy, pageNewCopy.first, pageNewCopy, pageNewCopy.first + 1, index - 1 - pageNewCopy.first );
+                            copyChildren( pageNewCopy, pageNewCopy.first, pageNewCopy, pageNewCopy.first + 1, index - 1
+                                - pageNewCopy.first );
                             setChild( pageNewCopy, pageNewCopy.first, null, -1 );
                         }
-                        
+
                         pageNewCopy.first += 1;
                         btree.recordManager.update( recordId, pageNewCopy, this );
 
@@ -829,7 +837,7 @@ public class BPage<K, V> implements Seri
                             prev.next = brother.next;
                             btree.recordManager.update( prev.recordId, prev, this );
                         }
-                        
+
                         if ( brother.next != 0 )
                         {
                             BPage<K, V> next = loadBPage( brother.next );
@@ -869,9 +877,9 @@ public class BPage<K, V> implements Seri
         while ( left < right )
         {
             int middle = ( left + right ) >>> 1;
-            
+
             int comp = compare( keys[middle], key );
-            
+
             if ( comp < 0 )
             {
                 left = middle + 1;
@@ -887,16 +895,16 @@ public class BPage<K, V> implements Seri
                 return -middle - 1;
             }
         }
-        
+
         if ( left == right )
         {
             // Special case : we don't know if the key is present
-            if ( compare( keys[left], key ) ==0 )
+            if ( compare( keys[left], key ) == 0 )
             {
                 return -right - 1;
             }
         }
-        
+
         return right;
     }
 
@@ -1011,13 +1019,14 @@ public class BPage<K, V> implements Seri
     /**
      * Load the BPage at the given recordId.
      */
-    @SuppressWarnings("unchecked") // The fetch method returns an Object
+    @SuppressWarnings("unchecked")
+    // The fetch method returns an Object
     private BPage<K, V> loadBPage( long recid ) throws IOException
     {
         BPage<K, V> child = ( BPage<K, V> ) btree.recordManager.fetch( recid, this );
         child.recordId = recid;
         child.btree = btree;
-        
+
         return child;
     }
 
@@ -1028,17 +1037,17 @@ public class BPage<K, V> implements Seri
         {
             return 0;
         }
-        
+
         if ( value1 == null )
         {
             return 1;
         }
-        
+
         if ( value2 == null )
         {
             return -1;
         }
-        
+
         return btree.getComparator().compare( value1, value2 );
     }
 
@@ -1046,15 +1055,15 @@ public class BPage<K, V> implements Seri
     static byte[] readByteArray( ObjectInput in ) throws IOException
     {
         int len = in.readInt();
-        
+
         if ( len < 0 )
         {
             return null;
         }
-        
+
         byte[] buf = new byte[len];
         in.readFully( buf );
-        
+
         return buf;
     }
 
@@ -1080,15 +1089,15 @@ public class BPage<K, V> implements Seri
     private void dump( int height )
     {
         StringBuffer prefix = new StringBuffer();
-        
+
         for ( int i = 0; i < height; i++ )
         {
             prefix.append( "    " );
         }
-        
+
         System.out.println( prefix + "-------------------------------------- BPage recordId=" + recordId );
         System.out.println( prefix + "first=" + first );
-        
+
         for ( int i = 0; i < btree.pageSize; i++ )
         {
             if ( isLeaf )
@@ -1100,7 +1109,7 @@ public class BPage<K, V> implements Seri
                 System.out.println( prefix + "BPage [" + i + "] " + keys[i] + " " + children[i] );
             }
         }
-        
+
         System.out.println( prefix + "--------------------------------------" );
     }
 
@@ -1113,16 +1122,16 @@ public class BPage<K, V> implements Seri
     {
         height -= 1;
         level += 1;
-        
+
         if ( height > 0 )
         {
             for ( int i = first; i < btree.pageSize; i++ )
             {
                 if ( keys[i] == null )
-                { 
+                {
                     break;
                 }
-                
+
                 BPage<K, V> child = childBPage( i );
                 child.dump( level );
                 child.dumpRecursive( height, level );
@@ -1155,7 +1164,7 @@ public class BPage<K, V> implements Seri
     void assertConsistencyRecursive( int height ) throws IOException
     {
         assertConsistency();
-        
+
         if ( --height > 0 )
         {
             for ( int i = first; i < btree.pageSize; i++ )
@@ -1164,16 +1173,16 @@ public class BPage<K, V> implements Seri
                 {
                     break;
                 }
-                
+
                 BPage<K, V> child = childBPage( i );
-                
+
                 if ( compare( keys[i], child.getLargestKey() ) != 0 )
                 {
                     dump( 0 );
                     child.dump( 0 );
                     throw new Error( I18n.err( I18n.ERR_516 ) );
                 }
-                
+
                 child.assertConsistencyRecursive( height );
             }
         }
@@ -1187,7 +1196,8 @@ public class BPage<K, V> implements Seri
      * @return deserialized object
      *
      */
-    @SuppressWarnings("unchecked") // Cannot create an array of generic objects
+    @SuppressWarnings("unchecked")
+    // Cannot create an array of generic objects
     public BPage<K, V> deserialize( byte[] serialized ) throws IOException
     {
         ByteArrayInputStream bais;
@@ -1199,7 +1209,7 @@ public class BPage<K, V> implements Seri
         ois = new ObjectInputStream( bais );
 
         bpage.isLeaf = ois.readBoolean();
-        
+
         if ( bpage.isLeaf )
         {
             bpage.previous = ois.readLong();
@@ -1208,23 +1218,23 @@ public class BPage<K, V> implements Seri
 
         bpage.first = ois.readInt();
 
-        bpage.keys = (K[])new Object[btree.pageSize];
-        
+        bpage.keys = ( K[] ) new Object[btree.pageSize];
+
         try
         {
             for ( int i = bpage.first; i < btree.pageSize; i++ )
             {
                 if ( btree.keySerializer == null )
                 {
-                    bpage.keys[i] = (K)ois.readObject();
+                    bpage.keys[i] = ( K ) ois.readObject();
                 }
                 else
                 {
                     serialized = readByteArray( ois );
-                    
+
                     if ( serialized != null )
                     {
-                        bpage.keys[i] = (K)btree.keySerializer.deserialize( serialized );
+                        bpage.keys[i] = ( K ) btree.keySerializer.deserialize( serialized );
                     }
                 }
             }
@@ -1236,23 +1246,23 @@ public class BPage<K, V> implements Seri
 
         if ( bpage.isLeaf )
         {
-            bpage.values = (V[])new Object[btree.pageSize];
-            
+            bpage.values = ( V[] ) new Object[btree.pageSize];
+
             try
             {
                 for ( int i = bpage.first; i < btree.pageSize; i++ )
                 {
                     if ( btree.valueSerializer == null )
                     {
-                        bpage.values[i] =(V) ois.readObject();
+                        bpage.values[i] = ( V ) ois.readObject();
                     }
                     else
                     {
                         serialized = readByteArray( ois );
-                        
+
                         if ( serialized != null )
                         {
-                            bpage.values[i] = (V)btree.valueSerializer.deserialize( serialized );
+                            bpage.values[i] = ( V ) btree.valueSerializer.deserialize( serialized );
                         }
                     }
                 }
@@ -1265,13 +1275,13 @@ public class BPage<K, V> implements Seri
         else
         {
             bpage.children = new long[btree.pageSize];
-            
+
             for ( int i = bpage.first; i < btree.pageSize; i++ )
             {
                 bpage.children[i] = ois.readLong();
             }
         }
-        
+
         ois.close();
         bais.close();
 
@@ -1286,7 +1296,8 @@ public class BPage<K, V> implements Seri
      * @return a byte array representing the object's state
      *
      */
-    @SuppressWarnings("unchecked") // The serialize signature requires an Object, so we have to cast
+    @SuppressWarnings("unchecked")
+    // The serialize signature requires an Object, so we have to cast
     public byte[] serialize( Object obj ) throws IOException
     {
         byte[] serialized;
@@ -1302,7 +1313,7 @@ public class BPage<K, V> implements Seri
         oos = new ObjectOutputStream( baos );
 
         oos.writeBoolean( bpage.isLeaf );
-        
+
         if ( bpage.isLeaf )
         {
             oos.writeLong( bpage.previous );
@@ -1365,7 +1376,7 @@ public class BPage<K, V> implements Seri
         data = baos.toByteArray();
         oos.close();
         baos.close();
-        
+
         return data;
     }
 
@@ -1387,7 +1398,7 @@ public class BPage<K, V> implements Seri
          * Existing value for the insertion key.
          */
         V existing;
-        
+
         /**
          * New version of the page doing the insert
          */
@@ -1409,12 +1420,12 @@ public class BPage<K, V> implements Seri
          * Removed entry value
          */
         V value;
-        
+
         /**
          * New version of the page doing the remove
          */
-        BPage<K, V> pageNewCopy;   
-        
+        BPage<K, V> pageNewCopy;
+
     }
 
     /** PRIVATE INNER CLASS
@@ -1424,10 +1435,10 @@ public class BPage<K, V> implements Seri
     {
         /** Current page. */
         private BPage<K, V> page;
-        
+
         /** context used to track browsing action */
         ActionContext context;
-        
+
         /**
          * Current index in the page.  The index positionned on the next
          * tuple to return.
@@ -1442,12 +1453,12 @@ public class BPage<K, V> implements Seri
          * @param context context in case of action capable record manager 
          * @param index Position of the next tuple to return.
          */
-        Browser( BPage<K, V> page, int index, ActionContext context)
+        Browser( BPage<K, V> page, int index, ActionContext context )
         {
             this.page = page;
             this.index = index;
             this.context = context;
-            
+
             outstandingBrowsers.incrementAndGet();
         }
 
@@ -1462,7 +1473,7 @@ public class BPage<K, V> implements Seri
          */
         public boolean getNext( Tuple<K, V> tuple ) throws IOException
         {
-            btree.setAsCurrentAction( context ); 
+            btree.setAsCurrentAction( context );
             try
             {
                 // First, check that we are within a page                                                            
@@ -1483,12 +1494,12 @@ public class BPage<K, V> implements Seri
                     page = page.loadBPage( page.next );
                     index = page.first;
                 }
-    
+
                 tuple.setKey( page.keys[index] );
                 tuple.setValue( btree.copyValue( page.values[index] ) );
                 index++;
             }
-            catch( IOException e )
+            catch ( IOException e )
             {
                 btree.abortAction( context );
                 context = null;
@@ -1502,14 +1513,15 @@ public class BPage<K, V> implements Seri
                     btree.unsetAsCurrentAction( context );
                 }
             }
-          
+
             return true;
         }
 
+
         public boolean getPrevious( Tuple<K, V> tuple ) throws IOException
         {
             btree.setAsCurrentAction( context );
-            
+
             try
             {
                 if ( index == page.first )
@@ -1525,12 +1537,12 @@ public class BPage<K, V> implements Seri
                         return false;
                     }
                 }
-    
+
                 index--;
                 tuple.setKey( page.keys[index] );
                 tuple.setValue( btree.copyValue( page.values[index] ) );
             }
-            catch( IOException e )
+            catch ( IOException e )
             {
                 btree.abortAction( context );
                 context = null;
@@ -1547,21 +1559,22 @@ public class BPage<K, V> implements Seri
 
             return true;
         }
-        
+
+
         @Override
         public void close()
         {
             super.close();
-            
-            if ( context!= null )
+
+            if ( context != null )
             {
                 btree.setAsCurrentAction( context );
                 btree.endAction( context );
                 context = null;
             }
-            
+
             int browserCount = outstandingBrowsers.decrementAndGet();
-            
+
             if ( browserCount > 0 )
             {
                 //System.out.println( "JDBM btree browsers are outstanding after close: " + browserCount );
@@ -1569,12 +1582,12 @@ public class BPage<K, V> implements Seri
         }
 
     }
-    
-    
+
+
     public String toString()
     {
         StringBuilder sb = new StringBuilder();
-        
+
         if ( isLeaf )
         {
             sb.append( "Leaf(" );
@@ -1583,15 +1596,15 @@ public class BPage<K, V> implements Seri
         {
             sb.append( "Node(" );
         }
-        
+
         sb.append( keys.length );
         sb.append( ") : [" );
-        
+
         if ( isLeaf )
         {
             boolean isFirst = true;
             int index = 0;
-            
+
             for ( K key : keys )
             {
                 if ( isFirst )
@@ -1608,14 +1621,14 @@ public class BPage<K, V> implements Seri
                 sb.append( "/" );
                 sb.append( values[index] );
                 sb.append( ">" );
-                
+
                 index++;
             }
         }
         else
         {
             boolean isFirst = true;
-            
+
             for ( K key : keys )
             {
                 if ( isFirst )

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java Tue Jan 24 16:15:05 2012
@@ -139,17 +139,17 @@ public class BTree<K, V> implements Exte
 
     /** Serializer used for BPages of this tree */
     private transient BPage<K, V> bpageSerializer;
-    
+
     /** TRUE if underlying record manager is snapshot capable */
     private transient boolean isActionCapable;
-    
-    
+
     /** Big lock snychronizing all actions */
-    private transient Lock bigLock = new ReentrantLock(); 
-    
+    private transient Lock bigLock = new ReentrantLock();
+
     /** Meta root used to access versions of Btree root */
     private transient MetaRoot metaRoot = new MetaRoot();
 
+
     /**
      * No-argument constructor used by serialization.
      */
@@ -200,13 +200,13 @@ public class BTree<K, V> implements Exte
     {
         createInstance( recman, comparator, keySerializer, valueSerializer, pageSize );
     }
-    
-    
+
+
     /**
      * The real BTree constructor.
      */
-    private void createInstance(RecordManager recordManager, Comparator<K> comparator, Serializer keySerializer,
-        Serializer valueSerializer, int pageSize) throws IOException
+    private void createInstance( RecordManager recordManager, Comparator<K> comparator, Serializer keySerializer,
+        Serializer valueSerializer, int pageSize ) throws IOException
     {
         if ( recordManager == null )
         {
@@ -237,8 +237,8 @@ public class BTree<K, V> implements Exte
         this.bpageSerializer = new BPage<K, V>();
         this.bpageSerializer.btree = this;
         this.nbEntries = new AtomicInteger( 0 );
-        
-        this.isActionCapable = recordManager instanceof ActionRecordManager; 
+
+        this.isActionCapable = recordManager instanceof ActionRecordManager;
 
         boolean abortedAction = false;
         ActionContext context = this.beginAction( false, "createInstance" );
@@ -259,8 +259,8 @@ public class BTree<K, V> implements Exte
                 this.endAction( context );
         }
     }
-    
-    
+
+
     public void setPageSize( int pageSize )
     {
         if ( ( pageSize & 0x0001 ) != 0 )
@@ -285,10 +285,10 @@ public class BTree<K, V> implements Exte
         BTree<K, V> btree = null;
         boolean abortedAction = false;
         ActionContext context = this.beginAction( false, "load" );
-        
+
         try
         {
-            btree = (BTree<K, V>) recman.fetch( recid );
+            btree = ( BTree<K, V> ) recman.fetch( recid );
             btree.recordId = recid;
             btree.recordManager = recman;
             btree.bpageSerializer = new BPage<K, V>();
@@ -309,7 +309,7 @@ public class BTree<K, V> implements Exte
                 this.endAction( context );
             }
         }
-        
+
         return btree;
     }
 
@@ -332,26 +332,24 @@ public class BTree<K, V> implements Exte
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_523 ) );
         }
-        
+
         if ( value == null )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_524 ) );
         }
 
-        
         boolean abortedAction = false;
-        ActionContext context  = this.beginAction( false, "insert" );
-        
+        ActionContext context = this.beginAction( false, "insert" );
 
         if ( !isActionCapable )
         {
             bigLock.lock();
         }
-        
+
         try
         {
             BPage<K, V> rootPage = getRoot();
-    
+
             if ( rootPage == null )
             {
                 // BTree is currently empty, create a new root BPage
@@ -359,27 +357,27 @@ public class BTree<K, V> implements Exte
                 {
                     System.out.println( "BTree.insert() new root BPage" );
                 }
-                
+
                 rootPage = new BPage<K, V>( this, key, value );
                 rootId = rootPage.getRecordId();
                 bTreeHeight = 1;
                 nbEntries.set( 1 );
                 recordManager.update( recordId, this );
                 updateMetaRoot( this.rootId, this.bTreeHeight );
-                
+
                 return null;
             }
             else
             {
                 BPage.InsertResult<K, V> insert = rootPage.insert( bTreeHeight, key, value, replace );
-                
+
                 if ( insert.pageNewCopy != null )
                 {
                     rootPage = insert.pageNewCopy;
                 }
-                
+
                 boolean dirty = false;
-                
+
                 if ( insert.overflow != null )
                 {
                     // current root page overflowed, we replace with a new root page
@@ -387,25 +385,25 @@ public class BTree<K, V> implements Exte
                     {
                         System.out.println( "BTree.insert() replace root BPage due to overflow" );
                     }
-                    
+
                     rootPage = new BPage<K, V>( this, rootPage, insert.overflow );
                     rootId = rootPage.getRecordId();
                     bTreeHeight += 1;
                     dirty = true;
                     updateMetaRoot( this.rootId, this.bTreeHeight );
                 }
-                
+
                 if ( insert.existing == null )
                 {
                     nbEntries.getAndIncrement();
                     dirty = true;
                 }
-                
+
                 if ( dirty )
                 {
                     recordManager.update( recordId, this );
                 }
-                
+
                 // insert might have returned an existing value
                 return insert.existing;
             }
@@ -422,7 +420,7 @@ public class BTree<K, V> implements Exte
             {
                 this.endAction( context );
             }
-            
+
             if ( !isActionCapable )
             {
                 bigLock.unlock();
@@ -444,8 +442,7 @@ public class BTree<K, V> implements Exte
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_523 ) );
         }
-       
-        
+
         boolean abortedAction = false;
         ActionContext context = this.beginAction( false, "remove" );
 
@@ -453,31 +450,31 @@ public class BTree<K, V> implements Exte
         {
             bigLock.lock();
         }
-        
+
         try
         {
             BPage<K, V> rootPage = getRoot();
-            
+
             if ( rootPage == null )
             {
                 return null;
             }
-            
+
             boolean dirty = false;
             BPage.RemoveResult<K, V> remove = rootPage.remove( bTreeHeight, key );
-            
+
             if ( remove.pageNewCopy != null )
             {
                 rootPage = remove.pageNewCopy;
             }
-            
+
             if ( remove.underflow && rootPage.isEmpty() )
             {
                 bTreeHeight -= 1;
                 dirty = true;
-    
+
                 recordManager.delete( rootId );
-                
+
                 if ( bTreeHeight == 0 )
                 {
                     rootId = 0;
@@ -488,18 +485,18 @@ public class BTree<K, V> implements Exte
                 }
                 updateMetaRoot( this.rootId, this.bTreeHeight );
             }
-            
+
             if ( remove.value != null )
             {
                 nbEntries.getAndDecrement();
                 dirty = true;
             }
-            
+
             if ( dirty )
             {
                 recordManager.update( recordId, this );
             }
-            
+
             return remove.value;
         }
         catch ( IOException e )
@@ -514,7 +511,7 @@ public class BTree<K, V> implements Exte
             {
                 this.endAction( context );
             }
-            
+
             if ( !isActionCapable )
             {
                 bigLock.unlock();
@@ -533,23 +530,23 @@ public class BTree<K, V> implements Exte
     {
         TupleBrowser<K, V> browser = null;
         Tuple<K, V> tuple = null;
-        
+
         if ( key == null )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_523 ) );
         }
-        
+
         if ( !isActionCapable )
         {
             bigLock.lock();
         }
-        
+
         try
-        {      
+        {
             tuple = new Tuple<K, V>( null, null );
-     
+
             browser = browse( key );
-   
+
             if ( browser.getNext( tuple ) )
             {
                 // find returns the matching key or the next ordered key, so we must
@@ -560,7 +557,7 @@ public class BTree<K, V> implements Exte
                 }
                 else
                 {
-                   return this.copyValue( tuple.getValue() );
+                    return this.copyValue( tuple.getValue() );
                 }
             }
             else
@@ -580,7 +577,7 @@ public class BTree<K, V> implements Exte
                 bigLock.unlock();
             }
         }
-        
+
     }
 
 
@@ -605,16 +602,16 @@ public class BTree<K, V> implements Exte
         }
 
         if ( !isActionCapable )
-        { 
+        {
             bigLock.lock();
         }
-        
+
         tuple = new Tuple<K, V>( null, null );
-        
+
         try
         {
             browser = browse( key );
-            
+
             if ( browser.getNext( tuple ) )
             {
                 tuple.setValue( this.copyValue( tuple.getValue() ) );
@@ -631,7 +628,7 @@ public class BTree<K, V> implements Exte
             {
                 browser.close();
             }
-            
+
             if ( !isActionCapable )
             {
                 bigLock.unlock();
@@ -653,26 +650,28 @@ public class BTree<K, V> implements Exte
     {
         TupleBrowser<K, V> browser = null;
         ActionContext context = this.beginAction( true, "browse" );
-        
+
         try
         {
             MetaRoot meta = this.getMetaRoot();
             BPage<K, V> rootPage = this.getRoot( meta );
-            
+
             if ( rootPage == null )
             {
                 this.endAction( context );
-                return new EmptyBrowser(){};
+                return new EmptyBrowser()
+                {
+                };
             }
-            
+
             browser = rootPage.findFirst( context );
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             this.abortAction( context );
             throw e;
         }
-        
+
         this.unsetAsCurrentAction( context );
         return browser;
     }
@@ -694,30 +693,31 @@ public class BTree<K, V> implements Exte
     {
         TupleBrowser<K, V> browser = null;
         ActionContext context = this.beginAction( true, "browse key" );
-        
+
         try
         {
             MetaRoot meta = this.getMetaRoot();
             BPage<K, V> rootPage = this.getRoot( meta );
-            
+
             if ( rootPage == null )
             {
                 this.endAction( context );
-                return new EmptyBrowser(){};
+                return new EmptyBrowser()
+                {
+                };
             }
-          
-            browser  = rootPage.find( meta.treeHeight, key, context );
+
+            browser = rootPage.find( meta.treeHeight, key, context );
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             this.abortAction( context );
             throw e;
         }
-        
+
         this.unsetAsCurrentAction( context );
         return browser;
     }
-    
 
 
     /**
@@ -741,26 +741,26 @@ public class BTree<K, V> implements Exte
     /**
      * @return the root BPage<Object, Object>, or null if it doesn't exist.
      */
-    BPage<K, V> getRoot( ) throws IOException
-    {        
+    BPage<K, V> getRoot() throws IOException
+    {
         if ( rootId != metaRoot.rootID )
         {
-            throw new IllegalStateException( "Stale root id " + this.rootId + " "+ metaRoot.rootID );
+            throw new IllegalStateException( "Stale root id " + this.rootId + " " + metaRoot.rootID );
         }
-        
+
         if ( this.rootId == 0 )
         {
             return null;
         }
-        
+
         BPage<K, V> root = ( BPage<K, V> ) recordManager.fetch( this.rootId, bpageSerializer );
         root.setRecordId( this.rootId );
         root.btree = this;
-        
+
         return root;
     }
-    
-    
+
+
     /**
      * @param meta The root to search for
      * 
@@ -772,15 +772,15 @@ public class BTree<K, V> implements Exte
         {
             return null;
         }
-        
+
         BPage<K, V> root = ( BPage<K, V> ) recordManager.fetch( meta.rootID, bpageSerializer );
         root.setRecordId( meta.rootID );
         root.btree = this;
-        
+
         return root;
     }
-    
-    
+
+
     /**
      * 
      * Returns the meta root that can be used to fetch the root page
@@ -791,16 +791,16 @@ public class BTree<K, V> implements Exte
     MetaRoot getMetaRoot() throws IOException
     {
         if ( isActionCapable )
-        { 
-            return ( MetaRoot )recordManager.fetch( -this.recordId );
+        {
+            return ( MetaRoot ) recordManager.fetch( -this.recordId );
         }
         else
         {
             return metaRoot;
         }
     }
-    
-    
+
+
     /**
      * Implement Externalizable interface.
      */
@@ -836,7 +836,6 @@ public class BTree<K, V> implements Exte
         this.valueSerializer = valueSerializer;
     }
 
-    
     /** PRIVATE INNER CLASS
      *  Browser returning no element.
      */
@@ -847,6 +846,7 @@ public class BTree<K, V> implements Exte
             return false;
         }
 
+
         public boolean getPrevious( Tuple<K, V> tuple )
         {
             return false;
@@ -861,103 +861,102 @@ public class BTree<K, V> implements Exte
     {
         return comparator;
     }
-    
-    
+
+
     void setAsCurrentAction( ActionContext context )
     {
         if ( context != null )
         {
-            ( ( ActionRecordManager )recordManager ).setCurrentActionContext( context );
+            ( ( ActionRecordManager ) recordManager ).setCurrentActionContext( context );
         }
     }
 
-    
+
     void unsetAsCurrentAction( ActionContext context )
     {
         if ( context != null )
         {
-            ( ( ActionRecordManager )recordManager ).unsetCurrentActionContext( context );
+            ( ( ActionRecordManager ) recordManager ).unsetCurrentActionContext( context );
         }
     }
 
-    
+
     ActionContext beginAction( boolean readOnly, String whoStarted )
     {
         ActionContext context = null;
-        
+
         if ( isActionCapable )
         {
-            context = ( ( ActionRecordManager )recordManager ).beginAction( readOnly, whoStarted );
+            context = ( ( ActionRecordManager ) recordManager ).beginAction( readOnly, whoStarted );
         }
-        
+
         return context;
     }
-    
-    
+
+
     void endAction( ActionContext context )
     {
         if ( context != null )
         {
-            ( ( ActionRecordManager )recordManager ).endAction( context );
+            ( ( ActionRecordManager ) recordManager ).endAction( context );
         }
     }
-    
-    
+
+
     void abortAction( ActionContext context )
     {
         if ( context != null )
         {
-            ( ( ActionRecordManager )recordManager ).abortAction( context );
+            ( ( ActionRecordManager ) recordManager ).abortAction( context );
         }
 
     }
-    
-    
-    BPage<K,V> copyOnWrite( BPage<K,V> page) throws IOException
+
+
+    BPage<K, V> copyOnWrite( BPage<K, V> page ) throws IOException
     {
-       return page.copyOnWrite();
+        return page.copyOnWrite();
 
     }
-    
-    
+
+
     private MetaRoot copyOnWrite( MetaRoot oldMetaRoot )
     {
         MetaRoot newMetaRoot = new MetaRoot();
         newMetaRoot.rootID = oldMetaRoot.rootID;
         newMetaRoot.treeHeight = oldMetaRoot.treeHeight;
-        
+
         return newMetaRoot;
     }
-    
-    
+
+
     private void updateMetaRoot( long newRootId, int newTreeHeight ) throws IOException
     {
         metaRoot = this.copyOnWrite( metaRoot );
         metaRoot.rootID = newRootId;
         metaRoot.treeHeight = newTreeHeight;
-        
+
         if ( isActionCapable )
-        { 
+        {
             recordManager.update( -this.recordId, metaRoot );
         }
     }
-    
-    
-    V copyValue( V value) throws IOException 
+
+
+    V copyValue( V value ) throws IOException
     {
         byte[] array;
         V valueCopy = null;
-        
-        
+
         if ( value == null )
         {
             return null;
         }
-        
+
         if ( this.valueSerializer != null )
         {
             array = this.valueSerializer.serialize( value );
-            valueCopy = (V) this.valueSerializer.deserialize( array );
+            valueCopy = ( V ) this.valueSerializer.deserialize( array );
         }
         else
         {
@@ -972,10 +971,10 @@ public class BTree<K, V> implements Exte
                 out = new ObjectOutputStream( bout );
                 out.writeObject( value );
                 out.flush();
-                byte[]  arr = bout.toByteArray();
+                byte[] arr = bout.toByteArray();
                 bin = new ByteArrayInputStream( arr );
                 in = new ObjectInputStream( bin );
-                valueCopy = ( V )in.readObject();
+                valueCopy = ( V ) in.readObject();
             }
             catch ( ClassNotFoundException e )
             {
@@ -1005,22 +1004,22 @@ public class BTree<K, V> implements Exte
             }
 
         }
-        
+
         return valueCopy;
     }
-    
-    
+
+
     public String toString()
     {
         StringBuilder sb = new StringBuilder();
-        
+
         sb.append( "BTree" );
-        sb.append( "(height:" ).append(bTreeHeight );
+        sb.append( "(height:" ).append( bTreeHeight );
         sb.append( ", pageSize:" ).append( pageSize );
         sb.append( ", nbEntries:" ).append( nbEntries );
         sb.append( ", rootId:" ).append( rootId );
         sb.append( ", comparator:" );
-        
+
         if ( comparator == null )
         {
             sb.append( "null" );
@@ -1031,7 +1030,7 @@ public class BTree<K, V> implements Exte
         }
 
         sb.append( ", keySerializer:" );
-        
+
         if ( keySerializer == null )
         {
             sb.append( "null" );
@@ -1051,12 +1050,12 @@ public class BTree<K, V> implements Exte
         {
             sb.append( valueSerializer.getClass().getSimpleName() );
         }
-        
+
         sb.append( ")\n" );
 
         return sb.toString();
     }
-    
+
     /**
      * Used to point to the root page that the reader needs based on the reader's
      * read action context. ReadWrite actions always use the latest root. 

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionContext.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionContext.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionContext.java Tue Jan 24 16:15:05 2012
@@ -19,6 +19,7 @@
  */
 package jdbm.helper;
 
+
 /**
  * Used to store Action specific context.
  *
@@ -26,63 +27,65 @@ package jdbm.helper;
  */
 public class ActionContext
 {
-    /** track whether action is read only */ 
+    /** track whether action is read only */
     boolean readOnly;
-    
+
     /** Version associated with the context */
     ActionVersioning.Version version;
-    
+
     /** Who started the action. Usefule for debugging */
     String whoStarted;
-    
+
+
     public void beginAction( boolean readOnly, ActionVersioning.Version version, String whoStarted )
     {
         this.readOnly = readOnly;
         this.version = version;
         this.whoStarted = whoStarted;
     }
-    
-    
+
+
     public void endAction()
     {
         if ( version == null )
         {
             throw new IllegalStateException( "Unexpected action state during endAction: " + this );
         }
-        
+
         version = null;
     }
-    
-    
+
+
     public boolean isReadOnlyAction()
     {
         return ( readOnly && ( version != null ) );
     }
-    
-    
+
+
     public boolean isWriteAction()
     {
         return ( !readOnly && ( version != null ) );
     }
-    
-    
+
+
     public boolean isActive()
     {
         return ( version != null );
     }
-    
-    
+
+
     public ActionVersioning.Version getVersion()
     {
         return version;
     }
-    
-    
+
+
     public String getWhoStarted()
     {
         return whoStarted;
     }
-    
+
+
     @Override
     public String toString()
     {
@@ -92,7 +95,7 @@ public class ActionContext
         sb.append( ", version: " ).append( version );
         sb.append( ", whoStarted: " ).append( whoStarted );
         sb.append( ")\n" );
-        
+
         return sb.toString();
     }
 }