xbn.util
Class RangeConfig

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.util.RangeConfig
Direct Known Subclasses:
RCLength

public class RangeConfig
extends XBNObject

Defines the legal range for an integer. See Range.

Source code:  RangeConfig.java.  Unit tests:  xbn_junit.JUTRangeConfig.java.

There are four elements of a range:

Inclusive and Exclusive

A range is always inclusive. That is, a number is considered legal when the value is between the minimum and maximum bounds or equal to them. If you need your range to be exclusive, then set the minimum bound to (minimum bound + 1) and maximum bound to (maximum bound - 1).


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
RangeConfig()
          Create a, completely unrestricted, RangeConfig object.
RangeConfig(int i_min, boolean b_nfrcMin, int i_max, boolean b_nfrcMax)
          Create a RangeConfig.
RangeConfig(int i_min, int i_max)
          Create a RangeConfig.
RangeConfig(RangeConfig range_config)
          Create a copy of the provided RangeConfig.
 
Method Summary
 int getMax()
          What is the maximum legal value for this range?
 int getMin()
          What is the minimum legal value for this range?
 boolean isMaxEnforced()
          Is the maximum bound enforced?
 boolean isMinEnforced()
          Is the minimum bound enforced?
 boolean isRestricted()
          Are there any restrictions imposed by this RCLength?
 boolean isValid(int i_potential)
          Is the potential value valid for this Range?
 String toString()
          Get some information about this RangeConfig.
 String toString(boolean b_className)
          Get some information about this RangeConfig.
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RangeConfig

public RangeConfig()

Create a, completely unrestricted, RangeConfig object.

Equal to RangeConfig(-1, false, -1, false)


RangeConfig

public RangeConfig(int i_min,
                   int i_max)

Create a RangeConfig.

Equal to RangeConfig(i_min, true, i_max, true)


RangeConfig

public RangeConfig(int i_min,
                   boolean b_nfrcMin,
                   int i_max,
                   boolean b_nfrcMax)

Create a RangeConfig.

All parameters must be valid according to UtilInt.areRangeBoundsValid(i_min, b_nfrcMin, i_max, b_nfrcMax, true)

Parameters:
i_min - The minimum bound. See getMin.
b_nfrcMin - The minimum bound. See isMinEnforced.
i_max - The minimum bound. See getMax.
b_nfrcMax - The minimum bound. See isMaxEnforced.

RangeConfig

public RangeConfig(RangeConfig range_config)

Create a copy of the provided RangeConfig.

Parameters:
range_config - The range config to copy. May not be null.
Method Detail

isMinEnforced

public final boolean isMinEnforced()

Is the minimum bound enforced?

Returns:
b_nfrcMin exactly as provided to the constructor.

isMaxEnforced

public final boolean isMaxEnforced()

Is the maximum bound enforced?

Returns:
b_nfrcMax exactly as provided to the constructor.

getMin

public final int getMin()

What is the minimum legal value for this range?

Returns:
i_min exactly as provided to the constructor.

getMax

public final int getMax()

What is the maximum legal value for this range?

Returns:
i_max exactly as provided to the constructor.

isValid

public final boolean isValid(int i_potential)

Is the potential value valid for this Range?

Equal to UtilInt.isInRange(i_potential, getMin(), isMinEnforced(), getMax(), isMaxEnforced(), false)


isRestricted

public boolean isRestricted()

Are there any restrictions imposed by this RCLength?

Returns:
(isMinEnforced() || isMaxEnforced())

toString

public String toString()

Get some information about this RangeConfig.

Equal to toString(true)

Overrides:
toString in class Object

toString

public String toString(boolean b_className)

Get some information about this RangeConfig.

Parameters:
b_className - If true, display the class name at the beginning of the returned string. If false, don't.



Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo