newArray[k]=oldArray[k]; current.set(newCoordinate+1, newArray);
newArray[k]=oldArray[k]; current.set(1, newArray);
   public double  setData (Locator locator, double numValue) throws SetDataException{    List axisList = parentArray.getAxisList();    List prev = data;    List current = data;    int numOfAxis = axisList.size();    if (numOfAxis == 1) {      Axis axis = (Axis) axisList.get(0);      int index = locator.getAxisLocation(axis);      if (data.get(0) == null) {        //used to track if the corresponding cell stores valid data        data.set(0,new byte[axis.getLength()]);        data.set(1,new double[axis.getLength()]);      }      int arrayLength = ((byte[]) data.get(0)).length;      if ( arrayLength< index+1) {  //have to expand the array        int toExpandLength = (int) (arrayLength*1.3)+1;  //use 1.3 as the size multiplier        if (toExpandLength < index) {  //expand to the size of index (index > arrayLength*1.3)          toExpandLength = index+1;        }        //copy the old byte array into the expanded one        byte[] oldByteArray = (byte[]) current.get(0);        byte[] newByteArray = new byte[toExpandLength];        for (int k = 0; k <oldByteArray.length; k++)          newByteArray[k]=oldByteArray[k];        current.set(0, newByteArray);        oldByteArray = null; //force garbage collection        //copy the old int array into the expanded one        double[] oldArray = (double[]) current.get(1);        double[] newArray = new double[toExpandLength];        for (int k = 0; k <oldArray.length; k++)        newArray[k]=oldArray[k];        current.set(1, newArray);        oldArray = null; //force garbage collection      }      try {        //indicates its corresponding data cell holds vaid data        java.lang.reflect.Array.setByte(current.get(0), index, Byte.parseByte("1"));        //put the data into the requested data cell        java.lang.reflect.Array.setDouble(current.get(1), index, numValue);        return numValue;      }      catch (Exception e) {        throw new SetDataException();      }    } //  end of if (numOfAxis == 1)    //contructs arraylist of arraylist to represent the multi-dimension    for (int i = 0; i < numOfAxis-2; i++) {      Axis axis = (Axis) axisList.get(i);      int index =  locator.getAxisLocation(axis);      int end = axis.getLength() - prev.size();      for (i = 0; i < end ; i++)  //expand it if prev.size < index+1        prev.add(null);      current = (List) prev.get(index);      if (current == null) {  //expand the datacube        int length = ((Axis) axisList.get(i+1)).getLength();        current = new ArrayList(length);        for (int j = 0; j < length; j++)          current.add(null);        prev.set(index, current);      }      prev = current;    }    //special handling of the inner most two dimensions    Axis lastTo2ndAxis = (Axis) axisList.get(numOfAxis-2);    Axis lastAxis = (Axis) axisList.get(numOfAxis-1);    int index0 = locator.getAxisLocation(lastTo2ndAxis );    int index1 = locator.getAxisLocation(lastAxis );    int stop = 2*(index0+1)-current.size();    for (int i = 0; i<stop; i++) {  //expand it if current.size < 2*(index0+1)        current.add(null);    }    int newCoordinate = 2*index0;  //internal index  = 2*index0    if (current.get(newCoordinate) == null) {      //expand array of byte and int      current.set(newCoordinate, new byte[lastAxis.getLength()]);      current.set(newCoordinate+1, new double[lastAxis.getLength()]);    }    int arrayLength = ((double[]) current.get(newCoordinate+1)).length;    if ( arrayLength< index1+1) {  ////have to expand the array      int toExpandLength = (int) (arrayLength*1.3)+1;      if (toExpandLength < index1) {        toExpandLength = index1+1;      }      //copy old byte array to the expanded new one      byte[] oldByteArray = (byte[]) current.get(newCoordinate);      byte[] newByteArray = new byte[toExpandLength];      for (int k = 0; k <oldByteArray.length; k++)      newByteArray[k]=oldByteArray[k];      current.set(newCoordinate, newByteArray);      oldByteArray = null; //force garbage collection      //copy old int array to the expanded new one      double[] oldArray = (double[]) current.get(newCoordinate+1);      double[] newArray = new double[toExpandLength];      for (int k = 0; k <oldArray.length; k++)      newArray[k]=oldArray[k];      current.set(newCoordinate+1, newArray);      oldArray = null; //force garbage collection    }    try { //set data      byte realValue = 1;      //indicate its corresponding datacell holds valid data      java.lang.reflect.Array.setByte(current.get(newCoordinate), index1, realValue);      //put data into the requested datacell      java.lang.reflect.Array.setDouble(current.get(newCoordinate+1), index1, numValue);      return numValue;    }    catch (Exception e) {      throw new SetDataException();    }  }