String[] noDataValues )
String[] noDataValues, boolean writeCDATAStatement )
   private void writeFormattedData(OutputStream outputstream ,                                   Locator locator,                                   FormattedXMLDataIOStyle readObj,                                   AxisInterface fastestAxis,                                   String[] noDataValues )   {      // print opening CDATA statement      writeOut(outputstream, "<![CDATA[");      // print out the data as appropriate for the format      // QUESTION: don't we need to syncronize on readObj too?      synchronized (data)       {         List commands = readObj.getCommands(); // returns expanded list (no repeat cmds)         int nrofCommands = commands.size();        int currentCommand = 0;        DataFormat dataFormats[] = parentArray.getDataFormatList();         int nrofDataFormats = dataFormats.length;        int currentDataFormat = 0;        // loop thru all of the dataCube until finished with all data and commands         boolean atEndOfDataCube = false;        boolean backToStartOfDataCube = false;        while (!backToStartOfDataCube)        {              FormattedIOCmd command = (FormattedIOCmd) commands.get(currentCommand);             if(atEndOfDataCube && locator.getAxisLocation(fastestAxis) == 0)                  backToStartOfDataCube = true;             if (command instanceof ReadCellFormattedIOCmd)             {                if (backToStartOfDataCube) break; // dont bother, we'd be re-printing data                 try {                   doReadCellFormattedIOCmdOutput( outputstream,                                                   dataFormats[currentDataFormat],                                                   locator );                } catch (NoDataException e) {                    // no data here, hurm. Print the noDataValue.                     // Is this always appropriate, seems questionable? -b.t.                     String noData = noDataValues[locator.getAxisLocation(fastestAxis)];                    if (noData != null)                         writeOut(outputstream, noData);                    else                       Log.errorln("Cant print out null data: noDataValue NOT defined.");                }                // advance the data location                 locator.next();                // advance the DataFormat to be used                  if(nrofDataFormats > 1)                {                   currentDataFormat++;                   if ( currentDataFormat == nrofDataFormats)                      currentDataFormat = 0;                }             }             else if (command instanceof SkipCharFormattedIOCmd)             {                doSkipCharFormattedIOCmdOutput ( outputstream, (SkipCharFormattedIOCmd) command);             }             else             {                Log.errorln("DataCube cannot write out, unimplemented format command:"+                              command.toString());                System.exit(-1);             }             if(nrofCommands > 1)             {                 currentCommand++;                if ( currentCommand == nrofCommands) {                    currentCommand = 0;                }             }             if(!atEndOfDataCube && !locator.hasNext()) atEndOfDataCube = true;         } // end of while loop       } // end of sync loop      // print closing CDATA statement      writeOut(outputstream, "]]>");   }