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 that wraps the sensor data type information specified by the user.
009     * 
010     * @author Austen Ito
011     * 
012     */
013    public class SdtOption extends AbstractOption {
014      /** This option's name, which is "-sdt". */
015      public static final String OPTION_NAME = "-sdt";
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 SdtOption(XmlDataController controller, List<String> parameters) {
023        super(controller, OPTION_NAME, parameters);
024      }
025    
026      /** Processes this option by setting the sdt name found in this option. */
027      @Override
028      public void process() {
029        if (this.isValid()) {
030          this.getController().addOptionObject(Options.SDT, this.getParameters().get(0));
031        }
032      }
033    
034      /**
035       * Returns true if the list of parameters contains only one element.
036       * @return true if the parameters are valid, false if not.
037       */
038      @Override
039      public boolean isValid() {
040        if (this.getParameters().size() != 1) {
041          String msg = "The " + OPTION_NAME
042              + " option must have only one argument.  Ex: -sdt DevEvent.";
043          this.getController().fireMessage(msg);
044          return false;
045        }
046        return true;
047      }
048    }