/* XBN Java: Generically useful, non-GUI Java code. http://sourceforge.net/projects/xbnjava Copyright (C) 1997-2003, Jeff Epstein All rights reserved. Modifications: No Redistribution in binary form, with or without modifications, are permitted provided that the following conditions are met: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * If modifications are made to source code then this license should indicate that fact in the "Modifications" section above. * Neither the author, nor the contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [NOTE: This license contains NO advertising clause.] */ package xbn.util; /**

A RangeConfig where the minimum value is always enforced, and may never be lower than zero. This class is helpful when validating something that has length. To manage a number conforming to an RCLength, see RLength.

Source code:  RCLength.java.  Unit tests:  xbn_junit.JUTRCLength.java.

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public class RCLength extends RangeConfig { /**

Create a, completely unrestricted, RCLength object.

Equal to RCLength(0, -1, false)

**/ public RCLength() { this(0, -1, false); } /**

Create a RCLength.

Equal to RCLength(i_min, i_max)

**/ public RCLength(int i_max) { this(i_max, true); } /**

Create a RCLength.

Equal to RCLength(i_min, i_max, true)

**/ public RCLength(int i_min, int i_max) { this(i_min, i_max, true); } /**

Create a RCLength.

Equal to RCLength(0, i_max, b_nfrcMax)

**/ public RCLength(int i_max, boolean b_nfrcMax) { this(0, i_max, b_nfrcMax); } /**

Create a RCLength.

Equal to RangeConfig(i_min, true, i_max, b_nfrcMax). After this super call is successful, it is then verified that i_min is less than zero.

**/ public RCLength(int i_min, int i_max, boolean b_nfrcMax) { super(i_min, true, i_max, b_nfrcMax); if(i_min < 0) { throwAX("constructor: i_min must be greater than -1."); } } /**

Create a copy of the provided RCLength.

Equal to RangeConfig(rc_length)

**/ public RCLength(RCLength rc_length) { super(rc_length); } /**

Are there any restrictions imposed by this RCLength?

@return (getMin() > 0 || isMaxEnforced()) **/ public boolean isRestricted() { return (getMin() > 0 || isMaxEnforced()); } /**

Get some information about this RCLength.

Equal to toString(true)

**/ public String toString() { return toString(true); } /**

Get some information about this RCLength.

@param b_className If true, display the class name at the beginning of the returned string. If false, don't. **/ public String toString(boolean b_className) { if(!isRestricted()) { return this.getClass().getName() + ": UNRESTRICTED"; } String sMaxEnforced = "not enforced"; if(isMaxEnforced()) { sMaxEnforced = "enforced"; } String sCN = sES; if(b_className) { sCN = this.getClass().getName() + ": "; } return sCN + "getMin()=" + getMin() + " (enforced), getMax()=" + getMax() + " (" + sMaxEnforced + ")"; } }