}
}
static synchronized void load()
{
RecordStore rs = null;
RecordEnumeration re = null;
//noinspection CheckForOutOfMemoryOnLargeArrayAllocation
byte[] buffer = new byte[ 256 ];
try
{
rs = RecordStore.openRecordStore( RS_NAME, true );
cache = new Hashtable( rs.getNumRecords() );
re = rs.enumerateRecords( null, null, false );
int recordId;
int recordSize;
//noinspection MethodCallInLoopCondition
while( re.hasNextElement() )
{
recordId = re.nextRecordId();
recordSize = rs.getRecordSize( recordId );
if( buffer.length < recordSize )
{
buffer = new byte[ recordSize + 64 ];
}
rs.getRecord( recordId, buffer, 0 );
final StoreInfo info = new StoreInfo();
info.deserialize( new SerializerInputStream(
new ByteArrayInputStream( buffer )
) );
info.recordId = new Integer( recordId );
cache.put( info.name, info );
}
}
catch( RecordStoreException e )
{
log.error( e );
ErrorHandler.handleError( null, e );
}
catch( SerializationException e )
{
log.error( e );
ErrorHandler.handleError( null, e );
}
finally
{
if( re != null ) try{ re.destroy(); }catch( Exception e ){}
if( rs != null ) try{ rs.closeRecordStore(); }catch( Exception e ){}
}
}