@@ -184,6 +184,18 @@ public void parse(BufferedReader buf)
184184
185185 logger .debug (inLoop + " " + line );
186186
187+ if (line .startsWith (MMCIF_TOP_HEADER )){
188+ // either first line in file, or beginning of new section
189+ if ( inLoop ) {
190+ //System.out.println("new data and in loop: " + line);
191+ inLoop = false ;
192+ inLoopData = false ;
193+ lineData .clear ();
194+ loopFields .clear ();
195+ }
196+
197+ }
198+
187199
188200 if ( inLoop ) {
189201
@@ -544,12 +556,10 @@ private List<String> processLine(String line,
544556 private void endLineChecks (String category ,List <String > loopFields , List <String > lineData , Set <String > loopWarnings ) throws IOException {
545557
546558 logger .debug ("Processing category {}, with fields: {}" ,category ,loopFields .toString ());
547- /*System.out.println("parsed the following data: " +category + " fields: "+
548- loopFields + " DATA: " +
549- lineData);
550- if (category.equals("_struct")){
551- System.exit(0);
552- }*/
559+ // System.out.println("parsed the following data: " +category + " fields: "+
560+ // loopFields + " DATA: " +
561+ // lineData);
562+
553563 if ( loopFields .size () != lineData .size ()){
554564 logger .warn ("looks like we got a problem with nested string quote characters:" );
555565 throw new IOException ("data length (" + lineData .size () +
@@ -696,7 +706,6 @@ private void endLineChecks(String category,List<String> loopFields, List<String>
696706 ChemComp .class .getName (),
697707 loopFields , lineData , loopWarnings
698708 );
699-
700709 triggerNewChemComp (c );
701710 } else if (category .equals ("_audit_author" )) {
702711 AuditAuthor aa = (AuditAuthor )buildObject (
@@ -945,8 +954,19 @@ private Object buildObject(String className, List<String> loopFields, List<Strin
945954 key = key .replace ('-' , '_' );
946955
947956 try {
948- Method m = c .getMethod ("set" + u + key .substring (1 ,key .length ()) , String .class );
957+
958+ StringBuffer methodName = new StringBuffer ();
959+ methodName .append ("set" );
960+ methodName .append (u );
961+ methodName .append (key .substring (1 , key .length ()));
962+
963+
964+
965+ Method m = c .getMethod (methodName .toString () , String .class );
949966 m .invoke (o ,val );
967+
968+
969+ ;
950970 }
951971 catch ( NoSuchMethodException nex ){
952972
@@ -970,21 +990,17 @@ private Object buildObject(String className, List<String> loopFields, List<Strin
970990 }
971991 }
972992 }
973- } catch (InstantiationException eix ){
974- logger .warn ( "Error while constructing " +className , eix .getMessage ());
975- } catch (InvocationTargetException etx ){
976- logger .warn ( "Error while constructing " +className , etx .getMessage ());
977- } catch (IllegalAccessException eax ){
978- logger .warn ( "Error while constructing " +className , eax .getMessage ());
979- } catch (ClassNotFoundException ex ){
993+
994+ } catch (Exception ex ){
980995 logger .warn ( "Error while constructing " +className , ex .getMessage ());
996+ ex .printStackTrace ();
981997 }
982998 return o ;
983999 }
9841000
9851001 public void triggerGeneric (String category , List <String > loopFields , List <String > lineData ){
9861002 for (MMcifConsumer c : consumers ){
987- c .newGenericData (category ,loopFields , lineData );
1003+ c .newGenericData (category , loopFields , lineData );
9881004 }
9891005 }
9901006
@@ -1015,6 +1031,7 @@ public void triggerNewEntitySrcSyn(EntitySrcSyn entitySrcSyn){
10151031 }
10161032 }
10171033 public void triggerNewChemComp (ChemComp cc ){
1034+
10181035 for (MMcifConsumer c : consumers ){
10191036 c .newChemComp (cc );
10201037 }
0 commit comments