// TestMobyJobs.java
//
//    Created: August 2005
//
// This file is a component of the BioMoby project.
// Copyright Martin Senger (martin.senger@gmail.com).
//

import org.biomoby.shared.MobyException;
import org.biomoby.shared.parser.MobyPackage;
import org.biomoby.shared.parser.MobyJob;
import org.biomoby.shared.datatypes.MobyObject;

import org.biomoby.client.BaseCmdLineClient;

/**
 * For debugging methods in MobyJob objects...
 *
 * @author <A HREF="mailto:martin.senger@gmail.com">Martin Senger</A>
 * @version $Id: TestMobyJobs.java,v 1.1 2005/08/26 06:27:03 senger Exp $
 */
public class TestMobyJobs
    extends BaseCmdLineClient {

    /**************************************************************************
     *
     *************************************************************************/
    public TestMobyJobs (String[] args) {
	super (args);
    }

    /**************************************************************************
     *
     *************************************************************************/
    public static void main (String [] args) {
	new TestMobyJobs (args).doEverything();
    }

    /**************************************************************************
     * This is an embryo of the future jUnit tests...
     *
     * Call (./a == uild/run/run-any-client):
     *    ./a TestMobyJobs -obj Regex regex=x,y,z,t -loop -noout XXX YYY
     * where XXX is an article name in the form -name "name" and
     *       YYY is -cols 2 or nothing
     * The results should be ( 1 == something shown, 0 == null):
     *   YYY is nothinbg            YYY is cols -2
     *   XXX is:                    XXX is:
     *   none    "abc"   "blah"     none    "abc"   "blah"
     *    1        1       1         1        1       1
     *    1        1       0         1        1       0
     *    1        1       0         1        1       0
     *    1        1       1         1        1       1
     *    0        0       0         0        0       0
     *
     *************************************************************************/
    public boolean useResponse (MobyJob response,
				MobyPackage responseContext)
	throws MobyException {
	System.out.println ("JOB " + response.getId());
	System.out.println ("getData(): " + response.getData());
	System.out.println ("getData (\"abc\"): " + response.getData ("abc"));
	System.out.println ("getData (\"abc\", \"Regex\"): " + response.getData ("abc", "Regex"));
	System.out.println ("getData (\"\", \"Regex\"): " + response.getData ("", "Regex"));
	System.out.println ("getData (\"\", \"RegexBIG\"): " + response.getData ("", "RegexBIG"));
	System.out.println ("getDataSet(): " + printCol (response.getDataSet()));
	System.out.println ("getDataSet (\"abc\"): " + printCol (response.getDataSet ("abc")));
	System.out.println ("getDataSet (\"abc\", \"Regex\"): " + printCol (response.getDataSet ("abc", "Regex")));
	System.out.println ("getDataSet (\"\", \"Regex\"): " + printCol (response.getDataSet ("", "Regex")));
	System.out.println ("getDataSet (\"\", \"RegexBIG\"): " + printCol (response.getDataSet ("", "RegexBIG")));
	return true;
    }

    private String printCol (MobyObject[] col) {
	if (col == null) return "null";
	if (col.length == 0) return "empty";
	return col[0].toString();
    }
}
