1 /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. 2 * Copyright 2004-2005 Cendio AB. 3 * Copyright 2012 Brian P. Hinz 4 * 5 * This is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This software is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this software; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 * USA. 19 */ 20 21 package com.tigervnc.rfb; 22 23 public class BoolParameter extends VoidParameter { BoolParameter(String name_, String desc_, boolean v, Configuration.ConfigurationObject co)24 public BoolParameter(String name_, String desc_, boolean v, 25 Configuration.ConfigurationObject co) 26 { 27 super(name_, desc_, co); 28 value = v; 29 defValue = v; 30 } 31 BoolParameter(String name_, String desc_, boolean v)32 public BoolParameter(String name_, String desc_, boolean v) { 33 this(name_, desc_, v, Configuration.ConfigurationObject.ConfGlobal); 34 } 35 setParam(String v)36 public boolean setParam(String v) { 37 if (immutable) return true; 38 39 if (v == null || v.equals("1") || v.equalsIgnoreCase("on") || 40 v.equalsIgnoreCase("true") || v.equalsIgnoreCase("yes")) 41 value = true; 42 else if (v.equals("0") || v.equalsIgnoreCase("off") || 43 v.equalsIgnoreCase("false") || v.equalsIgnoreCase("no")) 44 value = false; 45 else { 46 vlog.error("Bool parameter "+getName()+": invalid value '"+v+"'"); 47 return false; 48 } 49 return true; 50 } 51 setParam()52 public boolean setParam() { setParam(true); return true; } setParam(boolean b)53 public void setParam(boolean b) { 54 if (immutable) return; 55 value = b; 56 } 57 getDefaultStr()58 public String getDefaultStr() { return defValue ? "1" : "0"; } getValueStr()59 public String getValueStr() { return value ? "1" : "0"; } isBool()60 public boolean isBool() { return true; } 61 getValue()62 final public boolean getValue() { return value; } 63 64 protected boolean value; 65 protected boolean defValue; 66 } 67