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 mark all data sent by this sensor as a batch of data. A 009 * batch of data is marked by having the same runtime. 010 * @author aito 011 * 012 */ 013 public class SetRuntimeOption extends AbstractOption { 014 /** This option's name, which is "-setRuntime". */ 015 public static final String OPTION_NAME = "-setRuntime"; 016 017 /** 018 * Creates this option with the specified controller and parameters. 019 * @param controller the specified controller. 020 * @param parameters the specified parameters. 021 */ 022 public SetRuntimeOption(XmlDataController controller, List<String> parameters) { 023 super(controller, OPTION_NAME, parameters); 024 } 025 026 /** Processes this option by setting the runtime option to true. */ 027 @Override 028 public void process() { 029 if (this.isValid()) { 030 this.getController().addOptionObject(Options.SET_RUNTIME, Boolean.TRUE); 031 } 032 } 033 034 /** 035 * Returns true if the list of parameters contains only no elements. 036 * @return true if the parameters are valid, false if not. 037 */ 038 @Override 039 public boolean isValid() { 040 if (this.getParameters().size() == 0) { 041 return true; 042 } 043 String msg = "The " + OPTION_NAME + " option must have no arguments. Ex: -setRuntime."; 044 this.getController().fireMessage(msg); 045 return false; 046 } 047 }