/* 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; /**
As PrimitiveArrayString that wraps around an array of ints.
Source code: PASInt.java.
To shorten code and Javadoc.
Equal to "xbn.array.primitive.PASInt"
**/ public static final String sPASI = "xbn.array.primitive.PASInt"; private int[] aInt = null; private boolean bLocked = false; /**Create a PASInt with default values.
Equal to PASInt(null)
Create a PASInt.
**/ public PASInt(int[] a_int) { this(sPASI, a_int); } /**Create a PASInt.
Equal to PASInt(s_fqExtendingClass, a_int, (new PARString())))
Create a PASInt.
Equal to PASInt(sPASI, a_int, par_string)
Create a PASInt.
Equal to PASInt(s_fqExtendingClass, a_int, par_string, false)
Create a PASInt.
Equal to PASInt(sPASI, a_int, (new PARString()), b_lock)
Create a PASInt.
Equal to PASInt(s_fqExtendingClass, a_int, (new PARString()), b_lock)
Create an PASInt.
The first line of this constructor calls PrimitiveArrayInt(s_fqExtendingClass, par_string)
Get the int array for direct manipulation.
@return a_int Exactly as provided to the constructor. @exception LockedException If isLocked equals true. **/ public final int[] getAOInt() { throwLXIfLocked(isLocked(), "getAOInt"); return aInt; } /**Get the (int translated to a) string at the requested array index.
@param i_dx The array index. Must range 0..[getLength() - 1]
, inclusive
**/
public final String getString(int i_dx) {
try {
return (new Integer(aInt[i_dx])).toString();
} catch(NullPointerException npx) {
throwAX("getString: isNull() equals true.");
} catch(ArrayIndexOutOfBoundsException aioobx) {
throwAX("getString: i_dx (" + i_dx + ") is invalid. getLength()=" + getLength() + ".");
}
//Never reached. Required for compile.
return null;
}
/**
How many elements exist in this PASInt?
@returna_int.length
Where a_int is exactly as provided to the constructor.
@exception AssertException If isNull equals true.
**/
public final int getLength() {
try {
return aInt.length;
} catch(NullPointerException npx) {
throwAX("getLength: isNull() equals true.");
}
//Never reached. Required for compile.
return -1;
}
/**
Is the array null?
@return(a_int == null)
Where a_int is exactly as provided to the constructor.
**/
public final boolean isNull() {
return (aInt == null);
}
/**
Is the int at the requested array index null?
@return false An int can never be null. **/ public final boolean isNull(int i_dx) { return false; } /**Get a new PAIInt from the internally held int array.
@return(new PAIInt(getFQClassName(),aInt, isLocked()))
**/
public final PAIInt getPAIInt() {
return (new PAIInt(getFQClassName(),aInt, isLocked()));
}
//Required by LockOneWay...START
public final void lock() {
bLocked = true;
}
public final boolean isLocked() {
return bLocked;
}
//Required by LockOneWay...END
}