// Path: src/main/java/generator/misc/DataFileDefinition.java
// public class DataFileDefinition
// {
//     private String name;
//     private String description;
//     private Vector<DataFileItem> outDataItems; //a place holder for DataFileItem
//     private String dataItemXml;
//     private String delimiter;
//     private long totalRecords;
//     private int tps;
//     private String log4j;
//     private String log4jName;
//     
//     public void setDataItemXml(String xml) throws Exception {
//       String fullXml = "<datafile-definitions><File-output-definition delimiter=\",\" name=\"Test_" + System.currentTimeMillis() + "\" " +
//       		"totalRecords=\"0\" tps=\"0\">" + xml;
//       fullXml += "</File-output-definition></datafile-definitions>";
//       
//       Vector<DataFileDefinition> vData;
//       RandomDefinitionsBuilder builder = new RandomDefinitionsBuilder();
//       
//       builder.setInputStreame(new ByteArrayInputStream(fullXml.getBytes()));
//       builder.setSAXHandler(new DataFileOutputSAXHandler() );
//       vData = builder.getElements();
//       if(vData.size() == 0) {
//         throw new IOException("XML Parsing error:" + xml);
//       }
//       outDataItems = vData.get(0).getOutDataItems();
//       this.dataItemXml = xml;
//     }
//    
//     public String getDataItemXml() {
//       return dataItemXml;
//     }
//     
//     public String getName() {
//       return name;
//     }
//     public void setName(String name) {
//       this.name = name;
//     }
//     public String getDescription() {
//       return description;
//     }
//     public void setDescription(String description) {
//       this.description = description;
//     }
//     public Vector<DataFileItem> getOutDataItems() {
//       return outDataItems;
//     }
//     public void setOutDataItems(Vector<DataFileItem> outDataItems) {
//       this.outDataItems = outDataItems;
//       StringBuilder sb = new StringBuilder();
//       for(DataFileItem eachItem: outDataItems) {
//         sb.append(dataItemToXml(eachItem)).append("\n");
//       }
//       
//       dataItemXml = sb.toString();
//     }
//     
//     private String dataItemToXml(DataFileItem dataItem) {
//       String result = "<data-item ";
//       result += "fieldName=\"" + dataItem.getFieldName()  + "\" ";
//       result += "randomiser-instance=\"" + dataItem.getRandomiserInstanceName()  + "\" ";
//       result += "width=\"" + dataItem.getWidth()  + "\" ";
//       result += "encloseChar=\"" + dataItem.getEncloseChar()  + "\" ";
//       if(dataItem.getDummy() != null && dataItem.getDummy().length() > 0) {
//         result += "dummy=\"" + dataItem.getDummy()  + "\" ";
//       }
//       if(dataItem.getExpression() != null && dataItem.getExpression().length() > 0) {
//         result += "expression=\"" + dataItem.getExpression()  + "\" ";
//       }
//       result += "alignment=\"" + dataItem.getAlignment()  + "\" />";
//       return result;
//     }
//     
//     public String getDelimiter() {
//       return delimiter;
//     }
//     public void setDelimiter(String delimiter) {
//       this.delimiter = delimiter;
//     }
//     public long getTotalRecords() {
//       return totalRecords;
//     }
//     public void setTotalRecords(long totalRecords) {
//       this.totalRecords = totalRecords;
//     }
//     public int getTps() {
//       return tps;
//     }
//     public void setTps(int tps) {
//       this.tps = tps;
//     }
//     public String getLog4j() {
//       return log4j;
//     }
//     public void setLog4j(String log4j) {
//       this.log4j = log4j;
//     }
//     public String getLog4jName() {
//       return log4jName;
//     }
//     public void setLog4jName(String log4jName) {
//       this.log4jName = log4jName;
//     }
//     public String toString() {
//       return name;
//     }
//     
//     public static void main(String[] args) throws Exception {
//       String data = "<data-item fieldName=\"f1\" alignment=\"1\" encloseChar=\"\" randomiser-instance=\"SimpleSequencer\" width=\"-1\"/>" + 
//                     "<data-item fieldName=\"f2\" alignment=\"1\" encloseChar=\"\" randomiser-instance=\"EnglishFirstnames\" width=\"-1\"/>";
// 
//       data = "<datafile-definitions><File-output-definition delimiter=\",\" name=\"Test_" + System.currentTimeMillis() + "\" totalRecords=\"0\" tps=\"0\">" + data;
//       data += "</File-output-definition></datafile-definitions>";
//       
//       Vector<DataFileDefinition> vData;
//       RandomDefinitionsBuilder builder = new RandomDefinitionsBuilder();
//       
//       builder.setInputStreame(new ByteArrayInputStream(data.getBytes()));
//       builder.setSAXHandler(new DataFileOutputSAXHandler() );
//       vData = builder.getElements();
//       System.out.println(">>>>" + vData.get(0).getOutDataItems().size());
//     }
// }


import generator.engine.ProgressUpdateObserver;
import generator.misc.DataFileDefinition;
package com.gruter.generator.service;


public class GeneratorProgressObserver implements ProgressUpdateObserver {
  DataFileDefinition dfd;
  public GeneratorProgressObserver(DataFileDefinition dfd) {
    this.dfd = dfd;
  }

  @Override
  public void dataGenEnd() {
    System.out.println("========= End ========");
  }

  @Override
  public void dataGenMaxProgressValue(int maxProgress) {
    //System.out.println("maxProgress:" + maxProgress);
  }

  @Override
// Path: src/main/java/generator/misc/DataFileDefinition.java
// public class DataFileDefinition
// {
//     private String name;
//     private String description;
//     private Vector<DataFileItem> outDataItems; //a place holder for DataFileItem
//     private String dataItemXml;
//     private String delimiter;
//     private long totalRecords;
//     private int tps;
//     private String log4j;
//     private String log4jName;
//     
//     public void setDataItemXml(String xml) throws Exception {
//       String fullXml = "<datafile-definitions><File-output-definition delimiter=\",\" name=\"Test_" + System.currentTimeMillis() + "\" " +
//       		"totalRecords=\"0\" tps=\"0\">" + xml;
//       fullXml += "</File-output-definition></datafile-definitions>";
//       
//       Vector<DataFileDefinition> vData;
//       RandomDefinitionsBuilder builder = new RandomDefinitionsBuilder();
//       
//       builder.setInputStreame(new ByteArrayInputStream(fullXml.getBytes()));
//       builder.setSAXHandler(new DataFileOutputSAXHandler() );
//       vData = builder.getElements();
//       if(vData.size() == 0) {
//         throw new IOException("XML Parsing error:" + xml);
//       }
//       outDataItems = vData.get(0).getOutDataItems();
//       this.dataItemXml = xml;
//     }
//    
//     public String getDataItemXml() {
//       return dataItemXml;
//     }
//     
//     public String getName() {
//       return name;
//     }
//     public void setName(String name) {
//       this.name = name;
//     }
//     public String getDescription() {
//       return description;
//     }
//     public void setDescription(String description) {
//       this.description = description;
//     }
//     public Vector<DataFileItem> getOutDataItems() {
//       return outDataItems;
//     }
//     public void setOutDataItems(Vector<DataFileItem> outDataItems) {
//       this.outDataItems = outDataItems;
//       StringBuilder sb = new StringBuilder();
//       for(DataFileItem eachItem: outDataItems) {
//         sb.append(dataItemToXml(eachItem)).append("\n");
//       }
//       
//       dataItemXml = sb.toString();
//     }
//     
//     private String dataItemToXml(DataFileItem dataItem) {
//       String result = "<data-item ";
//       result += "fieldName=\"" + dataItem.getFieldName()  + "\" ";
//       result += "randomiser-instance=\"" + dataItem.getRandomiserInstanceName()  + "\" ";
//       result += "width=\"" + dataItem.getWidth()  + "\" ";
//       result += "encloseChar=\"" + dataItem.getEncloseChar()  + "\" ";
//       if(dataItem.getDummy() != null && dataItem.getDummy().length() > 0) {
//         result += "dummy=\"" + dataItem.getDummy()  + "\" ";
//       }
//       if(dataItem.getExpression() != null && dataItem.getExpression().length() > 0) {
//         result += "expression=\"" + dataItem.getExpression()  + "\" ";
//       }
//       result += "alignment=\"" + dataItem.getAlignment()  + "\" />";
//       return result;
//     }
//     
//     public String getDelimiter() {
//       return delimiter;
//     }
//     public void setDelimiter(String delimiter) {
//       this.delimiter = delimiter;
//     }
//     public long getTotalRecords() {
//       return totalRecords;
//     }
//     public void setTotalRecords(long totalRecords) {
//       this.totalRecords = totalRecords;
//     }
//     public int getTps() {
//       return tps;
//     }
//     public void setTps(int tps) {
//       this.tps = tps;
//     }
//     public String getLog4j() {
//       return log4j;
//     }
//     public void setLog4j(String log4j) {
//       this.log4j = log4j;
//     }
//     public String getLog4jName() {
//       return log4jName;
//     }
//     public void setLog4jName(String log4jName) {
//       this.log4jName = log4jName;
//     }
//     public String toString() {
//       return name;
//     }
//     
//     public static void main(String[] args) throws Exception {
//       String data = "<data-item fieldName=\"f1\" alignment=\"1\" encloseChar=\"\" randomiser-instance=\"SimpleSequencer\" width=\"-1\"/>" + 
//                     "<data-item fieldName=\"f2\" alignment=\"1\" encloseChar=\"\" randomiser-instance=\"EnglishFirstnames\" width=\"-1\"/>";
// 
//       data = "<datafile-definitions><File-output-definition delimiter=\",\" name=\"Test_" + System.currentTimeMillis() + "\" totalRecords=\"0\" tps=\"0\">" + data;
//       data += "</File-output-definition></datafile-definitions>";
//       
//       Vector<DataFileDefinition> vData;
//       RandomDefinitionsBuilder builder = new RandomDefinitionsBuilder();
//       
//       builder.setInputStreame(new ByteArrayInputStream(data.getBytes()));
//       builder.setSAXHandler(new DataFileOutputSAXHandler() );
//       vData = builder.getElements();
//       System.out.println(">>>>" + vData.get(0).getOutDataItems().size());
//     }
// }


// Path: src/main/java/com/gruter/generator/service/GeneratorProgressObserver.java
import generator.engine.ProgressUpdateObserver;
import generator.misc.DataFileDefinition;

package com.gruter.generator.service;


public class GeneratorProgressObserver implements ProgressUpdateObserver {
  DataFileDefinition dfd;
  public GeneratorProgressObserver(DataFileDefinition dfd) {
    this.dfd = dfd;
  }

  @Override
  public void dataGenEnd() {
    System.out.println("========= End ========");
  }

  @Override
  public void dataGenMaxProgressValue(int maxProgress) {
    //System.out.println("maxProgress:" + maxProgress);
  }

  @Override
  public boolean dataGenProgressContinue(String msg, int progress) {