/** * Read the next record from the input stream and convert into a java object. * * @return null if no more records. Should throw exception if EOF is encountered in the middle of * a record. */ @Override public SAMRecord decode() { final Integer recordLength = decodeRecordLength(); if (recordLength == null) { return null; } return decode(recordLength); }
/** * Read the next record from the input stream. */ private BamRecordDecodingInfo readNextRecord() { try { if (!advanceToNextRecordStart()) { // effectively end of stream return null; } final long startCoordinate = mCompressedInputStream.getFilePointer(); Integer readLength = bamRecordCodec.decodeRecordLength(); if (readLength == null) { // EOF returns null read length return null; } else { if (useAsynchronousIO) { byte[] buffer = new byte[readLength]; mCompressedInputStream.read(buffer); long stopCoordinate = mCompressedInputStream.getFilePointer(); return new BamRecordDecodingInfo(++streamSamRecordIndex, readLength, startCoordinate, stopCoordinate, buffer); } else { return new BamRecordDecodingInfo(++streamSamRecordIndex, readLength, startCoordinate); } } } catch (IOException e) { throw new RuntimeIOException(e); } }