You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BoolParameter.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. package com.tigervnc.rfb;
  21. public class BoolParameter extends VoidParameter {
  22. public BoolParameter(String name_, String desc_, boolean v,
  23. Configuration.ConfigurationObject co)
  24. {
  25. super(name_, desc_, co);
  26. value = v;
  27. defValue = v;
  28. }
  29. public BoolParameter(String name_, String desc_, boolean v) {
  30. this(name_, desc_, v, Configuration.ConfigurationObject.ConfGlobal);
  31. }
  32. public boolean setParam(String v) {
  33. if (immutable) return true;
  34. if (v == null || v.equals("1") || v.equalsIgnoreCase("on") ||
  35. v.equalsIgnoreCase("true") || v.equalsIgnoreCase("yes"))
  36. value = true;
  37. else if (v.equals("0") || v.equalsIgnoreCase("off") ||
  38. v.equalsIgnoreCase("false") || v.equalsIgnoreCase("no"))
  39. value = false;
  40. else {
  41. vlog.error("Bool parameter "+getName()+": invalid value '"+v+"'");
  42. return false;
  43. }
  44. return true;
  45. }
  46. public boolean setParam() { setParam(true); return true; }
  47. public void setParam(boolean b) {
  48. if (immutable) return;
  49. value = b;
  50. }
  51. public String getDefaultStr() { return defValue ? "1" : "0"; }
  52. public String getValueStr() { return value ? "1" : "0"; }
  53. public boolean isBool() { return true; }
  54. final public boolean getValue() { return value; }
  55. protected boolean value;
  56. protected boolean defValue;
  57. }