Example program for handling errors in the Mascot results files.
 
import java.util.Date;
import matrix_science.msparser.*;
 
public class resfile_error {
    static {
        try {
            System.loadLibrary("msparserj");
        } catch (UnsatisfiedLinkError e) {
            System.err.println("Native code library failed to load. "
                               + "Is msparserj.dll on the path?\n" + e);
            System.exit(0);
        }
    }
 
    public static void main(String argv[]) 
    {
        
        if(argv.length < 1) {
            System.out.println("Must specify results filename as parameter");
            System.exit(0);
        }
 
        ms_mascotresfilebase file = ms_mascotresfilebase.createResfile(argv[0], 0, "");
        if (file.isValid()) {
            checkErrorHandler(file);
        } else {
            System.out.println("Error number: "+file.getLastError());
            System.out.println("Error string: "+file.getLastErrorString());
            System.exit(0);
        }
    }
  
      
  
    private static void checkErrorHandler(ms_mascotresfilebase file) {
        int numberOfQueries;
        int loop;
        int loopTwo;
 
        System.out.println("Testing the error handling...            ");
        System.out.println("=========================================");
 
        numberOfQueries = file.getNumQueries();
        file.getObservedCharge(numberOfQueries+40);                
        System.out.println("Error number: "+file.getLastError());
        System.out.println("Error string: "+file.getLastErrorString());
 
        file.clearAllErrors();
        System.out.print("Cleared all errors - should have no errors left: "+file.getNumberOfErrors());
        System.out.println(" errors left\n");
 
        for(loop=1; loop <= 20; loop++) {
            file.getObservedCharge(numberOfQueries+loop);          
        }
 
        
        System.out.println("More errors added - there are now "+file.getNumberOfErrors()+" errors");
 
        for(loopTwo=1; loopTwo <= file.getNumberOfErrors(); loopTwo++) {
            System.out.print("Error number: "+file.getErrorNumber(loopTwo));
            System.out.print(" : "+file.getErrorString(loopTwo));
            System.out.println("");
        }
 
        System.out.println("");
        file.clearAllErrors();  
    }   
}