/* 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.util.LockOneWay; /**

A PrimitiveArrayChar that wraps around an array of chars.

Source code:  PACChar.java.

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public class PACChar extends PrimitiveArrayChar implements LockOneWay { /**

To shorten code and Javadoc.

Equal to "xbn.array.primitive.PACChar"

**/ public static final String sPACC = "xbn.array.primitive.PACChar"; private char[] aChar = null; private boolean bLocked = false; /**

Create a PACChar with default values.

Equal to PACChar(null)

**/ public PACChar() { this(null); } /**

Create a PACChar.

Equal to PACChar(sPACC, a_char)

**/ public PACChar(char[] a_char) { this(sPACC, a_char); } /**

Create a PACChar.

Equal to PACChar(s_fqExtendingClass, a_char, (new PARChar()))

**/ public PACChar(String s_fqExtendingClass, char[] a_char) { this(s_fqExtendingClass, a_char, (new PARChar())); } /**

Create a PACChar.

Equal to PACChar(sPACC, a_char)

**/ public PACChar(char[] a_char, PARChar par_char) { this(sPACC, a_char, par_char); } /**

Create a PACChar.

Equal to PACChar(s_fqExtendingClass, a_char, par_char)

**/ public PACChar(String s_fqExtendingClass, char[] a_char, PARChar par_char) { this(s_fqExtendingClass, a_char, par_char, false); } /**

Create a PACChar.

Equal to PACChar(sPACC, a_char, (new PARChar()), b_lock)

**/ public PACChar(char[] a_char, boolean b_lock) { this(sPACC, a_char, (new PARChar()), b_lock); } /**

Create a PACChar.

Equal to PACChar(s_fqExtendingClass, a_char, (new PARChar()), b_lock)

**/ public PACChar(String s_fqExtendingClass, char[] a_char, boolean b_lock) { this(s_fqExtendingClass, a_char, (new PARChar()), b_lock); } /**

Create an PACChar.

Equal to PrimitiveArrayChar(s_fqExtendingClass, a_char, par_char, b_lock)

@param a_char The array of ints to analyze. @param b_lock Should the char array be directly accessible, via getAOChar? If true, yes. If false, no. **/ public PACChar(String s_fqExtendingClass, char[] a_char, PARChar par_char, boolean b_lock) { super(s_fqExtendingClass, par_char); aChar = a_char; bLocked = b_lock; } /**

Get the array of chars for direct manipulation.

@return a_char Exactly as provided to the constructor. **/ public char[] getAOChar() { throwLXIfLocked(isLocked(), "getAOChar"); return aChar; } /**

Get the char at the provide array index.

@param i_dx The array index. Must range 0..[getLength() - 1], inclusive @return a_char[i_dx] Where a_char is exactly as pacced into the constructor. @exception AssertException If isNull equals true. **/ public char getChar(int i_dx) { try { return aChar[i_dx]; } catch(NullPointerException npx) { throwAX("getChar: isNull() equals true."); } catch(ArrayIndexOutOfBoundsException aioobx) { throwAX("getChar: i_dx (" + i_dx + ") is invalid. getLength()=" + getLength() + "."); } //Never reached. Required for compile. return ' '; } /**

How many chars are in the char array?

@return a_char.length Where a_char is exactly as pacced into the constructor. @exception AssertException If isNull equals true. **/ public int getLength() { try { return aChar.length; } catch(NullPointerException npx) { throwAX("getLength: isNull() equals true."); } //Never reached. Required for compile. return ' '; } /**

Is the array null?

@return (a_char == null) Where a_char is exactly as pacced into the constructor. **/ public boolean isNull() { return (aChar == null); } /**

Is the char at the requested array index null?

@return false It is not possible for a char to be null. **/ public boolean isNull(int i_dx) { return false; } //Required by LockOneWay...START public final void lock() { bLocked = true; } public final boolean isLocked() { return bLocked; } //Required by LockOneWay...END }