/* 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 PrimitiveArrayInt that wraps around an array of ints.

Source code:  PAIInt.java

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

To shorten code and Javadoc.

Equal to "xbn.array.primitive.PAIInt"

**/ public static final String sPAII = "xbn.array.primitive.PAIInt"; private int[] aInt = null; private boolean bLocked = false; /**

Create a PAIInt with default values.

Equal to PAIInt(null)

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

Create a PAIInt.

Equal to PAIInt(sPAII, a_int)

**/ public PAIInt(int[] a_int) { this(sPAII, a_int); } /**

Create a PAIInt.

Equal to PAIInt(s_fqExtendingClass, a_int, (new PARInt()))

**/ public PAIInt(String s_fqExtendingClass, int[] a_int) { this(s_fqExtendingClass, a_int, (new PARInt())); } /**

Create a PAIInt.

Equal to PAIInt(sPAII, a_int)

**/ public PAIInt(int[] a_int, PARInt par_int) { this(sPAII, a_int, par_int); } /**

Create a PAIInt.

Equal to PAIInt(s_fqExtendingClass, a_int, par_int)

**/ public PAIInt(String s_fqExtendingClass, int[] a_int, PARInt par_int) { this(s_fqExtendingClass, a_int, par_int, false); } /**

Create a PAIInt.

Equal to PAIInt(sPAII, a_int, (new PARInt()), b_lock)

**/ public PAIInt(int[] a_int, boolean b_lock) { this(sPAII, a_int, (new PARInt()), b_lock); } /**

Create a PAIInt.

Equal to PAIInt(s_fqExtendingClass, a_int, (new PARInt()), b_lock)

**/ public PAIInt(String s_fqExtendingClass, int[] a_int, boolean b_lock) { this(s_fqExtendingClass, a_int, (new PARInt()), b_lock); } /**

Create an PAIInt.

Equal to PrimitiveArrayInt(s_fqExtendingClass, par_int)

@param a_int The array of ints to analyze. @param b_lock Should the int array be directly accessible, via getAOInt? If true, yes. If false, no. **/ public PAIInt(String s_fqExtendingClass, int[] a_int, PARInt par_int, boolean b_lock) { super(s_fqExtendingClass, par_int); aInt = a_int; bLocked = b_lock; } /**

Get the array of ints for direct manipulation.

@return a_int Exactly as provided to the constructor. **/ public int[] getAOInt() { throwLXIfLocked(isLocked(), "getAOInt"); return aInt; } /**

Get the int at the requested array index.

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

How many elements are in this PAIInt?

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

Is the int array null?

@return (a_int == null) Where a_int is exactly as passed into the constructor. **/ public boolean isNull() { return (aInt == 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; } /**

Get a PASInt containing the same int array as exists in this class.

@return (new PASInt(a_int, isLocked())) Where a_int is exactly as passed into the constructor. **/ public final PASInt getPASInt() { return (new PASInt(aInt, isLocked())); } //Required by LockOneWay...START public final void lock() { bLocked = true; } public final boolean isLocked() { return bLocked; } //Required by LockOneWay...END }