/* 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 the rules to be enforced by PrimitiveArray.isValid. See PrimitiveArray.isValid.

Source code:  PrimitiveArrayRule.java.

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public abstract class PrimitiveArrayRule extends XBNObject { private PARDupNullLen pardnl = null; private PAROrderDir parod = null; /**

Create an PrimitiveArrayRule.

@param par_dupNullLen Defines whether overall duplicate, null and length rules. May not be null. See getPARDupNullLen. @param par_orderDir Defines ordering requirements to impose onto the array. May not be null. See getPAROrderDir. **/ protected PrimitiveArrayRule(PARDupNullLen par_dupNullLen, PAROrderDir par_orderDir) { throwAXIfNull(par_dupNullLen, "par_dupNullLen", sCNSTR); throwAXIfNull(par_orderDir, "par_orderDir", sCNSTR); pardnl = par_dupNullLen; parod = par_orderDir; } /**

Create a full (deep) copy of the provided PrimitiveArrayRule.

@param pa_rule The PrimitiveArrayRule to copy. May not be null. **/ protected PrimitiveArrayRule(PrimitiveArrayRule pa_rule) { try { pardnl = new PARDupNullLen(pa_rule.pardnl); } catch(NullPointerException npx) { throwAX("constructor: pa_rule is null."); } parod = pa_rule.parod.getPARODClone(); } /**

Get the PARDupNullLen for direct manipulation.

@return par_dupNullLen Exactly as provided to the constructor. **/ public final PARDupNullLen getPARDupNullLen() { return pardnl; } /**

Get the PAROrderDir for direct manipulation.

@return par_dupNullLen Exactly as provided to the constructor. **/ public final PAROrderDir getPAROrderDir() { return parod; } /**

Does this PrimitiveArrayRule have any restrictions?

If this function returns false, then there are absolutely no requirements to impose onto the char array (by PrimitiveArray.isValid). If true, there is at least one requirement.

@return (getPARDupNullLen().isRestricted() || getPAROrderDir().isRestricted()) **/ public boolean isRestricted() { return (getPARDupNullLen().isRestricted() || getPAROrderDir().isRestricted()); } /**

Get some information about this PrimitiveArrayRule.

**/ public String toString() { return this.getClass().getName() + ": [" + getPARDupNullLen().toString() + "], [" + getPAROrderDir().toString() + "]"; } }