// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1:
import java.lang.reflect.Array ;
/**
* Utility class to deal with arrays
*/
public class ArrayWrapper extends RJavaArrayIterator {
/**
* is this array rectangular
*/
private boolean isRect ;
/**
* The type name of the objects stored
*/
private String typeName ;
/**
* true if the array stores primitive types
*/
private boolean primitive ;
private int length ;
/**
* Constructor
*
* @param array the array to check
* @throws NotAnArrayException if array is not an array
*/
public ArrayWrapper(Object array) throws NotAnArrayException {
super( RJavaArrayTools.getDimensions(array) );
this.array = array ;
typeName = RJavaArrayTools.getObjectTypeName(array );
primitive = RJavaArrayTools.isPrimitiveTypeName( typeName ) ;
if( dimensions.length == 1){
isRect = true ;
} else{
isRect = isRectangular_( array, 0 );
}
// reset the dimensions if the array is not rectangular
if( !isRect ){
dimensions = null ;
length = -1;
} else{
length = 1;
for( int i=0; i