private void countAndVerifyObjects ( ) throws IOException , EOFException , FileManagerException , ClassNotFoundException , HashtableOnDiskException { println ( "countAndVerifyObjects(): Hashtable " + filename + " was not closed properly. Validating " ) ; header . set_num_objects ( 0 ) ; HashtableAction act = new HashtableAction ( ) { public boolean execute ( HashtableEntry e ) throws IOException { if ( ( header . num_objects ( ) % 100 ) == 0 ) { print ( "." ) ; } header . incrementObjectCount ( ) ; if ( item_initialize != null ) { item_initialize . initialize ( e . getKey ( ) , e . getValue ( ) ) ; } return true ; } } ; walkHash ( act , RETRIEVE_ALL , 0 , - 1 ) ; header . write ( ) ; println ( "countAndVerifyObjects(): done" ) ; }
This walks the hash table and sets the internal count of objects . Note that it also sort of works as a verifier of the content - if we throw an exception we can be sure the file is corrupted .