# Class BAMFileReader.BAMQueryFilteringIterator

java.lang.Object
htsjdk.samtools.BAMFileReader.BAMQueryFilteringIterator

All Implemented Interfaces:
  `CloseableIterator<SAMRecord>, Closeable, AutoCloseable, Iterator<SAMRecord>`

Enclosing class:
  `BAMFileReader`

public class BAMFileReader.BAMQueryFilteringIterator extends Object
Pull SAMRecords from a coordinate-sorted iterator, and filter out any that do not match the filter.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected SAMRecord`
`mNextRecord`
The next record to be returned.
`protected final CloseableIterator<SAMRecord>`
`wrappedIterator`
The wrapped iterator.

## Constructor Summary

Constructors
Constructor
Description
`BAMQueryFilteringIterator(CloseableIterator<SAMRecord> iterator, htsjdk.samtools.BAMIteratorFilter iteratorFilter)`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`assertOpen()`
`void`
`close()`
Should be implemented to close/release any underlying resources.
`boolean`
`hasNext()`
Returns true if a next element exists; false otherwise.
`SAMRecord`
`next()`
Gets the next record from the given iterator.
`void`
`remove()`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface CloseableIterator

`stream, toList`

### Methods inherited from interface Iterator

`forEachRemaining`

## Field Details

### wrappedIterator

protected final CloseableIterator<SAMRecord> wrappedIterator
The wrapped iterator.

### mNextRecord

protected SAMRecord mNextRecord
The next record to be returned. Will be null if no such record exists.

## Constructor Details

### BAMQueryFilteringIterator

public BAMQueryFilteringIterator(CloseableIterator<SAMRecord> iterator, htsjdk.samtools.BAMIteratorFilter iteratorFilter)

## Method Details

### hasNext

public boolean hasNext()
Returns true if a next element exists; false otherwise.

### next

public SAMRecord next()
Gets the next record from the given iterator.

Returns:
  The next SAM record in the iterator.

### close

public void close()
Description copied from interface: `CloseableIterator`
Should be implemented to close/release any underlying resources.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `CloseableIterator<SAMRecord>`

### assertOpen

protected void assertOpen()

### remove

public void remove()

Specified by:
  `remove` in interface `Iterator<SAMRecord>`