int myValue = convertBytesToInteger (bytes_to_add, endian, data, bytes_added); CurrentArray.setData(location, myValue);
switch (bytes_to_add) {  case 1: { short val = convert1byteToShort (data, bytes_added); CurrentArray.setData(location, val); break; }  case 2: { short val = convert2bytesToShort (endian, data, bytes_added); CurrentArray.setData(location, val); break; }  case 3: { int val = convert3bytesToInt (endian, data, bytes_added); CurrentArray.setData(location, val); break; }  case 4: { int val = convert4bytesToInt (endian, data, bytes_added); CurrentArray.setData(location, val); break; }  case 8: { 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);  }
    private void addByteDataToCurrentArray (Locator location, byte[] data, int amount, String endian)     throws SetDataException    {        ArrayList commandList = (ArrayList) ((FormattedXMLDataIOStyle) CurrentArray.getXMLDataIOStyle()).getFormatCommands();        int nrofIOCmd = commandList.size();        int bytes_added = 0;        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();               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+"]");                   addDataToCurrentArray(location, thisData.trim(), currentDataFormat, IntRadix[CurrentDataFormatIndex]);               } 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+"]");                   addDataToCurrentArray(location, thisData, currentDataFormat, IntRadix[CurrentDataFormatIndex]);               } 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) {//  Integer myValue = convert2bytesToInteger (endian, data, bytes_added);// Log.errorln("Got Href Data Integer:["+myValue.toString()+ "]["+bytes_added+"]["+bytes_to_add+"]");                  // int numOfBytes = ((BinaryIntegerDataFormat) currentDataFormat).numOfBytes();                  int myValue = convertBytesToInteger (bytes_to_add, endian, data, bytes_added);                  CurrentArray.setData(location, myValue);               }                // 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++;        }    }