1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * ident "%Z%%M% %I% %E% SMI"
24 *
25 * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28 package com.sun.dhcpmgr.data;
29
30 import java.util.Vector;
31
32 public class BooleanOptionValue extends OptionValue {
33 private String name;
34
35 // Serialization id for this class
36 static final long serialVersionUID = 5379063769810230706L;
37
38 protected BooleanOptionValue(String name) {
39 this.name = name;
40 }
41
42 public String getName() {
43 return name;
44 }
45
46 public String getValue() {
47 return "";
48 }
49
50 public void setValue(Object value) throws ValidationException {
51 // Booleans must have an empty value
52 Option option = OptionsTable.getTable().get(name);
53 if (value != null && value.toString().length() != 0) {
54 Object [] args = { name,
55 Option.getTypeDhcptabString(option.getType()) };
56 throwException("invalid_option_value", args);
57 }
58 }
59
60 public String toString() {
61 return getName();
62 }
63
64 public boolean isValid() {
65 return true;
66 }
67
68 public Object clone() {
69 return new BooleanOptionValue(name);
70 }
71 }