MOA 12.03
Real Time Analytics for Data Streams
FlagOption.java
Go to the documentation of this file.
00001 /*
00002  *    FlagOption.java
00003  *    Copyright (C) 2007 University of Waikato, Hamilton, New Zealand
00004  *    @author Richard Kirkby (rkirkby@cs.waikato.ac.nz)
00005  *
00006  *    This program is free software; you can redistribute it and/or modify
00007  *    it under the terms of the GNU General Public License as published by
00008  *    the Free Software Foundation; either version 3 of the License, or
00009  *    (at your option) any later version.
00010  *
00011  *    This program is distributed in the hope that it will be useful,
00012  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *    GNU General Public License for more details.
00015  *
00016  *    You should have received a copy of the GNU General Public License
00017  *    along with this program. If not, see <http://www.gnu.org/licenses/>.
00018  *    
00019  */
00020 package moa.options;
00021 
00022 import javax.swing.JComponent;
00023 
00024 import moa.gui.FlagOptionEditComponent;
00025 
00032 public class FlagOption extends AbstractOption {
00033 
00034     private static final long serialVersionUID = 1L;
00035 
00036     protected boolean isSet = false;
00037 
00038     public FlagOption(String name, char cliChar, String purpose) {
00039         super(name, cliChar, purpose);
00040     }
00041 
00042     public void setValue(boolean v) {
00043         this.isSet = v;
00044     }
00045 
00046     public void set() {
00047         setValue(true);
00048     }
00049 
00050     public void unset() {
00051         setValue(false);
00052     }
00053 
00054     public boolean isSet() {
00055         return this.isSet;
00056     }
00057 
00058     @Override
00059     public String getDefaultCLIString() {
00060         return null;
00061     }
00062 
00063     @Override
00064     public String getValueAsCLIString() {
00065         return this.isSet ? "" : null;
00066     }
00067 
00068     @Override
00069     public void setValueViaCLIString(String s) {
00070         this.isSet = (s != null);
00071     }
00072 
00073     @Override
00074     public String getStateString() {
00075         return this.isSet ? "true" : "false";
00076     }
00077 
00078     @Override
00079     public JComponent getEditComponent() {
00080         return new FlagOptionEditComponent(this);
00081     }
00082 }
 All Classes Namespaces Files Functions Variables Enumerations