- All Implemented Interfaces:
DataOutput
,ObjectOutput
,AutoCloseable
FastExternalizable
, Externalizable
, and Serializable
objects.
When multiple objects are being written, this avoids the repetitive writing of classnames and serialVersionUIDs.
- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
void
unwrap()
Unwraps the object output.static FastObjectOutput
wrap
(ObjectOutput out) Gets the wrapper for the providedObjectOutput
, creating if needed.void
write
(byte[] b) void
write
(byte[] b, int off, int len) void
write
(int b) void
writeBoolean
(boolean v) void
writeByte
(int v) void
writeBytes
(String s) void
writeChar
(int v) void
writeChars
(String s) void
writeDouble
(double v) protected void
Writes aFastExternalizable
object to the provided stream, supportingnull
values.void
writeFastUTF
(String value) Writes aString
to the output, not writing any duplicates.void
writeFloat
(float v) void
writeInt
(int v) void
writeLong
(long v) void
writeObject
(Object obj) Writes the provided object in the most efficient manner possible, with no object graph tracking (if possible).void
writeShort
(int v) void
-
Method Details
-
wrap
Gets the wrapper for the providedObjectOutput
, creating if needed. To avoid memory leaks, it must also beunwrapped
in a finally block.TODO: Can
FastObjectOutput
itself implementAutoCloseable
forunwrap()
? Maybe this means it no longer implementsObjectOutput
directly?- Throws:
IOException
-
unwrap
Unwraps the object output.- Throws:
IllegalStateException
- if not wrapped
-
writeObject
Writes the provided object in the most efficient manner possible, with no object graph tracking (if possible). This allows individual objects to switch betweenFastExternalizable
and standard serialization without calling code needing to know the difference.If the object is
null
, writes a single byte ofNULL
.If the object is
FastExternalizable
, callswriteFastObject(com.aoapps.lang.io.FastExternalizable)
.Otherwise, writes
STANDARD
and then uses standard Java serialization.- Specified by:
writeObject
in interfaceObjectOutput
- Throws:
IOException
- See Also:
-
writeFastObject
Writes aFastExternalizable
object to the provided stream, supportingnull
values.- Throws:
IOException
- See Also:
-
writeFastUTF
Writes aString
to the output, not writing any duplicates. Supportsnull
.TODO: Any benefit to string prefix compression, like in CompressedDataOutput?
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfaceObjectOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfaceObjectOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfaceObjectOutput
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceObjectOutput
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceObjectOutput
- Throws:
IOException
-
writeBoolean
- Specified by:
writeBoolean
in interfaceDataOutput
- Throws:
IOException
-
writeByte
- Specified by:
writeByte
in interfaceDataOutput
- Throws:
IOException
-
writeShort
- Specified by:
writeShort
in interfaceDataOutput
- Throws:
IOException
-
writeChar
- Specified by:
writeChar
in interfaceDataOutput
- Throws:
IOException
-
writeInt
- Specified by:
writeInt
in interfaceDataOutput
- Throws:
IOException
-
writeLong
- Specified by:
writeLong
in interfaceDataOutput
- Throws:
IOException
-
writeFloat
- Specified by:
writeFloat
in interfaceDataOutput
- Throws:
IOException
-
writeDouble
- Specified by:
writeDouble
in interfaceDataOutput
- Throws:
IOException
-
writeBytes
- Specified by:
writeBytes
in interfaceDataOutput
- Throws:
IOException
-
writeChars
- Specified by:
writeChars
in interfaceDataOutput
- Throws:
IOException
-
writeUTF
- Specified by:
writeUTF
in interfaceDataOutput
- Throws:
IOException
-