test_class.declarator: CSV_FILE_NAME =  "test.csv.csv"
test_class.modifier: private final
test_class.original_string: private final String CSV_FILE_NAME =  "test.csv.csv";
test_class.type: String
test_class.var_name: CSV_FILE_NAME
test_class.declarator: CHECK_POINT_DIR = "csv-check-points.csv"
test_class.modifier: private final
test_class.original_string: private final String CHECK_POINT_DIR = "csv-check-points.csv";
test_class.type: String
test_class.var_name: CHECK_POINT_DIR
test_class.file: modules/x-gsn/src/main/java/org/openiot/gsn/wrappers/general/CSVWrapperTest.java
test_class.identifier: CSVWrapperTest
test_case.body: @Test
  	public void testCheckpoints() throws IOException {
  		String fields = "TIMED, air_temp , TIMEd , AiR_TeMp2, comments";
  		String formats = "Timestamp(d.M.y ) , Numeric , timestamp(k:m) , numeric ,String   ";
  		String data = "01.01.2009,1,10:10,10,\"Ali Salehi\"\n"+
  		"01.01.2009,2,10:11,11,\"Ali Salehi\"\n"+
  		"01.01.2009,3,10:12,12,\"Ali Salehi\"\n";
  		CSVHandler wrapper = new CSVHandler();
  		assertEquals(true,wrapper.initialize("test.csv.csv", fields,formats,',','\"',0,"NaN,-1234,4321"));
  		ArrayList<TreeMap<String, Serializable>> parsed = wrapper.parseValues(new StringReader(data), -1, 250);
  		assertEquals(3, parsed.size());
  		assertEquals(wrapper.work(new StringReader(data), CHECK_POINT_DIR, 250).size(), parsed.size());
  		assertEquals(true,((Long)parsed.get(0).get("timed"))<((Long)parsed.get(1).get("timed")));
  		long recentTimestamp = ((Long)parsed.get(parsed.size()-1).get("timed"));
  		data+="01.01.2009,3,10:12,12,\"Ali Salehi\"\n";
  		assertEquals(0,wrapper.parseValues(new StringReader(data), recentTimestamp, 250).size());
  		assertEquals(0,wrapper.work(new StringReader(data), CHECK_POINT_DIR, 250).size());
  
  		data+="01.01.2009,3,10:12,12,\"Ali Salehi\"\n";
  		data+="01.01.2009,3,10:11,12,\"Ali Salehi\"\n";
  		data+="01.01.2009,3,10:10,12,\"Ali Salehi\"\n";
  		assertEquals(0,wrapper.parseValues(new StringReader(data), recentTimestamp, 250).size());
  		assertEquals(0,wrapper.work(new StringReader(data), CHECK_POINT_DIR, 250).size());
  		data+="01.01.2009,3,10:13,13,\"Ali Salehi\"\n";
  		assertEquals(1,wrapper.parseValues(new StringReader(data), recentTimestamp, 250).size());
  		assertEquals(1,wrapper.work(new StringReader(data), CHECK_POINT_DIR, 250).size());
  		data="###########################\n\n\n\n,,,,,,,,,\n\n\n"; // Empty File.
  		wrapper.setSkipFirstXLines(1);
  		assertEquals(0,wrapper.parseValues(new StringReader(data), recentTimestamp, 250).size());
  		assertEquals(0,wrapper.work(new StringReader(data), CHECK_POINT_DIR, 250).size());
  
  	}
test_case.class_method_signature: CSVWrapperTest.testCheckpoints()
test_case.full_signature: @Test public void testCheckpoints()
test_case.identifier: testCheckpoints
test_case.invocations: assertEquals initialize parseValues assertEquals size assertEquals size work size assertEquals get get get get get get size assertEquals size parseValues assertEquals size work assertEquals size parseValues assertEquals size work assertEquals size parseValues assertEquals size work setSkipFirstXLines assertEquals size parseValues assertEquals size work
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCheckpoints()
focal_class.declarator: logger = Logger.getLogger(CSVWrapper.class)
focal_class.modifier: private final transient
focal_class.original_string: private final transient Logger logger = Logger.getLogger(CSVWrapper.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: threadCounter = 0
focal_class.modifier: private static
focal_class.original_string: private static int threadCounter = 0;
focal_class.type: int
focal_class.var_name: threadCounter
focal_class.declarator: dataField
focal_class.modifier: private
focal_class.original_string: private DataField[] dataField;
focal_class.type: DataField[]
focal_class.var_name: dataField
focal_class.declarator: handler = new CSVHandler()
focal_class.modifier: private
focal_class.original_string: private CSVHandler handler = new CSVHandler();
focal_class.type: CSVHandler
focal_class.var_name: handler
focal_class.declarator: samplingPeriodInMsc
focal_class.modifier: private
focal_class.original_string: private int samplingPeriodInMsc;
focal_class.type: int
focal_class.var_name: samplingPeriodInMsc
focal_class.declarator: samplingCountPerPeriod
focal_class.modifier: private
focal_class.original_string: private int samplingCountPerPeriod;
focal_class.type: int
focal_class.var_name: samplingCountPerPeriod
focal_class.declarator: checkPointDir
focal_class.modifier: private
focal_class.original_string: private String checkPointDir;
focal_class.type: String
focal_class.var_name: checkPointDir
focal_class.declarator: dataFileName
focal_class.modifier: private
focal_class.original_string: private String dataFileName;
focal_class.type: String
focal_class.var_name: dataFileName
focal_class.declarator: useCounterForCheckPoint = false
focal_class.original_string: boolean useCounterForCheckPoint = false;
focal_class.type: boolean
focal_class.var_name: useCounterForCheckPoint
focal_class.declarator: processedLineCounter = 0
focal_class.original_string: long processedLineCounter = 0;
focal_class.type: long
focal_class.var_name: processedLineCounter
focal_class.file: modules/x-gsn/src/main/java/org/openiot/gsn/wrappers/general/CSVWrapper.java
focal_class.identifier: CSVWrapper
focal_class.class_method_signature: CSVWrapper.initialize()
focal_class.full_signature: @Override public boolean initialize()
focal_class.identifier: initialize
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean initialize()
focal_class.class_method_signature: CSVWrapper.run()
focal_class.full_signature: @Override public void run()
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: CSVWrapper.getOutputFormat()
focal_class.full_signature: @Override public DataField[] getOutputFormat()
focal_class.identifier: getOutputFormat
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: DataField[]
focal_class.signature: DataField[] getOutputFormat()
focal_class.class_method_signature: CSVWrapper.getWrapperName()
focal_class.full_signature: @Override public String getWrapperName()
focal_class.identifier: getWrapperName
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getWrapperName()
focal_class.class_method_signature: CSVWrapper.dispose()
focal_class.full_signature: @Override public void dispose()
focal_class.identifier: dispose
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void dispose()
focal_class.class_method_signature: CSVWrapper.DEBUG_INFO(String s)
focal_class.full_signature: public void DEBUG_INFO(String s)
focal_class.identifier: DEBUG_INFO
focal_class.modifiers: public
focal_class.parameters: (String s)
focal_class.return: void
focal_class.signature: void DEBUG_INFO(String s)
focal_class.class_method_signature: CSVWrapper.list(String name, long value)
focal_class.full_signature:  String list(String name, long value)
focal_class.identifier: list
focal_class.parameters: (String name, long value)
focal_class.return: String
focal_class.signature: String list(String name, long value)
focal_class.superclass: extends AbstractWrapper
focal_method.body: @Override
      public boolean initialize() {
          setName("CSVWrapper-Thread" + (++threadCounter));
          AddressBean addressBean = getActiveAddressBean();
          dataFileName = addressBean.getPredicateValueWithException("file");
          String csvFields = addressBean.getPredicateValueWithException("fields");
          String csvFormats = addressBean.getPredicateValueWithException("formats");
          //String csvSeparator = addressBean.getPredicateValueWithDefault("separator",",");
          String value = addressBean.getPredicateValue("separator");
          String csvSeparator = (value == null || value.length() == 0) ? "," : value;
          checkPointDir = addressBean.getPredicateValueWithDefault("check-point-directory", "./csv-check-points");
          String csvStringQuote = addressBean.getPredicateValueWithDefault("quote", "\"");
          int skipFirstXLine = addressBean.getPredicateValueAsInt("skip-first-lines", 0);
          String timezone = addressBean.getPredicateValueWithDefault("timezone", CSVHandler.LOCAL_TIMEZONE_ID);
          String nullValues = addressBean.getPredicateValueWithDefault("bad-values", "");
          String strUseCounterForCheckPoint = addressBean.getPredicateValueWithDefault("use-counter-for-check-point", "false");
          samplingPeriodInMsc = addressBean.getPredicateValueAsInt("sampling", 10000);
          samplingCountPerPeriod = addressBean.getPredicateValueAsInt("sampling-count", 250);
  
          /*
           DEBUG_INFO(dataFile);
           */
          if (csvSeparator != null && csvSeparator.length() != 1) {
              logger.warn("The provided CSV separator:>" + csvSeparator + "< should only have  1 character, thus ignored and instead \",\" is used.");
              csvSeparator = ",";
          }
  
          if (csvStringQuote.length() != 1) {
              logger.warn("The provided CSV quote:>" + csvSeparator + "< should only have 1 character, thus ignored and instead '\"' is used.");
              csvStringQuote = "\"";
          }
  
          try {
              if (strUseCounterForCheckPoint.equalsIgnoreCase("true")) {
                  useCounterForCheckPoint = true;
                  logger.warn("Using counter-based check points");
              }
              //String checkPointFile = new File(checkPointDir).getAbsolutePath()+"/"+(new File(dataFile).getName())+"-"+addressBean.hashCode();
              StringBuilder checkPointFile = new StringBuilder()
                      .append(new File(checkPointDir).getAbsolutePath())
                      .append("/")
                      .append(addressBean.getVirtualSensorName())
                      .append("_")
                      .append(addressBean.getInputStreamName())
                      .append("_")
                      .append(addressBean.getWrapper())
                      .append("_")
                      .append(new File(dataFileName).getName());
              if (!handler.initialize(dataFileName.trim(), csvFields, csvFormats, csvSeparator.toCharArray()[0], csvStringQuote.toCharArray()[0], skipFirstXLine, nullValues, timezone, checkPointFile.toString())) {
                  return false;
              }
  
              String val = FileUtils.readFileToString(new File(checkPointFile.toString()), "UTF-8");
              long lastItem = 0;
              if (val != null && val.trim().length() > 0) {
                  lastItem = Long.parseLong(val.trim());
              }
              logger.warn("Latest item: " + lastItem);
  
              if (useCounterForCheckPoint) {
                  processedLineCounter = lastItem;
              }
  
          } catch (IOException | NumberFormatException e) {
              logger.error("Loading the csv-wrapper failed:" + e.getMessage(), e);
              return false;
          }
  
          dataField = handler.getDataFields();
  
          logger.warn("Reading from: " + dataFileName);
  
          return true;
      }
focal_method.class_method_signature: CSVWrapper.initialize()
focal_method.full_signature: @Override public boolean initialize()
focal_method.identifier: initialize
focal_method.invocations: setName getActiveAddressBean getPredicateValueWithException getPredicateValueWithException getPredicateValueWithException getPredicateValue length getPredicateValueWithDefault getPredicateValueWithDefault getPredicateValueAsInt getPredicateValueWithDefault getPredicateValueWithDefault getPredicateValueWithDefault getPredicateValueAsInt getPredicateValueAsInt length warn length warn equalsIgnoreCase warn append append append append append append append append append getAbsolutePath getVirtualSensorName getInputStreamName getWrapper getName initialize trim toCharArray toCharArray toString readFileToString toString length trim parseLong trim warn error getMessage getDataFields warn
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: boolean
focal_method.signature: boolean initialize()