}
int recordId;
int recordSize;
byte rowType;
//noinspection MethodCallInLoopCondition
final ProgressEvent event = new ProgressEvent();
event.setSource( this );
event.setCurrentValue( 0 );
event.setPhase( ResourceManager.getResource(
"db.start.startSystem"
) );
event.setMaxValue( new Integer( 2 ) );
ProgressEvent.dispatch( event );
final int length = rids.length;
event.setCurrentValue( 0 );
event.setPhase( ResourceManager.getResource(
"db.start.loadData"
) );
event.setMaxValue( new Integer( length ) );
ProgressEvent.dispatch( event );
//noinspection MethodCallInLoopCondition
for( int i = 0; i < length; i++ )
{
recordId = rids[i];
// Skip header record
if( recordId > 1 )
{
recordSize = rs.getRecordSize( recordId );
if( recordSize > data.length )
{
try
{
data = Tools.secureAlloc(
recordSize + Constants.GROWTH_FACTOR
);
}
catch( J2MEException e )
{
log.error( e );
ErrorLog.addError(
"Database",
"loadStructure",
null,
null,
e
);
throw new DBException(
Constants.ERR_DB_LOAD_STRUCTURE,
e
);
}
}
rs.getRecord( recordId, data, 0 );
ByteArrayInputStream bais = new ByteArrayInputStream( data, 0, recordSize );
SerializerInputStream in = new SerializerInputStream( bais );
rowType = in.readByte();
switch( rowType )
{
case Constants.DBRT_TABLE_INFO:
final TableInfo info = new TableInfo();
info.deserialize( in );
info.setRecordId( recordId );
tableInfo.put( info.getName(), info );
tableInfoList.addElement( info );
break;
case Constants.DBRT_TABLE_STATUS:
final TableStatus status = new TableStatus( this );
status.deserialize( in );
status.setRecordId( recordId );
tableStatus.put( status.getTableName(), status );
break;
}
event.increment();
ProgressEvent.dispatch( event );
}
}
event.increment();
ProgressEvent.dispatch( event );
}
catch( Exception e )
{
log.error( e );