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

Configuration for UtilSOB.getContainedIdxs. See UtilSOB.getContainedIdxs.

Source code:  GCIConfig.java

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public class GCIConfig extends XBNObject { private String sCallingClassFunc = null; private String[] asNames = null; private boolean bEqualOk = false; private PARSCBad parscb = null; /**

Create a GCIConfig with default settings.

Equal to GCIConfig(false)

**/ public GCIConfig() { this(false); } /**

Create a GCIConfig.

Equal to GCIConfig(s_callingClsFnc, false)

**/ public GCIConfig(String s_callingClsFnc) { this(s_callingClsFnc, false); } /**

Create a GCIConfig.

Equal to GCIConfig(null, b_equalOk)

**/ public GCIConfig(boolean b_equalOk) { this(null, b_equalOk); } /**

Create a GCIConfig.

Equal to GCIConfig(null, parsc_bad)

**/ public GCIConfig(PARSCBad parsc_bad) { this(null, parsc_bad); } /**

Create a GCIConfig.

Equal to GCIConfig(s_callingClsFnc, as_names, false)

**/ public GCIConfig(String s_callingClsFnc, String[] as_names) { this(s_callingClsFnc, as_names, false); } /**

Create a GCIConfig.

Equal to GCIConfig(s_callingClsFnc, null, b_equalOk)

**/ public GCIConfig(String s_callingClsFnc, boolean b_equalOk) { this(s_callingClsFnc, null, b_equalOk); } /**

Create a GCIConfig.

Equal to GCIConfig(s_callingClsFnc, null, parsc_bad)

**/ public GCIConfig(String s_callingClsFnc, PARSCBad parsc_bad) { this(s_callingClsFnc, null, parsc_bad); } /**

Create a GCIConfig.

Equal to GCIConfig(null, b_equalOk, parsc_bad)

**/ public GCIConfig(boolean b_equalOk, PARSCBad parsc_bad) { this(null, b_equalOk, parsc_bad); } /**

Create a GCIConfig.

Equal to GCIConfig(s_callingClsFnc, as_names, b_equalOk, (new PARSCBad()))

**/ public GCIConfig(String s_callingClsFnc, String[] as_names, boolean b_equalOk) { this(s_callingClsFnc, as_names, b_equalOk, (new PARSCBad())); } /**

Create a GCIConfig.

Equal to GCIConfig(s_callingClsFnc, as_names, false, parsc_bad)

**/ public GCIConfig(String s_callingClsFnc, String[] as_names, PARSCBad parsc_bad) { this(s_callingClsFnc, as_names, false, parsc_bad); } /**

Create a GCIConfig.

Equal to GCIConfig(s_callingClsFnc, null, b_equalOk, parsc_bad)

**/ public GCIConfig(String s_callingClsFnc, boolean b_equalOk, PARSCBad parsc_bad) { this(s_callingClsFnc, null, b_equalOk, parsc_bad); } /**

Create a GCIConfig.

This documentation discusses UtilSOB.getContainedIdxs, including it's parameters (a_strOrBfr and gci_config) and returned value (an informational s_s).

@param s_callingClsFnc The name of the class-plus-function for potential error messages, when getContainedIdxs detects a containment violation. If null, an informational i_i_i is returned. If non-null, an AssertException is thrown with a message describing the violation (where this class-plus-function is where the error will appear to have been caused). See getCallingClassFunc. @param as_names The array of descriptive names for every element in a_strOrBfr. If non-null, these names are used in potential error messages (element X in as_names is the name of element X in a_strOrBfr). If null, then "a_strOrBfr[INDEX]" is the name assigned to each element. When non-null, this must be exactly the same length as a_strOrBfr. All elements should be non-null and at least one character in length, although this is not enforced. If s_callingClsFnc is null, then this must be null as well. See getAOSNames. @param b_equalOk Should equality also be considered illegal? If true, then containment is illegal, but equality is not. If false, both containment and equality are considered illegal. See isEqualOk. @param parsc_bad Defines extra rules for containment. May not be null. See getPARSCBad. **/ public GCIConfig(String s_callingClsFnc, String[] as_names, boolean b_equalOk, PARSCBad parsc_bad) { throwAXIfNull(parsc_bad, "parsc_bad", sCNSTR); if(s_callingClsFnc == null && as_names != null) { throwAX("constructor: s_callingClsFnc is null, but as_names is not."); } sCallingClassFunc = s_callingClsFnc; asNames = as_names; bEqualOk = b_equalOk; parscb = parsc_bad; } /**

Get the name of the class-plus-function for potential error messages.

If this returns null, an informational i_i_i is returned by getContainedIdxs. If non-null, an AssertException is thrown with a message describing the violation (where this class-plus-function is where the error will appear to have been caused).

@return s_callingClsFnc Exactly as provided to the constructor. **/ public final String getCallingClassFunc() { return sCallingClassFunc; } /**

Get the array of descriptive names for every element in a_strOrBfr. See getContainedIdxs for information on the a_strOrBfr parameter.

If this returns a non-null value, it is an array of strings containing the names to be used in potential error messages (element X in this is the name of element X in a_strOrBfr). If null, then "a_strOrBfr[INDEX]" is the name assigned to each element.

When getCallingClassFunc returns null, this also returns null. When getCallingClassFunc is non-null, this may or may not return null.

@return s_callingClsFnc Exactly as provided to the constructor. **/ public final String[] getAOSNames() { return asNames; } /**

Is equality also considered illegal?

If this returns true, then containment is illegal, but equality is not. If false, both containment and equality are considered illegal.

@return b_equalOk Exactly as provided to the constructor. **/ public final boolean isEqualOk() { return bEqualOk; } /**

Get the PARSCBad, which defines extra containment rules.

@return parsc_bad Exactly as provided to the constructor. **/ public final PARSCBad getPARSCBad() { return parscb; } /**

Get some information about this GCIConfig.

**/ public final String toString() { return this.getClass().getName() + ": getCallingClassFunc()='" + getCallingClassFunc() + "', getAOSNames()=[" + (new APString(getAOSNames())).getList() + "], isEqualOk()=" + isEqualOk() + ", [" + getPARSCBad().toString() + "]"; } }