001    package org.hackystat.sensor.xmldata.option;
002    
003    import java.util.ArrayList;
004    import java.util.List;
005    
006    import org.hackystat.sensor.xmldata.XmlDataController;
007    
008    /**
009     * The skeletal implementation of an option, which provides default
010     * implementations for the basic accessor methods. Sub-classes must override the
011     * abstract methods to provide functionality specific to their class type.
012     * @author aito
013     * 
014     */
015    public abstract class AbstractOption implements Option {
016      /** The name of this option. */
017      private String name = "";
018      /** The list of parameters used to execute this option. */
019      private List<String> parameters = new ArrayList<String>();
020      /** The controller containing additional information to execute this option. */
021      private XmlDataController controller = null;
022    
023      /**
024       * Constructs this option with a controller, option name, and a list of
025       * parameters used to execute this option.
026       * @param controller the specified controller.
027       * @param name the specified option name.
028       * @param parameters the specified parameters.
029       */
030      public AbstractOption(XmlDataController controller, String name, List<String> parameters) {
031        this.controller = controller;
032        this.name = name;
033        this.parameters = parameters;
034      }
035    
036      /** {@inheritDoc} */
037      public String getName() {
038        return this.name;
039      }
040    
041      /** {@inheritDoc} */
042      public List<String> getParameters() {
043        return this.parameters;
044      }
045    
046      /**
047       * Implements the process method to provide the default process behavior,
048       * which is perform no parameter processing.
049       */
050      public void process() { //NOPMD
051        // Performs no processing.
052      }
053    
054      /** {@inheritDoc} */
055      public abstract boolean isValid();
056    
057      /**
058       * Returns the controller which provides access to parameters processed in
059       * other options and global sensor operations.
060       * @return the controller instance.
061       */
062      public XmlDataController getController() {
063        return this.controller;
064      }
065    
066      /**
067       * Implements the execute method with the default execute behavior, which is
068       * to do nothing.
069       */
070      public void execute() { //NOPMD
071        // Does no execution.
072      }
073    }