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
public class SimpleDataOutput extends ByteOutputStream implements DataOutput
A simple base implementation ofDataOutputwhich wraps aByteOutput. This implementation maintains an internal buffer.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]bufferThe internal buffer.protected intbufferSizeThe size of the internal buffer.-
Fields inherited from class org.jboss.marshalling.ByteOutputStream
byteOutput
-
-
Constructor Summary
Constructors Constructor Description SimpleDataOutput(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected voidfinish()Finish writing to a stream.voidflush()protected voidshallowFlush()This shallow flush will write the internal buffer out to theByteOutput, but will not flush it.protected voidstart(ByteOutput byteOutput)Begin writing to a stream.voidwrite(byte[] bytes)Write all the bytes from the given array to the stream.voidwrite(byte[] bytes, int off, int len)Write some of the bytes from the given array to the stream.voidwrite(int v)Writes to the output stream the eight low-order bits of the argumentb.voidwriteBoolean(boolean v)voidwriteByte(int v)voidwriteBytes(String s)voidwriteChar(int v)voidwriteChars(String s)voidwriteDouble(double v)voidwriteFloat(float v)voidwriteInt(int v)voidwriteLong(long v)voidwriteShort(int v)voidwriteUTF(String s)-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Constructor Detail
-
SimpleDataOutput
public SimpleDataOutput(int bufferSize)
Construct a new instance.- Parameters:
bufferSize- the buffer size
-
SimpleDataOutput
public SimpleDataOutput(int bufferSize, ByteOutput byteOutput)Construct a new instance.- Parameters:
bufferSize- the buffer sizebyteOutput- the byte output to wrap
-
SimpleDataOutput
public SimpleDataOutput(ByteOutput byteOutput)
Construct a new instance with a default buffer size.- Parameters:
byteOutput- the byte output to wrap
-
-
Method Detail
-
write
public void write(int v) throws IOExceptionWrites to the output stream the eight low-order bits of the argumentb. The 24 high-order bits ofbare ignored.- Specified by:
writein interfaceByteOutput- Specified by:
writein interfaceDataOutput- Overrides:
writein classByteOutputStream- Parameters:
v- the byte to write- Throws:
IOException- if an error occurs
-
write
public void write(byte[] bytes) throws IOExceptionWrite all the bytes from the given array to the stream.- Specified by:
writein interfaceByteOutput- Specified by:
writein interfaceDataOutput- Overrides:
writein classByteOutputStream- Parameters:
bytes- the byte array- Throws:
IOException- if an error occurs
-
write
public void write(byte[] bytes, int off, int len) throws IOExceptionWrite some of the bytes from the given array to the stream.- Specified by:
writein interfaceByteOutput- Specified by:
writein interfaceDataOutput- Overrides:
writein 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
public void writeBoolean(boolean v) throws IOException- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeByte
public void writeByte(int v) throws IOException- Specified by:
writeBytein interfaceDataOutput- Throws:
IOException
-
writeShort
public void writeShort(int v) throws IOException- Specified by:
writeShortin interfaceDataOutput- Throws:
IOException
-
writeChar
public void writeChar(int v) throws IOException- Specified by:
writeCharin interfaceDataOutput- Throws:
IOException
-
writeInt
public void writeInt(int v) throws IOException- Specified by:
writeIntin interfaceDataOutput- Throws:
IOException
-
writeLong
public void writeLong(long v) throws IOException- Specified by:
writeLongin interfaceDataOutput- Throws:
IOException
-
writeFloat
public void writeFloat(float v) throws IOException- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException
-
writeDouble
public void writeDouble(double v) throws IOException- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException
-
writeBytes
public void writeBytes(String s) throws IOException
- Specified by:
writeBytesin interfaceDataOutput- Throws:
IOException
-
writeChars
public void writeChars(String s) throws IOException
- Specified by:
writeCharsin interfaceDataOutput- Throws:
IOException
-
writeUTF
public void writeUTF(String s) throws IOException
- Specified by:
writeUTFin interfaceDataOutput- Throws:
IOException
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Overrides:
flushin classByteOutputStream- Throws:
IOException
-
shallowFlush
protected void shallowFlush() throws IOExceptionThis shallow flush will write the internal buffer out to theByteOutput, but will not flush it.- Throws:
IOException- if an I/O error occurs
-
start
protected void start(ByteOutput byteOutput) throws IOException
Begin writing to a stream.- Parameters:
byteOutput- the new stream- Throws:
IOException- if an error occurs
-
finish
protected void finish() throws IOExceptionFinish 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
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classByteOutputStream- Throws:
IOException
-
-