# Class FressianWriter

java.lang.Object
org.fressian.FressianWriter

All Implemented Interfaces:
  `Closeable, AutoCloseable, StreamingWriter, Writer`

public class FressianWriter extends Object implements StreamingWriter, Writer, Closeable

## Constructor Summary

Constructors
Constructor
Description
`FressianWriter(OutputStream out)`
`FressianWriter(OutputStream out, ILookup<Class, Map<String, WriteHandler>> userHandlers)`
Create a writer that combines userHandlers with the normal type handlers built into Fressian.

## Method Summary

Modifier and Type
Method
Description
`Writer`
`beginClosedList()`
Begin a variable-length closed list.
`Writer`
`beginOpenList()`
Begin a variable-length open list.
`void`
`close()`
`Writer`
`endList()`
Mark the end of a variable-lenght list, either closed or open.
`InterleavedIndexHopMap`
`getPriorityCache()`
`InterleavedIndexHopMap`
`getStructCache()`
`Writer`
`resetCaches()`
`Writer`
`writeAs(String tag, Object o)`
`Writer`
`writeAs(String tag, Object o, boolean cache)`
`Writer`
`writeBoolean(boolean b)`
`Writer`
`writeBoolean(Object o)`
`Writer`
`writeBytes(byte[] b)`
`Writer`
`writeBytes(byte[] b, int offset, int length)`
`void`
`writeCode(int code)`
`void`
`writeCount(int count)`
`Writer`
`writeDouble(double d)`
`Writer`
`writeDouble(Object o)`
`Writer`
`writeExt(Object tag, Object... fields)`
`Writer`
`writeFloat(float f)`
`Writer`
`writeFloat(Object o)`
`Writer`
`writeFooter()`
`void`
`writeFooterFor(ByteBuffer bb)`
Write a footer for some existing fressianed data (the readable portion of bb.) For advanced use when building a larger fressianed stream from existing content.
`Writer`
`writeInt(long i)`
`Writer`
`writeInt(Object o)`
`Writer`
`writeList(Object o)`
`Writer`
`writeNull()`
`Writer`
`writeObject(Object o)`
`Writer`
`writeObject(Object o, boolean cache)`
`Writer`
`writeString(Object o)`
`Writer`
`writeTag(Object tag, int componentCount)`

### Methods inherited from class Object

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

## Constructor Details

### FressianWriter

public FressianWriter(OutputStream out)

### FressianWriter

public FressianWriter(OutputStream out, ILookup<Class, Map<String, WriteHandler>> userHandlers)
Create a writer that combines userHandlers with the normal type handlers built into Fressian.

## Method Details

### writeNull

public Writer writeNull() throws IOException

Specified by:
  `writeNull` in interface `Writer`
Throws:
  `IOException`

### writeBoolean

public Writer writeBoolean(boolean b) throws IOException

Specified by:
  `writeBoolean` in interface `Writer`
Throws:
  `IOException`

### writeBoolean

public Writer writeBoolean(Object o) throws IOException

Specified by:
  `writeBoolean` in interface `Writer`
Throws:
  `IOException`

### writeInt

public Writer writeInt(long i) throws IOException

Specified by:
  `writeInt` in interface `Writer`
Throws:
  `IOException`

### writeInt

public Writer writeInt(Object o) throws IOException

Specified by:
  `writeInt` in interface `Writer`
Throws:
  `IOException`

### writeDouble

public Writer writeDouble(double d) throws IOException

Specified by:
  `writeDouble` in interface `Writer`
Throws:
  `IOException`

### writeDouble

public Writer writeDouble(Object o) throws IOException

Specified by:
  `writeDouble` in interface `Writer`
Throws:
  `IOException`

### writeFloat

public Writer writeFloat(float f) throws IOException

Specified by:
  `writeFloat` in interface `Writer`
Throws:
  `IOException`

### writeFloat

public Writer writeFloat(Object o) throws IOException

Specified by:
  `writeFloat` in interface `Writer`
Throws:
  `IOException`

### writeString

public Writer writeString(Object o) throws IOException

Specified by:
  `writeString` in interface `Writer`
Throws:
  `IOException`

### writeList

public Writer writeList(Object o) throws IOException

Specified by:
  `writeList` in interface `Writer`
Throws:
  `IOException`

### writeBytes

public Writer writeBytes(byte[] b) throws IOException

Specified by:
  `writeBytes` in interface `Writer`
Throws:
  `IOException`

### writeBytes

public Writer writeBytes(byte[] b, int offset, int length) throws IOException

Specified by:
  `writeBytes` in interface `Writer`
Throws:
  `IOException`

### writeFooterFor

public void writeFooterFor(ByteBuffer bb) throws IOException
Description copied from interface: `StreamingWriter`
Write a footer for some existing fressianed data (the readable portion of bb.) For advanced use when building a larger fressianed stream from existing content.

Specified by:
  `writeFooterFor` in interface `StreamingWriter`
Parameters:
  `bb` -
Throws:
  `IOException`

### writeFooter

public Writer writeFooter() throws IOException

Specified by:
  `writeFooter` in interface `Writer`
Throws:
  `IOException`

### resetCaches

public Writer resetCaches() throws IOException

Specified by:
  `resetCaches` in interface `Writer`
Throws:
  `IOException`

### getPriorityCache

public InterleavedIndexHopMap getPriorityCache()

### getStructCache

public InterleavedIndexHopMap getStructCache()

### writeTag

public Writer writeTag(Object tag, int componentCount) throws IOException

Specified by:
  `writeTag` in interface `Writer`
Throws:
  `IOException`

### writeExt

public Writer writeExt(Object tag, Object... fields) throws IOException

Throws:
  `IOException`

### writeCount

public void writeCount(int count) throws IOException

Throws:
  `IOException`

### writeAs

public Writer writeAs(String tag, Object o, boolean cache) throws IOException

Specified by:
  `writeAs` in interface `Writer`
Throws:
  `IOException`

### writeAs

public Writer writeAs(String tag, Object o) throws IOException

Specified by:
  `writeAs` in interface `Writer`
Throws:
  `IOException`

### writeObject

public Writer writeObject(Object o, boolean cache) throws IOException

Specified by:
  `writeObject` in interface `Writer`
Throws:
  `IOException`

### writeObject

public Writer writeObject(Object o) throws IOException

Specified by:
  `writeObject` in interface `Writer`
Throws:
  `IOException`

### writeCode

public void writeCode(int code) throws IOException

Throws:
  `IOException`

### close

public void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Throws:
  `IOException`

### beginClosedList

public Writer beginClosedList() throws IOException
Description copied from interface: `StreamingWriter`
Begin a variable-length closed list. This allows you (the writer) to write very large things, or things of unknown size, without having to place them in a collection first. However, you must remember to call endList when you are done, or the resulting stream will not be readable.

Specified by:
  `beginClosedList` in interface `StreamingWriter`
Returns:
  this Writer (fluent)
Throws:
  `IOException`

### endList

public Writer endList() throws IOException
Description copied from interface: `StreamingWriter`
Mark the end of a variable-lenght list, either closed or open.

Specified by:
  `endList` in interface `StreamingWriter`
Returns:
  this Writer (fluent)
Throws:
  `IOException`

### beginOpenList

public Writer beginOpenList() throws IOException
Description copied from interface: `StreamingWriter`
Begin a variable-length open list. An open list can be terminated either by a call to endList, *or* by an end of stream. Using an open is much more subtle than either a fixed or closed variable list. Avoid it if either other choice can work.

Specified by:
  `beginOpenList` in interface `StreamingWriter`
Returns:
  this Writer (fluent)
Throws:
  `IOException`