# Class VCFRecordCodec

java.lang.Object
htsjdk.variant.vcf.VCFRecordCodec

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

public class VCFRecordCodec extends Object implements SortingCollection.Codec<VariantContext>
Writes VariantContext instances to an OutputStream without headers or metadata. For use with SortingCollection ONLY.

## Constructor Summary

Constructors
Constructor
Description
`VCFRecordCodec(VCFHeader header)`
`VCFRecordCodec(VCFHeader header, boolean allowMissingFieldsInHeader)`

## Method Summary

Modifier and Type
Method
Description
`VCFRecordCodec`
`clone()`
Must return a cloned copy of the codec that can be used independently of the original instance.
`VariantContext`
`decode()`
Read the next record from the input stream and convert into a java object.
`void`
`encode(VariantContext context)`
Write object to output stream
`void`
`setInputStream(InputStream stream)`
Where to read encoded input from
`void`
`setOutputStream(OutputStream stream)`
Where to write encoded output

### Methods inherited from class Object

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

## Constructor Details

### VCFRecordCodec

public VCFRecordCodec(VCFHeader header)

### VCFRecordCodec

public VCFRecordCodec(VCFHeader header, boolean allowMissingFieldsInHeader)

## Method Details

### setOutputStream

public void setOutputStream(OutputStream stream)
Description copied from interface: `SortingCollection.Codec`
Where to write encoded output

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

### setInputStream

public void setInputStream(InputStream stream)
Description copied from interface: `SortingCollection.Codec`
Where to read encoded input from

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

### encode

public void encode(VariantContext context)
Description copied from interface: `SortingCollection.Codec`
Write object to output stream

Specified by:
  `encode` in interface `SortingCollection.Codec<VariantContext>`
Parameters:
  `context` - what to write

### decode

public VariantContext decode()
Description copied from interface: `SortingCollection.Codec`
Read the next record from the input stream and convert into a java object.

Specified by:
  `decode` in interface `SortingCollection.Codec<VariantContext>`
Returns:
  null if no more records. Should throw exception if EOF is encountered in the middle of a record.

### clone

public VCFRecordCodec 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<VariantContext>`
Overrides:
  `clone` in class `Object`