/* 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.array.primitive; import xbn.XBNObject; /**

Defines rules regarding containment and equality between array elements. Containment is defined as "element X fully exists in element Y, but is not equal to element Y".

Source code:  PARSContain.java

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public class PARSContain extends XBNObject { private boolean bContainmentOk = true; private boolean bMustContainBeOrdered = true; private boolean bContainOrderAscDesc = true; /**

Create a PARSContain with default values.

Equal to PARSContain(true)

**/ public PARSContain() { this(true); } /**

Create a PARSContain.

Equal to PARSContain(b_containmentOk, false, false)

**/ public PARSContain(boolean b_containmentOk) { this(b_containmentOk, false, false); } /**

Create a PARSContain.

Equal to PARSContain(false, b_rdrdContainment, b_orderDirAscDesc)

**/ public PARSContain(boolean b_rdrdContainment, boolean b_orderDirAscDesc) { this(false, b_rdrdContainment, b_orderDirAscDesc); } /**

Create a PARSContain.

@param b_containmentOk If true, then values may contain one another. If false, no value may be contained in another. See isContainmentOk. @param b_rdrdContainment Must containment be ordered? If true, then yes (direction is defined by b_orderDirAscDesc). If false, no. When b_containmentOk is true, this must equal false. See mustBeOrdered. @param b_orderDirAscDesc What direction should containment ordering be in? If true, then ascending (0, 1, 2, ...), otherwise, descending. When b_rdrdContainment is false, this is ignored. See getOrderDirAscDesc. **/ protected PARSContain(boolean b_containmentOk, boolean b_rdrdContainment, boolean b_orderDirAscDesc) { if(b_rdrdContainment && b_containmentOk) { throwAX("constructor: b_rdrdContainment is true but b_containmentOk is true."); } bContainmentOk = b_containmentOk; bMustContainBeOrdered = b_rdrdContainment; if(!b_rdrdContainment) { bContainOrderAscDesc = false; } else { bContainOrderAscDesc = b_orderDirAscDesc; } } /**

Is it okay for the array to have a value that contains another?. Note that if two elements are equal, they are not "contained" in one another.

@return b_containmentOk Exactly as provided to the constructor. **/ public final boolean isContainmentOk() { return bContainmentOk; } /**

Must containment be in a certain order?

If this returns true, then containment is ordered (direction is defined by getOrderDirAscDesc). If false, containment is not ordered.

@return b_rdrdContainment Exactly as provided to the constructor. Exception: When isContainmentOk equals true, this always returns false.. **/ public final boolean mustBeOrdered() { return bMustContainBeOrdered; } /**

What direction should containment be in?

If this function returns true, then ordering must be ascending (0, 1, 2, ...), meaning element 0 may be contained by element 3, but not vice-versa. If this function returns false, then containment must be descending.

@return b_orderDirAscDesc Exactly as provided to the constructor. Exception: When mustBeOrdered equals false, this always returns false.. **/ public final boolean getOrderDirAscDesc() { return bContainOrderAscDesc; } /**

Does this PARSContain have any restrictions?

@return !isContainmentOk() **/ public final boolean isRestricted() { return !isContainmentOk(); } /**

Get some information about this PARSContain.

**/ public final String toString() { return this.getClass().getName() + ": isContainmentOk()=" + isContainmentOk() + ", mustBeOrdered()=" + mustBeOrdered() + ", getOrderDirAscDesc()=" + getOrderDirAscDesc(); } }