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 2002 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29 package com.sun.dhcpmgr.data.qualifier; 30 31 /** 32 * An extension of the integer qualifier type that restricts the integer 33 * values to a given range, bounded by an inclusive minimum and maximum value. 34 */ 35 public class QualifierIntegerRange extends QualifierInteger 36 implements QualifierRange { 37 38 /** 39 * Minimum legal value. 40 */ 41 protected int min; 42 43 /** 44 * Maximum legal value. 45 */ 46 protected int max; 47 48 private QualifierIntegerRange() {} 49 50 /** 51 * Construct an integer range qualifier type. 52 * 53 * @param min 54 * Minimum legal value. 55 * @param max 56 * Maximum legal value. 57 */ 58 public QualifierIntegerRange(int min, int max) { 59 this.min = min; 60 this.max = max; 61 } 62 63 /** 64 * Get the minimum boundary. 65 * 66 * @return 67 * Minimum legal value. 68 */ 69 public int getMin() { 70 return min; 71 } 72 73 /** 74 * Get the maximum boundary. 75 * 76 * @return 77 * Maximum legal value. 78 */ 79 public int getMax() { 80 return max; 81 } 82 83 public Object parseValue(String value) { 84 Integer intValue = (Integer)super.parseValue(value); 85 86 if (intValue != null) { 87 int i = intValue.intValue(); 88 89 if (i >= min && i <= max) { 90 return intValue; 91 } 92 } 93 94 return null; 95 } 96 97 public String toString() { 98 return super.toString() + "<" + min + "," + max + ">"; 99 } 100 101 }