/* 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; import xbn.XBNObject; /**
Ensure an array of objects is valid, according to the rules existing in an AOOVConfig. See AOOVConfig.
Source code: AOOValid.java
Create a completely unrestricted AOOValid.
Equal to AOOValid(new AOOVConfig())
Create an AOOValid.
@param aoov_config The configuration defining "valid". May not be null. **/ public AOOValid(AOOVConfig aoov_config) { throwAXIfNull(aoov_config, "aoov_config", sCNSTR); aoovc = aoov_config; } /**Was the object array validated?
@return true If isValid was called at least once, and it returned true.When extending the isValid function, you must call this immediately before your function returns true.
**/ protected final void declareNoViolation() { bValidated = true; } /**Get the AOOVConfig for direct manipulation.
@return aoov_config Exactly as provided to the constructor. **/ public final AOOVConfig getAOOVConfig() { return aoovc; } /**Is the provided array of objects legal according to the rules existing in the AOOVConfig?
@returnisValid(null, null, a_object)
**/
public boolean isValid(Object[] a_object) {
return isValid(null, null, a_object);
}
/**
Is the provided array of objects legal according to the rules existing in the AOOVConfig?
@param s_callingClsFnc The name of the class-dot-function for use in potential error messages only. This is the place where the error message should appear that it was generated from. For example:xbn.array.primitive.PrimitiveArrayChar.crashIfInvalid
.
@param s_varName The descriptive name of the char array, for potential error messages only.
@param a_object The object array to analyze.
@return true If all rules configured into the AOOVConfig are followed.
If the provided object array is invalid, throw a descriptive error message.
Equal to crashIfBad("xbn.array.AOOValid", "a_object", a_object)
If the provided object array is invalid, throw a descriptive error message.
Equal to isValid(s_callingClsFnc, s_varName, a_object)
(supressing the error message)
Note that before isValid is called, both s_callingClsFnc and s_varName are validated to be both non-null and at least one character in length.
**/ public final void crashIfBad(String s_callingClsFnc, String s_varName, Object[] a_object) { throwAXIfBadStr(s_callingClsFnc, "s_callingClsFnc", "crashIfBad"); throwAXIfBadStr(s_varName, "s_varName", "crashIfBad"); //We don't care what it returns, this is just to indicate that it *does* return something. boolean bUNRTRND = isValid(s_callingClsFnc, s_varName, a_object); } /**Used internally, by isValid. See the code for isValid.
**/ protected final void throwAXBad(String s_callingClsFnc, String s_varName, String s_currently) { throwAX(s_callingClsFnc + ": " + s_varName + " is invalid according to [" + getAOOVConfig().toString() + "]. Currently, " + s_currently + "."); } }