/* 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.array.APChar; import java.util.Arrays; /**
Defines the rules to be enforced by PrimitiveArrayChar.isValid. See PrimitiveArrayChar.isValid.
Source code: PARChar.java.
Create a completely unrestricted PARChar.
Equal to PARChar(new PARDupNullLen())
Using this constructor causes isRestricted to equal true (until values are subsequently altered).
**/ public PARChar() { //OLD, NO LONGER APPLICABLE TO THIS CLASS, BUT STILL INTERESTING //NOTE: //this(null) //results in an "Ambiguous invocation of constructor" //compiler error, using Jikes. I think it is a Jikes bug. this(new PARDupNullLen()); } /**Create a PARChar.
Equal to PARChar(par_dupNullLen, (new PAROrderDir()))
Create a PARChar.
Equal to PARChar((new PARDupNullLen()), par_orderDir)
Create a PARChar.
Equal to PARChar((new PARDupNullLen()), ac_illegal)
Create a PARChar.
Equal to PARChar(par_dupNullLen, par_orderDir, (new char[] {}))
Create a PARChar.
Equal to PARChar(par_dupNullLen, (new PAROrderDir()), ac_illegal)
Create a PARChar.
Equal to PARChar((new PARDupNullLen()), par_dupNullLen, par_orderDir, ac_illegal)
Create an PARCGoodUnq.
The first line of this constructor calls PrimitiveArrayRule(par_dupNullLen, par_orderDir)
.
Create a full (deep) copy of the provided PARChar.
The first line of this constructor calls PrimitiveArrayRule(par_char)
Get the array of chars considered illegal, as an APChar.
@return(new APChar(ac_illegal))
Where ac_illegal is exactly as provided to the constructor (except that it is sorted). Note this object is only created once.
**/
public final APChar getAPCIllegal() {
return apcIllegal;
}
/**
Is there at least one int considered illegal?
@return(getAPCIllegal().getLength() > 0)
**/
public final boolean hasIllegalChars() {
return (getAPCIllegal().getLength() > 0);
}
/**
Is the provided char illegal?
@param c_har The char to determine legality of. May not be null. @return(Arrays.binarySearch(ac_illegal, c_har) > -1)
Where ac_illegal is exactly as provided to the constructor.
**/
public boolean isIllegal(char c_har) {
return (Arrays.binarySearch(acIllegal, c_har) > -1);
}
/**
Does this PARChar have any restrictions?
@return(super.isRestricted() || getAPCIllegal().getLength() > 0)
**/
public boolean isRestricted() {
return (super.isRestricted() || getAPCIllegal().getLength() > 0);
}
/**
Get some information about this PARChar.
**/ public String toString() { return super.toString() + ", getAPCIllegal()=[" + getAPCIllegal().toString() + "]"; } }