class ReadRecordsRespPars extends AbstractPoResponseParser {

  public SortedMap<Integer, byte[]> getRecords() {
    SortedMap<Integer, byte[]> records = new TreeMap<Integer, byte[]>();
    if (((ReadRecordsCmdBuild) builder).getReadMode() == ReadRecordsCmdBuild.ReadMode.ONE_RECORD) {
      records.put(((ReadRecordsCmdBuild) builder).getFirstRecordNumber(), response.getDataOut());
    } else {
      byte[] apdu = response.getDataOut();
      int apduLen = apdu.length;
      int index = 0;
      while (apduLen > 0) {
        byte recordNb = apdu[index++];
        byte len = apdu[index++];
        records.put((int) recordNb, Arrays.copyOfRange(apdu, index, index + len));
        index = index + len;
        apduLen = apduLen - 2 - len;
      }
    }
    return records;
  }

  public  ReadRecordsRespPars(ApduResponse apduResponse, ReadRecordsCmdBuild builder);

}