# Class IntervalCodec

java.lang.Object
htsjdk.samtools.util.IntervalCodec

All Implemented Interfaces:
  `SortingCollection.Codec<Interval>, Cloneable`

public class IntervalCodec extends Object implements SortingCollection.Codec<Interval>

## Constructor Summary

Constructors
Constructor
Description
`IntervalCodec(SAMSequenceDictionary dict)`
Creates a new binary codec to read or write.

## Method Summary

Modifier and Type
Method
Description
`IntervalCodec`
`clone()`
Must return a cloned copy of the codec that can be used independently of the original instance.
`Interval`
`decode()`
Reads an interval from the input stream.
`void`
`encode(Interval interval)`
Writes the interval to the output stream.
`void`
`setInputStream(InputStream is)`
Sets the input stream that records will be read from.
`void`
`setInputStream(InputStream is, String filename)`
Sets the input stream that records will be read from.
`void`
`setOutputStream(OutputStream os)`
Sets the output stream that records will be written to.
`void`
`setOutputStream(OutputStream os, String filename)`
Sets the output stream that records will be written to.

### Methods inherited from class Object

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

## Constructor Details

### IntervalCodec

public IntervalCodec(SAMSequenceDictionary dict)
Creates a new binary codec to read or write.

Parameters:
  `dict` - the sequence dictionary associated with the intervals.

## Method Details

### clone

public IntervalCodec clone()
Description copied from interface: `SortingCollection.Codec`
Must return a cloned copy of the codec that can be used independently of the original instance. This is required so that multiple codecs can exist simultaneously that each is reading a separate file.

Specified by:
  `clone` in interface `SortingCollection.Codec<Interval>`
Overrides:
  `clone` in class `Object`

### setOutputStream

public void setOutputStream(OutputStream os)
Sets the output stream that records will be written to.

Specified by:
  `setOutputStream` in interface `SortingCollection.Codec<Interval>`

### setOutputStream

public void setOutputStream(OutputStream os, String filename)
Sets the output stream that records will be written to.

### setInputStream

public void setInputStream(InputStream is)
Sets the input stream that records will be read from.

Specified by:
  `setInputStream` in interface `SortingCollection.Codec<Interval>`

### setInputStream

public void setInputStream(InputStream is, String filename)
Sets the input stream that records will be read from.

### encode

public void encode(Interval interval)
Writes the interval to the output stream.

Specified by:
  `encode` in interface `SortingCollection.Codec<Interval>`
Parameters:
  `interval` - the interval to write.

### decode

public Interval decode()
Reads an interval from the input stream.

Specified by:
  `decode` in interface `SortingCollection.Codec<Interval>`
Returns:
  null if no more intervals, otherwise the next interval.