public String[] getOptions() {
    Vector<String>	result;
    String[]      	options;
    int           	i;
    
    result = new Vector<String>();

    result.add("-B");
    result.add(MOAUtils.toCommandLine(m_ActualGenerator));
    
    options = super.getOptions();
    for (i = 0; i < options.length; i++)
      result.add(options[i]);
    
    return result.toArray(new String[result.size()]);
  }
  
  /**
   * Sets the MOA stream generator to use.
   * 
   * @param value the stream generator to use
   */
  public void setGenerator(ClassOption value) {
  	m_Generator       = value;
  	m_ActualGenerator = (InstanceStream) MOAUtils.fromOption(m_Generator);
  }
  
  /**
   * Returns the current MOA stream generator in use.
   * 
   * @return the stream generator in use
   */
  public ClassOption getGenerator() {
  	return m_Generator;
  }
  
  /**
   * Returns the tooltip displayed in the GUI.
   * 
   * @return the tooltip
   */
  public String generatorTipText() {
  	return "The MOA stream generator to use.";
  }

  /**
   * Return if single mode is set for the given data generator
   * mode depends on option setting and or generator type.
   * 
   * @return single mode flag, always true
   * @throws Exception if mode is not set yet
   */
  public boolean getSingleModeFlag() throws Exception {
    return true;
  }

  /**
   * Initializes the format for the dataset produced. 
   *
   * @return the format for the dataset 
   * @throws Exception if the generating of the format failed
   */
  public Instances defineDataFormat() throws Exception {
  	int		numExamples;
  	
  	m_ActualGenerator = (InstanceStream) MOAUtils.fromOption(m_Generator);
  	((AbstractOptionHandler) m_ActualGenerator).prepareForUse();
     this.instanceConverter = new SamoaToWekaInstanceConverter();   
    m_DatasetFormat = new Instances(instanceConverter.wekaInstances(m_ActualGenerator.getHeader()));

    // determine number of instances to generate
    numExamples = getNumExamples();
    if (m_ActualGenerator.estimatedRemainingInstances() != -1) {
    	if (m_ActualGenerator.estimatedRemainingInstances() < numExamples)
    		numExamples = (int) m_ActualGenerator.estimatedRemainingInstances();
    }
    setNumExamplesAct(numExamples);
    
    return m_DatasetFormat;
  }

  /**
   * Generates one example of the dataset. 
   *
   * @return the generated example, null if no further example available
   * @throws Exception if the format of the dataset is not yet defined
   * @throws Exception if the generator only works with generateExamples
   * which means in non single mode
   */
  public Instance generateExample() throws Exception {
  	if (m_ActualGenerator.hasMoreInstances()) {
  		return instanceConverter.wekaInstance(m_ActualGenerator.nextInstance().getData());
        } else {
  		return null;
  }
  }

  /**
   * Generates all examples of the dataset. Re-initializes the random number
   * generator with the given seed, before generating instances.
   *
   * @return the generated dataset
   * @throws Exception if the format of the dataset is not yet defined
   * @throws Exception if the generator only works with generateExample,
   * which means in single mode
   * @see   #getSeed()
   */
  public Instances generateExamples() throws Exception {
    Instances       result;
    Instance				inst;
    int             i;

    result   = new Instances(m_DatasetFormat, 0);
    m_Random = new Random(getSeed());

    for (i = 0; i < getNumExamplesAct(); i++) {
    	inst = generateExample();
    	if (inst != null)
    		result.add(inst);
    	else
    		break;
    }
    
    return result;
  }

  /**
   * Generates a comment string that documentates the data generator.
   * By default this string is added at the beginning of the produced output
   * as ARFF file type, next after the options.
   * 
   * @return string contains info about the generated rules
   */
  public String generateStart () {
    return "";
  }

  /**
   * Generates a comment string that documentats the data generator.
   * By default this string is added at the end of theproduces output
   * as ARFF file type.
   * 
   * @return string contains info about the generated rules
   * @throws Exception if the generating of the documentaion fails
   */
  public String generateFinished() throws Exception {
    return "";
  }
  
  /**
   * Returns the revision string.
   * 
   * @return		the revision
   */
  public String getRevision() {
    return RevisionUtils.extract("$Revision$");
  }

  /**
   * Main method for executing this class.
   *
   * @param args should contain arguments for the data producer: 
   */
  public static void main(String[] args) {
    runDataGenerator(new MOA(), args);
  }
}
public String [ ] getOptions ( ) { Vector < String > result ; String [ ] options ; int i ; result = new Vector < String > ( ) ; result . add ( "-B" ) ; result . add ( MOAUtils . toCommandLine ( m_ActualGenerator ) ) ; options = super . getOptions ( ) ; for ( i = 0 ; i < options . length ; i ++ ) result . add ( options [ i ] ) ; return result . toArray ( new String [ result . size ( ) ] ) ; } public void setGenerator ( ClassOption value ) { m_Generator = value ; m_ActualGenerator = ( InstanceStream ) MOAUtils . fromOption ( m_Generator ) ; } public ClassOption getGenerator ( ) { return m_Generator ; } public String generatorTipText ( ) { return "The MOA stream generator to use." ; } public boolean getSingleModeFlag ( ) throws Exception { return true ; } public Instances defineDataFormat ( ) throws Exception { int numExamples ; m_ActualGenerator = ( InstanceStream ) MOAUtils . fromOption ( m_Generator ) ; ( ( AbstractOptionHandler ) m_ActualGenerator ) . prepareForUse ( ) ; this . instanceConverter = new SamoaToWekaInstanceConverter ( ) ; m_DatasetFormat = new Instances ( instanceConverter . wekaInstances ( m_ActualGenerator . getHeader ( ) ) ) ; numExamples = getNumExamples ( ) ; if ( m_ActualGenerator . estimatedRemainingInstances ( ) != - 1 ) { if ( m_ActualGenerator . estimatedRemainingInstances ( ) < numExamples ) numExamples = ( int ) m_ActualGenerator . estimatedRemainingInstances ( ) ; } setNumExamplesAct ( numExamples ) ; return m_DatasetFormat ; } public Instance generateExample ( ) throws Exception { if ( m_ActualGenerator . hasMoreInstances ( ) ) { return instanceConverter . wekaInstance ( m_ActualGenerator . nextInstance ( ) . getData ( ) ) ; } else { return null ; } } public Instances generateExamples ( ) throws Exception { Instances result ; Instance inst ; int i ; result = new Instances ( m_DatasetFormat , 0 ) ; m_Random = new Random ( getSeed ( ) ) ; for ( i = 0 ; i < getNumExamplesAct ( ) ; i ++ ) { inst = generateExample ( ) ; if ( inst != null ) result . add ( inst ) ; else break ; } return result ; } public String generateStart ( ) { return "" ; } public String generateFinished ( ) throws Exception { return "" ; } public String getRevision ( ) { return RevisionUtils . extract ( "$Revision$" ) ; } public static void main ( String [ ] args ) { runDataGenerator ( new MOA ( ) , args ) ; } }
Gets the current settings of the datagenerator.

@return an array of strings suitable for passing to setOptions