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:
java.io.Closeable,java.io.DataOutput,java.io.Flushable,java.lang.AutoCloseable,ByteOutput
- Direct Known Subclasses:
AbstractObjectOutput
public class SimpleDataOutput extends ByteOutputStream implements java.io.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.private intpositionThe position in the 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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected voidfinish()Finish writing to a stream.voidflush()private static java.io.NotActiveExceptionnotActiveException()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(java.lang.String s)voidwriteChar(int v)voidwriteChars(java.lang.String s)voidwriteDouble(double v)voidwriteFloat(float v)voidwriteInt(int v)voidwriteLong(long v)voidwriteShort(int v)voidwriteUTF(java.lang.String s)
-
-
-
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
-
notActiveException
private static java.io.NotActiveException notActiveException()
-
write
public void write(int v) throws java.io.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 interfacejava.io.DataOutput- Overrides:
writein classByteOutputStream- Parameters:
v- the byte to write- Throws:
java.io.IOException- if an error occurs
-
write
public void write(byte[] bytes) throws java.io.IOExceptionWrite all the bytes from the given array to the stream.- Specified by:
writein interfaceByteOutput- Specified by:
writein interfacejava.io.DataOutput- Overrides:
writein classByteOutputStream- Parameters:
bytes- the byte array- Throws:
java.io.IOException- if an error occurs
-
write
public void write(byte[] bytes, int off, int len) throws java.io.IOExceptionWrite some of the bytes from the given array to the stream.- Specified by:
writein interfaceByteOutput- Specified by:
writein interfacejava.io.DataOutput- Overrides:
writein classByteOutputStream- Parameters:
bytes- the byte arrayoff- the index to start writing fromlen- the number of bytes to write- Throws:
java.io.IOException- if an error occurs
-
writeBoolean
public void writeBoolean(boolean v) throws java.io.IOException- Specified by:
writeBooleanin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeByte
public void writeByte(int v) throws java.io.IOException- Specified by:
writeBytein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeShort
public void writeShort(int v) throws java.io.IOException- Specified by:
writeShortin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChar
public void writeChar(int v) throws java.io.IOException- Specified by:
writeCharin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeInt
public void writeInt(int v) throws java.io.IOException- Specified by:
writeIntin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeLong
public void writeLong(long v) throws java.io.IOException- Specified by:
writeLongin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(float v) throws java.io.IOException- Specified by:
writeFloatin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(double v) throws java.io.IOException- Specified by:
writeDoublein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.lang.String s) throws java.io.IOException- Specified by:
writeBytesin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChars
public void writeChars(java.lang.String s) throws java.io.IOException- Specified by:
writeCharsin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeUTF
public void writeUTF(java.lang.String s) throws java.io.IOException- Specified by:
writeUTFin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classByteOutputStream- Throws:
java.io.IOException
-
shallowFlush
protected void shallowFlush() throws java.io.IOExceptionThis shallow flush will write the internal buffer out to theByteOutput, but will not flush it.- Throws:
java.io.IOException- if an I/O error occurs
-
start
protected void start(ByteOutput byteOutput) throws java.io.IOException
Begin writing to a stream.- Parameters:
byteOutput- the new stream- Throws:
java.io.IOException- if an error occurs
-
finish
protected void finish() throws java.io.IOExceptionFinish writing to a stream. The stream is released. No further writing may be done until thestart(ByteOutput)method is again invoked.- Throws:
java.io.IOException- if an error occurs
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classByteOutputStream- Throws:
java.io.IOException
-
-