Package org.fressian
Class FressianWriter
- java.lang.Object
-
- org.fressian.FressianWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,StreamingWriter,Writer
public class FressianWriter extends java.lang.Object implements StreamingWriter, Writer, java.io.Closeable
-
-
Constructor Summary
Constructors Constructor Description FressianWriter(java.io.OutputStream out)FressianWriter(java.io.OutputStream out, ILookup<java.lang.Class,java.util.Map<java.lang.String,WriteHandler>> userHandlers)Create a writer that combines userHandlers with the normal type handlers built into Fressian.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WriterbeginClosedList()Begin a variable-length closed list.WriterbeginOpenList()Begin a variable-length open list.voidclose()WriterendList()Mark the end of a variable-lenght list, either closed or open.InterleavedIndexHopMapgetPriorityCache()InterleavedIndexHopMapgetStructCache()WriterresetCaches()WriterwriteAs(java.lang.String tag, java.lang.Object o)WriterwriteAs(java.lang.String tag, java.lang.Object o, boolean cache)WriterwriteBoolean(boolean b)WriterwriteBoolean(java.lang.Object o)WriterwriteBytes(byte[] b)WriterwriteBytes(byte[] b, int offset, int length)voidwriteCode(int code)voidwriteCount(int count)WriterwriteDouble(double d)WriterwriteDouble(java.lang.Object o)WriterwriteExt(java.lang.Object tag, java.lang.Object... fields)WriterwriteFloat(float f)WriterwriteFloat(java.lang.Object o)WriterwriteFooter()voidwriteFooterFor(java.nio.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.WriterwriteInt(long i)WriterwriteInt(java.lang.Object o)WriterwriteList(java.lang.Object o)WriterwriteNull()WriterwriteObject(java.lang.Object o)WriterwriteObject(java.lang.Object o, boolean cache)WriterwriteString(java.lang.Object o)WriterwriteTag(java.lang.Object tag, int componentCount)
-
-
-
Constructor Detail
-
FressianWriter
public FressianWriter(java.io.OutputStream out)
-
FressianWriter
public FressianWriter(java.io.OutputStream out, ILookup<java.lang.Class,java.util.Map<java.lang.String,WriteHandler>> userHandlers)Create a writer that combines userHandlers with the normal type handlers built into Fressian.
-
-
Method Detail
-
writeNull
public Writer writeNull() throws java.io.IOException
-
writeBoolean
public Writer writeBoolean(boolean b) throws java.io.IOException
- Specified by:
writeBooleanin interfaceWriter- Throws:
java.io.IOException
-
writeBoolean
public Writer writeBoolean(java.lang.Object o) throws java.io.IOException
- Specified by:
writeBooleanin interfaceWriter- Throws:
java.io.IOException
-
writeInt
public Writer writeInt(long i) throws java.io.IOException
-
writeInt
public Writer writeInt(java.lang.Object o) throws java.io.IOException
-
writeDouble
public Writer writeDouble(double d) throws java.io.IOException
- Specified by:
writeDoublein interfaceWriter- Throws:
java.io.IOException
-
writeDouble
public Writer writeDouble(java.lang.Object o) throws java.io.IOException
- Specified by:
writeDoublein interfaceWriter- Throws:
java.io.IOException
-
writeFloat
public Writer writeFloat(float f) throws java.io.IOException
- Specified by:
writeFloatin interfaceWriter- Throws:
java.io.IOException
-
writeFloat
public Writer writeFloat(java.lang.Object o) throws java.io.IOException
- Specified by:
writeFloatin interfaceWriter- Throws:
java.io.IOException
-
writeString
public Writer writeString(java.lang.Object o) throws java.io.IOException
- Specified by:
writeStringin interfaceWriter- Throws:
java.io.IOException
-
writeList
public Writer writeList(java.lang.Object o) throws java.io.IOException
-
writeBytes
public Writer writeBytes(byte[] b) throws java.io.IOException
- Specified by:
writeBytesin interfaceWriter- Throws:
java.io.IOException
-
writeBytes
public Writer writeBytes(byte[] b, int offset, int length) throws java.io.IOException
- Specified by:
writeBytesin interfaceWriter- Throws:
java.io.IOException
-
writeFooterFor
public void writeFooterFor(java.nio.ByteBuffer bb) throws java.io.IOExceptionDescription copied from interface:StreamingWriterWrite 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:
writeFooterForin interfaceStreamingWriter- Throws:
java.io.IOException
-
writeFooter
public Writer writeFooter() throws java.io.IOException
- Specified by:
writeFooterin interfaceWriter- Throws:
java.io.IOException
-
resetCaches
public Writer resetCaches() throws java.io.IOException
- Specified by:
resetCachesin interfaceWriter- Throws:
java.io.IOException
-
getPriorityCache
public InterleavedIndexHopMap getPriorityCache()
-
getStructCache
public InterleavedIndexHopMap getStructCache()
-
writeTag
public Writer writeTag(java.lang.Object tag, int componentCount) throws java.io.IOException
-
writeExt
public Writer writeExt(java.lang.Object tag, java.lang.Object... fields) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCount
public void writeCount(int count) throws java.io.IOException- Throws:
java.io.IOException
-
writeAs
public Writer writeAs(java.lang.String tag, java.lang.Object o, boolean cache) throws java.io.IOException
-
writeAs
public Writer writeAs(java.lang.String tag, java.lang.Object o) throws java.io.IOException
-
writeObject
public Writer writeObject(java.lang.Object o, boolean cache) throws java.io.IOException
- Specified by:
writeObjectin interfaceWriter- Throws:
java.io.IOException
-
writeObject
public Writer writeObject(java.lang.Object o) throws java.io.IOException
- Specified by:
writeObjectin interfaceWriter- Throws:
java.io.IOException
-
writeCode
public void writeCode(int code) throws java.io.IOException- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
beginClosedList
public Writer beginClosedList() throws java.io.IOException
Description copied from interface:StreamingWriterBegin 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:
beginClosedListin interfaceStreamingWriter- Returns:
- this Writer (fluent)
- Throws:
java.io.IOException
-
endList
public Writer endList() throws java.io.IOException
Description copied from interface:StreamingWriterMark the end of a variable-lenght list, either closed or open.- Specified by:
endListin interfaceStreamingWriter- Returns:
- this Writer (fluent)
- Throws:
java.io.IOException
-
beginOpenList
public Writer beginOpenList() throws java.io.IOException
Description copied from interface:StreamingWriterBegin 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:
beginOpenListin interfaceStreamingWriter- Returns:
- this Writer (fluent)
- Throws:
java.io.IOException
-
-