Class state_class;
Method start_fn = null, final_fn = null;
Class[] typelist;
Object[] arglist;
ObjMethod evt_pairing, obj_meth1, obj_meth2;
Primitive drawobj;
int def_idx;
int bare_etype, cargo_etype, msg_etype;
int Nmatched = 0;
typelist = new Class[] { RecHeader.class, RecBare.class };
arglist = new Object[ 2 ];
System.out.println( "\n\t Completed Objects : " );
total_bytesize = 0;
blk_ins = clog_ins.getBlockStream();
while ( blk_ins != null ) {
rectype = logformat.clog2.Const.AllType.UNDEF;
while ( rectype != logformat.clog2.Const.RecType.ENDBLOCK
&& rectype != logformat.clog2.Const.RecType.ENDLOG ) {
bytes_read = header.readFromDataStream( blk_ins );
total_bytesize += bytes_read;
rectype = header.getRecType();
switch ( rectype ) {
case RecDefState.RECTYPE:
bytes_read = staterec.readFromDataStream( blk_ins );
total_bytesize += bytes_read;
obj_meth1 = (ObjMethod)
evtdefs.get( staterec.startetype );
obj_meth2 = (ObjMethod)
evtdefs.get( staterec.finaletype );
if ( obj_meth1 == null || obj_meth2 == null ) {
stateform = new Topo_State();
def_idx = ObjDef.getNextCategoryIndex();
objdef = new ObjDef( def_idx, staterec,
stateform, 1 );
stateform.setCategory( objdef );
objdefs.add( objdef.getIndex(), objdef );
state_class = stateform.getClass();
try {
start_fn = state_class .getMethod(
"matchStartEvent", typelist );
final_fn = state_class.getMethod(
"matchFinalEvent", typelist );
} catch ( NoSuchMethodException err ) {
err.printStackTrace();
System.exit( 1 );
}
obj_fn = new ObjMethod();
obj_fn.obj = stateform;
obj_fn.method = start_fn;
evtdefs.put( objdef.start_evt, obj_fn );
obj_fn = new ObjMethod();
obj_fn.obj = stateform;
obj_fn.method = final_fn;
evtdefs.put( objdef.final_evt, obj_fn );
}
else { // i.e. obj_meth1 != null && obj_meth2 != null
if ( obj_meth1.obj == obj_meth2.obj ) {
stateform = ( Topo_State ) obj_meth1.obj;
objdef = ( ObjDef ) stateform.getCategory();
objdef.setName( staterec.name );
objdef.setColor(
ColorNameMap.getColorAlpha( staterec.color ) );
}
else {
System.err.println( "**** Error! "
+ obj_meth1.obj + "!="
+ obj_meth2.obj );
}
}
break;
case RecDefEvent.RECTYPE:
bytes_read
= eventrec.skipBytesFromDataStream( blk_ins );
total_bytesize += bytes_read;
break;
case RecDefConst.RECTYPE:
bytes_read
= constrec.skipBytesFromDataStream( blk_ins );
total_bytesize += bytes_read;
break;
case RecBare.RECTYPE:
bytes_read = bare.readFromDataStream( blk_ins );
total_bytesize += bytes_read;
bare_etype = bare.etype.intValue();
if ( bare_etype != Const.AllType.UNDEF ) {
evt_pairing = (ObjMethod) evtdefs.get( bare.etype );
// Object[] arglist = new Object[] { header, bare };
arglist[ 0 ] = header;
arglist[ 1 ] = null;
drawobj = null;
try {
drawobj = (Primitive) evt_pairing.method
.invoke( evt_pairing.obj,
arglist );
} catch ( IllegalAccessException err ) {
err.printStackTrace();
System.err.println( "Offending RecBare = "
+ bare );
// catching NoMatchingEventException
} catch ( InvocationTargetException err ) {
err.printStackTrace();
} catch ( NullPointerException nullerr ) {
nullerr.printStackTrace();
System.err.println( "Offending RecHeader = "
+ header );
System.err.println( "Offending RecBare = "
+ bare );
System.exit(1);
}
if ( drawobj != null )
System.out.println( (++Nmatched) + ", "
+ drawobj.toString() );
}
break;
case RecCargo.RECTYPE:
bytes_read = cargo.readFromDataStream( blk_ins );
total_bytesize += bytes_read;
cargo_etype = cargo.etype.intValue();
if ( cargo_etype != Const.AllType.UNDEF ) {
evt_pairing = (ObjMethod)
evtdefs.get( cargo.etype );
// arglist = new Object[] { header, cargo };
arglist[ 0 ] = header;
arglist[ 1 ] = cargo;
drawobj = null;
try {
drawobj = (Primitive) evt_pairing.method
.invoke( evt_pairing.obj,
arglist );
} catch ( IllegalAccessException err ) {
err.printStackTrace();
System.err.println( "Offending RecCargo = "
+ cargo );
// catching NoMatchingEventException
} catch ( InvocationTargetException err ) {
err.printStackTrace();
} catch ( NullPointerException nullerr ) {
nullerr.printStackTrace();
System.err.println( "Offending RecHeader = "
+ header );
System.err.println( "Offending RecCargo = "
+ cargo );
System.exit(1);
}
if ( drawobj != null )
System.out.println( (++Nmatched) + ", "
+ drawobj.toString() );
}
break;
case RecMsg.RECTYPE:
bytes_read = msg.readFromDataStream( blk_ins );
total_bytesize += bytes_read;
msg_etype = msg.etype.intValue();
if ( msg_etype != Const.AllType.UNDEF ) {
evt_pairing = (ObjMethod) evtdefs.get( msg.etype );
// Object[] arglist = new Object[] { header, msg };
arglist[ 0 ] = header;
arglist[ 1 ] = msg;
drawobj = null;
try {
drawobj = (Primitive) evt_pairing.method
.invoke( evt_pairing.obj,
arglist );
} catch ( IllegalAccessException err ) {
err.printStackTrace();
System.err.println( "Offending RecMsg = "
+ msg );
// catching NoMatchingEventException
} catch ( InvocationTargetException err ) {
err.printStackTrace();
} catch ( NullPointerException nullerr ) {
nullerr.printStackTrace();
System.err.println( "Offending RecHeader = "
+ header );
System.err.println( "Offending RecMsg = "
+ msg );
System.exit(1);
}
if ( drawobj != null )
System.out.println( (++Nmatched) + ", "
+ drawobj.toString() );
}
break;
case RecColl.RECTYPE:
bytes_read = coll.skipBytesFromDataStream( blk_ins );
total_bytesize += bytes_read;