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 (c) 1998-2001 by Sun Microsystems, Inc. 26 * All rights reserved. 27 */ 28 29 package com.sun.dhcpmgr.data; 30 31 import java.io.Serializable; 32 33 public class DhcpDatastore implements Serializable { 34 35 private String resource; 36 private String location; 37 private String config; 38 private int version; 39 private boolean enabled; 40 41 /** 42 * Simplest constructor. 43 */ 44 public DhcpDatastore() { 45 this(null, null, null, -1, true); 46 } // constructor 47 48 /** 49 * Constructor. 50 * @param r the data store 'resource' value 51 * @param v the data store 'version' value 52 * @param e the data store 'enabled' value 53 */ 54 public DhcpDatastore(String r, int v, boolean e) { 55 this(r, null, null, v, e); 56 } // constructor 57 58 /** 59 * Constructor. 60 * @param r the data store 'resource' value 61 * @param l the data store 'location' value 62 * @param a the data store 'config' value 63 */ 64 public DhcpDatastore(String r, String l, String a) { 65 this(r, l, a, -1, true); 66 } // constructor 67 68 /** 69 * Constructor. 70 * @param r the data store 'resource' value 71 * @param l the data store 'location' value 72 * @param a the data store 'config' value 73 * @param v the data store 'version' value 74 */ 75 public DhcpDatastore(String r, String l, String a, int v) { 76 this(r, l, a, v, true); 77 } // constructor 78 79 /** 80 * Constructor. 81 * @param r the data store 'resource' value 82 * @param l the data store 'location' value 83 * @param a the data store 'config' value 84 * @param v the data store 'version' value 85 * @param e the data store 'enabled' value 86 */ 87 public DhcpDatastore(String r, String l, String a, int v, boolean e) { 88 setResource(r); 89 setLocation(l); 90 setConfig(a); 91 setVersion(v); 92 setEnabled(e); 93 } // constructor 94 95 /** 96 * Returns the data store 'resource' value. 97 * @returns the data store 'resource' value. 98 */ 99 public String getResource() { 100 return resource; 101 } // getResource 102 103 /** 104 * Sets the data store 'resource' value. 105 * @param s the data store 'resource' value. 106 */ 107 public void setResource(String s) { 108 resource = s; 109 } // setResource 110 111 /** 112 * Returns the data store 'location' value. 113 * @returns the data store 'location' value. 114 */ 115 public String getLocation() { 116 return location; 117 } // getLocation 118 119 /** 120 * Sets the data store 'location' value. 121 * @param s the data store 'location' value. 122 */ 123 public void setLocation(String s) { 124 location = s; 125 } // setLocation 126 127 /** 128 * Returns the data store 'config' value. 129 * @returns the data store 'config' value. 130 */ 131 public String getConfig() { 132 return config; 133 } // getConfig 134 135 /** 136 * Sets the data store 'config' value. 137 * @param s the data store 'config' value. 138 */ 139 public void setConfig(String s) { 140 config = s; 141 } // setConfig 142 143 /** 144 * Returns the data store 'version' value. 145 * @returns the data store 'version' value. 146 */ 147 public int getVersion() { 148 return version; 149 } // getVersion 150 151 /** 152 * Sets the data store 'version' value. 153 * @param v the data store 'version' value. 154 */ 155 public void setVersion(int v) { 156 version = v; 157 } // setVersion 158 159 /** 160 * Returns the data store 'enabled' value. 161 * @returns the data store 'enabled' value. 162 */ 163 public boolean isEnabled() { 164 return enabled; 165 } // isEnables 166 167 /** 168 * Sets the data store 'enabled' value. 169 * @param e the data store 'enabled' value. 170 */ 171 public void setEnabled(boolean e) { 172 enabled = e; 173 } // setEnabled 174 175 /** 176 * Indicates whether some other object "is equal" to this one. 177 * @param o the object with which to compare. 178 * @returns true if the objects are equal, false otherwise. 179 */ 180 public boolean equals(Object o) { 181 if (o instanceof DhcpDatastore) { 182 DhcpDatastore d = (DhcpDatastore)o; 183 184 return (version == d.getVersion() && 185 stringsEqual(resource, d.getResource()) && 186 stringsEqual(location, d.getLocation()) && 187 stringsEqual(config, d.getConfig())); 188 189 } else { 190 return false; 191 } 192 193 } // equals 194 195 /** 196 * Compares two strings for equality. 197 * @param s1 one of the strings to compare. 198 * @param s2 the other string to compare against. 199 * @returns true if the strings are equal, false otherwise. 200 */ 201 private boolean stringsEqual(String s1, String s2) { 202 if (s1 == s2) { 203 return true; 204 } else if (s1 == null || s2 == null) { 205 return false; 206 } else { 207 return s1.equals(s2); 208 } 209 } // stringsEqual 210 211 } // DhcpDatastore