Package org.jboss.marshalling
Class SimpleDataOutput
java.lang.Object
java.io.OutputStream
org.jboss.marshalling.SimpleByteOutput
org.jboss.marshalling.ByteOutputStream
org.jboss.marshalling.SimpleDataOutput
- All Implemented Interfaces:
Closeable
,DataOutput
,Flushable
,AutoCloseable
,ByteOutput
- Direct Known Subclasses:
AbstractObjectOutput
A simple base implementation of
DataOutput
which wraps a ByteOutput
. This implementation maintains
an internal buffer.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
The internal buffer.protected final int
The size of the internal buffer.private int
The position in the buffer.Fields inherited from class org.jboss.marshalling.ByteOutputStream
byteOutput
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleDataOutput
(int bufferSize) Construct a new instance.SimpleDataOutput
(int bufferSize, ByteOutput byteOutput) Construct a new instance.SimpleDataOutput
(ByteOutput byteOutput) Construct a new instance with a default buffer size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected void
finish()
Finish writing to a stream.void
flush()
private static NotActiveException
protected void
This shallow flush will write the internal buffer out to theByteOutput
, but will not flush it.protected void
start
(ByteOutput byteOutput) Begin writing to a stream.void
write
(byte[] bytes) Write all the bytes from the given array to the stream.void
write
(byte[] bytes, int off, int len) Write some of the bytes from the given array to the stream.void
write
(int v) Writes to the output stream the eight low-order bits of the argumentb
.void
writeBoolean
(boolean v) void
writeByte
(int v) void
writeBytes
(String s) void
writeChar
(int v) void
writeChars
(String s) void
writeDouble
(double v) void
writeFloat
(float v) void
writeInt
(int v) void
writeLong
(long v) void
writeShort
(int v) void
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
bufferSize
protected final int bufferSizeThe size of the internal buffer. -
buffer
protected byte[] bufferThe internal buffer. -
position
private int positionThe position in the buffer.
-
-
Constructor Details
-
SimpleDataOutput
public SimpleDataOutput(int bufferSize) Construct a new instance.- Parameters:
bufferSize
- the buffer size
-
SimpleDataOutput
Construct a new instance.- Parameters:
bufferSize
- the buffer sizebyteOutput
- the byte output to wrap
-
SimpleDataOutput
Construct a new instance with a default buffer size.- Parameters:
byteOutput
- the byte output to wrap
-
-
Method Details
-
notActiveException
-
write
Writes to the output stream the eight low-order bits of the argumentb
. The 24 high-order bits ofb
are ignored.- Specified by:
write
in interfaceByteOutput
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classByteOutputStream
- Parameters:
v
- the byte to write- Throws:
IOException
- if an error occurs
-
write
Write all the bytes from the given array to the stream.- Specified by:
write
in interfaceByteOutput
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classByteOutputStream
- Parameters:
bytes
- the byte array- Throws:
IOException
- if an error occurs
-
write
Write some of the bytes from the given array to the stream.- Specified by:
write
in interfaceByteOutput
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classByteOutputStream
- Parameters:
bytes
- the byte arrayoff
- the index to start writing fromlen
- the number of bytes to write- Throws:
IOException
- if an error occurs
-
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
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classByteOutputStream
- Throws:
IOException
-
shallowFlush
This shallow flush will write the internal buffer out to theByteOutput
, but will not flush it.- Throws:
IOException
- if an I/O error occurs
-
start
Begin writing to a stream.- Parameters:
byteOutput
- the new stream- Throws:
IOException
- if an error occurs
-
finish
Finish writing to a stream. The stream is released. No further writing may be done until thestart(ByteOutput)
method is again invoked.- Throws:
IOException
- if an error occurs
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classByteOutputStream
- Throws:
IOException
-