String strValue = new String(data, bytes_added, bytes_to_add); Log.debugln("AddByteData READCELL string(off:"+bytes_added+" len:"+bytes_to_add+") => ["+strValue+"]");
    private void addByteDataToCurrentArray ( Locator location,                                              byte[] data,                                              int startByte,                                              int endByte,                                              int amount,                                              String endian                                           ) //    throws SetDataException    throws SAXException    {        ArrayList commandList = (ArrayList)               ((FormattedXMLDataIOStyle) CurrentArray.getXMLDataIOStyle()).getFormatCommands();        int nrofIOCmd = commandList.size();        int bytes_added = startByte;        if (endByte > 0 && amount > endByte)            amount = endByte;        try {           while (bytes_added < amount) {                  FormattedIOCmd currentIOCmd = (FormattedIOCmd) commandList.get(CurrentIOCmdIndex);                  // readCell               if (currentIOCmd instanceof ReadCellFormattedIOCmd) {                     DataFormat currentDataFormat = DataFormatList[CurrentDataFormatIndex];                  int bytes_to_add = currentDataFormat.numOfBytes();   //   String strValue = new String(data, bytes_added, bytes_to_add);//   Log.errorln("AddByteData READCELL string(off:"+bytes_added+" len:"+bytes_to_add+") => ["+strValue+"]");                     if ( currentDataFormat instanceof IntegerDataFormat                       || currentDataFormat instanceof FloatDataFormat                     ) {                         String thisData = new String(data,bytes_added,bytes_to_add);//   Log.errorln("Got Href Formatted Number Data:["+thisData.trim()+ "]["+bytes_added+"]["+bytes_to_add+"]");                         try {                         addDataToCurrentArray(location, thisData.trim(), currentDataFormat, IntRadix[CurrentDataFormatIndex]);                      } catch (SetDataException e) {                         throw new SetDataException("Unable to setData:["+thisData+"], ignoring request"+e.getMessage());                      }                     } else if (currentDataFormat instanceof StringDataFormat) {                         String thisData = new String(data,bytes_added,bytes_to_add);//   Log.errorln("Got Href Formatted Character Data:["+thisData+ "]["+bytes_added+"]["+bytes_to_add+"]");                         try {                         addDataToCurrentArray(location, thisData, currentDataFormat, IntRadix[CurrentDataFormatIndex]);                      } catch (SetDataException e) {                         throw new SetDataException("Unable to setData:["+thisData+"], ignoring request"+e.getMessage());                      }                        } else if (currentDataFormat instanceof BinaryFloatDataFormat) {                        if (bytes_to_add == 4) {                              float myValue = convert4bytesToFloat(endian, data, bytes_added);   //Log.errorln("Got Href Data BFloatSingle:["+myValue.toString()+"]["+bytes_added+"]["+bytes_to_add+"]");                        CurrentArray.setData(location, myValue);                        } else if (bytes_to_add == 8) {       // Log.errorln("Got Href Data BFloatDouble:["+myValue.toString()+"]["+bytes_added+"]["+bytes_to_add+"]");                        double myValue = convert8bytesToDouble(endian, data, bytes_added);                        CurrentArray.setData(location, myValue);                        } else {                        Log.errorln("Error: got floating point with bit size != (32|64). Ignoring data.");                     }                     } else if (currentDataFormat instanceof BinaryIntegerDataFormat) {      // short myValue = convert2bytesToShort (endian, data, bytes_added);   // Log.errorln("Got Href Data Integer:["+myValue+ "]["+bytes_added+"]["+bytes_to_add+"]");                        // int numOfBytes = ((BinaryIntegerDataFormat) currentDataFormat).numOfBytes();                     // int myValue = convertBytesToInteger (bytes_to_add, endian, data, bytes_added);                     // CurrentArray.setData(location, myValue);                        // is it better to use a dispatch table here?                     switch (bytes_to_add)                      {                           case 1: { // 8-bit                            short val = convert1byteToShort (data, bytes_added);                           CurrentArray.setData(location, val);                           break;                        }                           case 2: { // 16-bit                            short val = convert2bytesToShort (endian, data, bytes_added);                           CurrentArray.setData(location, val);                           break;                        }                           case 3: { // 24-bit (unusual)                            int val = convert3bytesToInt (endian, data, bytes_added);                           CurrentArray.setData(location, val);                           break;                        }                           case 4: { // 32-bit                           int val = convert4bytesToInt (endian, data, bytes_added);                           CurrentArray.setData(location, val);                           break;                        }                           case 8: { // 64-bit                            long val = convert8bytesToLong (endian, data, bytes_added);                           CurrentArray.setData(location, val);                           break;                        }                           default:                           Log.errorln("XDF Can't handle binary integers of byte size:"+bytes_to_add+". Aborting!");                           System.exit(-1);                        }                     }                      // advance the data pointer to next location                  location.next();                     // advance our global pointer to the current DataFormat                  if (NrofDataFormats > 1)                     if (CurrentDataFormatIndex == (NrofDataFormats - 1))                        CurrentDataFormatIndex = 0;                     else                        CurrentDataFormatIndex++;                      bytes_added += bytes_to_add;                  } else if (currentIOCmd instanceof SkipCharFormattedIOCmd) {                                     Integer bytes_to_skip = ((SkipCharFormattedIOCmd) currentIOCmd).getCount();                   bytes_added += bytes_to_skip.intValue();                  } else if (currentIOCmd instanceof RepeatFormattedIOCmd) {                  // shouldnt happen                  Log.errorln("Argh getFormatCommands not working right, got repeat command in addByteData!!!");                  System.exit(-1);               }                  // advance our global pointer to the current IOCmd               if (nrofIOCmd> 1)                 if (CurrentIOCmdIndex == (nrofIOCmd - 1))                    CurrentIOCmdIndex = 0;                 else                    CurrentIOCmdIndex++;              }        } catch (SetDataException e) {           throw new SAXException("Failed to load external data at byte_read:"+bytes_added+" msg:"+e.getMessage());        }    }