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 -multishell option is deprecated and scheduled for removal. The XmlSensor will use whatever
009     * setting is present in the SensorShellProperties file. 
010     * 
011     * The options that is used to notify the data sending Options that a
012     * MultiSensorShell instance should be used instead of a single-threaded
013     * SensorShell.
014     * 
015     * 
016     * @author aito
017     * 
018     */
019    public class MultiShellOption extends AbstractOption {
020      /** This option's name, which is "-multishell". */
021      public static final String OPTION_NAME = "-multishell";
022    
023      /**
024       * Static factory method that creates an option with the specified controller
025       * and parameters. The name of this option is set to "-multishell".
026       * @param controller the specified controller.
027       * @param parameters the specified parameters.
028       */
029      public MultiShellOption(XmlDataController controller, List<String> parameters) {
030        super(controller, MultiShellOption.OPTION_NAME, parameters);
031      }
032    
033      /** Processes this option by setting the multi-shell option to true. */
034      @Override
035      public void process() {
036        if (this.isValid()) {
037          this.getController().addOptionObject(Options.MULTI_SHELL, Boolean.TRUE);
038        }
039      }
040    
041      /**
042       * Returns true if the list of parameters contains no parameters.
043       * @return true if this option has no parameters, false if not.
044       */
045      @Override
046      public boolean isValid() {
047        if (!this.getParameters().isEmpty()) {
048          String msg = "The " + OPTION_NAME + " option does not accept parameters.  ";
049          this.getController().fireMessage(msg);
050          return false;
051        }
052        this.getController().fireMessage("-multishell option ignored. Using SensorShellProperties.");
053        return true;
054      }
055    }