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 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(java.lang.String tag, java.lang.Object o)
Writer
writeAs(java.lang.String tag, java.lang.Object o, boolean cache)
Writer
writeBoolean(boolean b)
Writer
writeBoolean(java.lang.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(java.lang.Object o)
Writer
writeExt(java.lang.Object tag, java.lang.Object... fields)
Writer
writeFloat(float f)
Writer
writeFloat(java.lang.Object o)
Writer
writeFooter()
void
writeFooterFor(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.Writer
writeInt(long i)
Writer
writeInt(java.lang.Object o)
Writer
writeList(java.lang.Object o)
Writer
writeNull()
Writer
writeObject(java.lang.Object o)
Writer
writeObject(java.lang.Object o, boolean cache)
Writer
writeString(java.lang.Object o)
Writer
writeTag(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:
writeBoolean
in interfaceWriter
- Throws:
java.io.IOException
-
writeBoolean
public Writer writeBoolean(java.lang.Object o) throws java.io.IOException
- Specified by:
writeBoolean
in 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:
writeDouble
in interfaceWriter
- Throws:
java.io.IOException
-
writeDouble
public Writer writeDouble(java.lang.Object o) throws java.io.IOException
- Specified by:
writeDouble
in interfaceWriter
- Throws:
java.io.IOException
-
writeFloat
public Writer writeFloat(float f) throws java.io.IOException
- Specified by:
writeFloat
in interfaceWriter
- Throws:
java.io.IOException
-
writeFloat
public Writer writeFloat(java.lang.Object o) throws java.io.IOException
- Specified by:
writeFloat
in interfaceWriter
- Throws:
java.io.IOException
-
writeString
public Writer writeString(java.lang.Object o) throws java.io.IOException
- Specified by:
writeString
in 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:
writeBytes
in interfaceWriter
- Throws:
java.io.IOException
-
writeBytes
public Writer writeBytes(byte[] b, int offset, int length) throws java.io.IOException
- Specified by:
writeBytes
in interfaceWriter
- Throws:
java.io.IOException
-
writeFooterFor
public void writeFooterFor(java.nio.ByteBuffer bb) throws java.io.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 interfaceStreamingWriter
- Throws:
java.io.IOException
-
writeFooter
public Writer writeFooter() throws java.io.IOException
- Specified by:
writeFooter
in interfaceWriter
- Throws:
java.io.IOException
-
resetCaches
public Writer resetCaches() throws java.io.IOException
- Specified by:
resetCaches
in 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:
writeObject
in interfaceWriter
- Throws:
java.io.IOException
-
writeObject
public Writer writeObject(java.lang.Object o) throws java.io.IOException
- Specified by:
writeObject
in 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
beginClosedList
public Writer beginClosedList() throws java.io.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 interfaceStreamingWriter
- Returns:
- this Writer (fluent)
- Throws:
java.io.IOException
-
endList
public Writer endList() throws java.io.IOException
Description copied from interface:StreamingWriter
Mark the end of a variable-lenght list, either closed or open.- Specified by:
endList
in interfaceStreamingWriter
- Returns:
- this Writer (fluent)
- Throws:
java.io.IOException
-
beginOpenList
public Writer beginOpenList() throws java.io.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 interfaceStreamingWriter
- Returns:
- this Writer (fluent)
- Throws:
java.io.IOException
-
-