private Array appendArrayToArray (Array arrayToAppendTo, Array arrayToAdd) {
private ArrayInterface appendArrayToArray ( ArrayInterface arrayToAppendTo, ArrayInterface arrayToAdd ) {
    private Array appendArrayToArray (Array arrayToAppendTo, Array arrayToAdd) {       if (arrayToAppendTo != null)        {          List origAxisList = arrayToAppendTo.getAxes();           List addAxisList = arrayToAdd.getAxes();           Hashtable correspondingAddAxis = new Hashtable();          Hashtable correspondingOrigAxis = new Hashtable();          // 1. determine the proper alignment of the axes between both arrays          //    Then cross-reference each in lookup Hashtables.          Iterator iter = origAxisList.iterator();          while (iter.hasNext()) {             AxisInterface origAxis = (AxisInterface) iter.next();             String align = origAxis.getAlign();             // search the list of the other array for a matching axis              boolean gotAMatch = false;             Iterator iter2 = addAxisList.iterator();             while (iter2.hasNext())              {                AxisInterface addAxis = (AxisInterface) iter2.next();                String thisAlign = addAxis.getAlign();                 if(thisAlign != null)                  {                    if(thisAlign.equals(align))                     {                       correspondingAddAxis.put(origAxis.getAxisId(), addAxis);                       correspondingOrigAxis.put(addAxis.getAxisId(), origAxis);                       gotAMatch = true;                       break;                    }                 } else {                     Log.errorln("Cant align axes, axis missing defined align attribute. Aborting.");                    return arrayToAppendTo;                 }             }             // no match?? then alignments are mis-specified.             if (!gotAMatch) {                Log.errorln("Cant align axes, axis has align attribute that is mis-specified. Aborting.");                return arrayToAppendTo;             }          }                 // 2. "Append" axis values to original axis. Because          // there are 2 different ways to add in data we either          // have a pre-existing axis value, in which case we dont          // need to expand the existing axis, or there is no pre-existing          // value so we tack it in. We need to figure out here if an          // axis value already exists, and if it doesnt then we add it in.           //          Iterator iter3 = origAxisList.iterator();          while (iter3.hasNext())           {             AxisInterface origAxis = (AxisInterface) iter3.next();             AxisInterface addAxis = (AxisInterface) correspondingAddAxis.get(origAxis.getAxisId());             if (addAxis instanceof Axis && origAxis instanceof Axis)              {                List valuesToAdd = ((Axis) addAxis).getAxisValues();                Iterator iter4 = valuesToAdd.iterator();                while (iter4.hasNext()) {                   Value value = (Value) iter4.next();                   if (((Axis) origAxis).getIndexFromAxisValue(value) == -1) {                      ((Axis) origAxis).addAxisValue(value);                   }                }             } else if (addAxis instanceof FieldAxis && origAxis instanceof FieldAxis) {                  // both are fieldAxis                Log.errorln("Dont know how to merge field Axis data. Aborting.");                System.exit(-1);             } else {                // mixed class Axes?? (e.g. a fieldAxis id matches Axis id??!? Error!!)                Log.errorln("Dont know how to merge data. Aborting.");                System.exit(-1);             }          }          // 3. Append data from one array to the other appropriately           Locator origLocator = arrayToAppendTo.createLocator();          Locator addLocator = arrayToAdd.createLocator();          while (addLocator.hasNext())           {             try {                // retrieve the data                Object data = arrayToAdd.getData(addLocator);                                // set up the origLocator                List locatorAxisList = addLocator.getIterationOrder();                Iterator iter5 = locatorAxisList.iterator();                Log.debug("Appending data to array(");                while (iter5.hasNext()) {                   Axis addAxis = (Axis) iter5.next();                   Value thisAxisValue = addLocator.getAxisValue(addAxis);                    Axis thisAxis = (Axis) correspondingOrigAxis.get(addAxis.getAxisId());                    try {                      origLocator.setAxisIndexByAxisValue(thisAxis, thisAxisValue);                      Log.debug(origLocator.getAxisIndex(thisAxis)+",");                   } catch (AxisLocationOutOfBoundsException e) {                       Log.errorln("Weird axis out of bounds error for append array.");                   }                }                // add in the data as appropriate.                Log.debugln(") => ["+data.toString()+"]");                try {                   if (data instanceof Double)                        arrayToAppendTo.setData(origLocator, (Double) data);                   else if (data instanceof Integer)                        arrayToAppendTo.setData(origLocator, (Integer) data);                   else if (data instanceof String )                        arrayToAppendTo.setData(origLocator, (String) data);                   else                       Log.errorln("Cant understand class of data !(Double|Integer|String). ignoring append");                } catch (SetDataException e) {                   Log.errorln("Cant setData. Ignoring append");                }             } catch (NoDataException e) {                // do nothing for NoDataValues??             }             addLocator.next(); // go to next location          }                } else           Log.errorln("Cannot append to null array. Ignoring request.");       return arrayToAppendTo;    }