001 package org.hackystat.sensor.xmldata.option; 002 003 import java.util.List; 004 005 import org.hackystat.sensor.xmldata.XmlDataController; 006 007 /** 008 * The option used to alter the "Timestmap" attribute in the sensor data files 009 * to ensure uniqueness. This removes the data collision problem due to entries 010 * having the same timstamps, but the cost is that the sensor/client-side will 011 * lose information about what timestamps are actually being sent to the server. 012 * @author aito 013 * 014 */ 015 public class UniqueTstampOption extends AbstractOption { 016 /** The option name, which is "-uniqueTimestamps". */ 017 public static final String OPTION_NAME = "-uniqueTimestamps"; 018 019 /** 020 * Creates this option with the specified controller and the specified list of 021 * parameters. 022 * @param controller the specified controller. 023 * @param parameters the specified list of parameters. 024 */ 025 public UniqueTstampOption(XmlDataController controller, List<String> parameters) { 026 super(controller, OPTION_NAME, parameters); 027 } 028 029 /** Processes this option by setting the unique timestamps mode to true. */ 030 @Override 031 public void process() { 032 if (this.isValid()) { 033 this.getController().addOptionObject(Options.UNIQUE_TSTAMP, Boolean.TRUE); 034 } 035 } 036 037 /** 038 * Returns true if the list of parameters contains no parameters. 039 * @return true if this option has no parameters, false if not. 040 */ 041 @Override 042 public boolean isValid() { 043 if (!this.getParameters().isEmpty()) { 044 String msg = "The " + OPTION_NAME + " option does not accept parameters. "; 045 this.getController().fireMessage(msg); 046 return false; 047 } 048 return true; 049 } 050 }