Package com.tangosol.io
Class WrapperDataOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- com.tangosol.io.WrapperDataOutputStream
-
- All Implemented Interfaces:
com.oracle.coherence.common.io.OutputStreaming
,OutputStreaming
,Closeable
,DataOutput
,Flushable
,AutoCloseable
- Direct Known Subclasses:
ExternalizableHelper.ShieldedDataOutputStream
,WrapperObjectOutputStream
public class WrapperDataOutputStream extends OutputStream implements DataOutput, OutputStreaming
This is an imitation DataOutputStream class that provides the DataOutput interface by delegating to an object that implements the DataOutput interface. Primarily, this is intended as a base class for building specific-purpose DataOutput wrappers.- Author:
- cp 2004.08.20
-
-
Constructor Summary
Constructors Constructor Description WrapperDataOutputStream(DataOutput out)
Construct a WrapperDataOutputStream that will output to the specified object implementing the DataOutput interface.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this OutputStream and releases any associated system resources.void
flush()
Flushes this OutputStream and forces any buffered output bytes to be written.long
getBytesWritten()
Return the total number of bytes written to the wrapped DataOutput object.DataOutput
getDataOutput()
Obtain the underlying object providing the DataOutput interface that this object is delegating to.protected void
incBytesWritten(int cb)
Increment the count of total number of bytes written to the wrapped DataOutput object by the specified number of bytes.void
write(byte[] ab)
Writes all the bytes in the arrayab
.void
write(byte[] ab, int of, int cb)
Writescb
bytes starting at offsetof
from the arrayab
.void
write(int b)
Writes the eight low-order bits of the argumentb
.void
writeBoolean(boolean f)
Writes the boolean valuef
.void
writeByte(int b)
Writes the eight low-order bits of the argumentb
.void
writeBytes(String s)
Writes the Strings
, but only the low-order byte from each character of the String is written.void
writeChar(int ch)
Writes a char value, comprised of the 16 low-order bits of the argumentch
; the 16 high-order bits ofch
are ignored.void
writeChars(String s)
Writes the Strings
as a sequence of characters.void
writeDouble(double dfl)
Writes a double value.void
writeFloat(float fl)
Writes a float value.void
writeInt(int n)
Writes an int value.void
writeLong(long l)
Writes a long value.void
writeShort(int n)
Writes a short value, comprised of the 16 low-order bits of the argumentn
; the 16 high-order bits ofn
are ignored.void
writeUTF(String s)
Writes the Strings
as a sequence of characters, but using UTF-8 encoding for the characters, and including the String length data so that the correspondingDataInput.readUTF()
method can reconstitute a String from the written data.-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Constructor Detail
-
WrapperDataOutputStream
public WrapperDataOutputStream(DataOutput out)
Construct a WrapperDataOutputStream that will output to the specified object implementing the DataOutput interface.- Parameters:
out
- an object implementing DataOutput to write to
-
-
Method Detail
-
getDataOutput
public DataOutput getDataOutput()
Obtain the underlying object providing the DataOutput interface that this object is delegating to.- Returns:
- the underlying DataOutput
-
getBytesWritten
public long getBytesWritten()
Return the total number of bytes written to the wrapped DataOutput object.- Returns:
- the total number of bytes written
-
incBytesWritten
protected void incBytesWritten(int cb)
Increment the count of total number of bytes written to the wrapped DataOutput object by the specified number of bytes.If the count has reached Long.MAX_VALUE, the count is not incremented.
- Parameters:
cb
- the number of bytes to increment the count by
-
write
public void write(int b) throws IOException
Writes the eight low-order bits of the argumentb
. The 24 high-order bits ofb
are ignored.- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfacecom.oracle.coherence.common.io.OutputStreaming
- Specified by:
write
in classOutputStream
- Parameters:
b
- the byte to write (passed as an integer)- Throws:
IOException
- if an I/O error occurs
-
write
public void write(byte[] ab) throws IOException
Writes all the bytes in the arrayab
.- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfacecom.oracle.coherence.common.io.OutputStreaming
- Overrides:
write
in classOutputStream
- Parameters:
ab
- the byte array to write- Throws:
IOException
- if an I/O error occursNullPointerException
- ifab
isnull
-
write
public void write(byte[] ab, int of, int cb) throws IOException
Writescb
bytes starting at offsetof
from the arrayab
.- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfacecom.oracle.coherence.common.io.OutputStreaming
- Overrides:
write
in classOutputStream
- Parameters:
ab
- the byte array to write fromof
- the offset intoab
to start writing fromcb
- the number of bytes fromab
to write- Throws:
IOException
- if an I/O error occursNullPointerException
- ifab
isnull
IndexOutOfBoundsException
- ifof
is negative, orcb
is negative, orof+cb
is greater thanab.length
-
writeBoolean
public void writeBoolean(boolean f) throws IOException
Writes the boolean valuef
.- Specified by:
writeBoolean
in interfaceDataOutput
- Parameters:
f
- the boolean to be written- Throws:
IOException
- if an I/O error occurs
-
writeByte
public void writeByte(int b) throws IOException
Writes the eight low-order bits of the argumentb
. The 24 high-order bits ofb
are ignored.- Specified by:
writeByte
in interfaceDataOutput
- Parameters:
b
- the byte to write (passed as an integer)- Throws:
IOException
- if an I/O error occurs
-
writeShort
public void writeShort(int n) throws IOException
Writes a short value, comprised of the 16 low-order bits of the argumentn
; the 16 high-order bits ofn
are ignored.- Specified by:
writeShort
in interfaceDataOutput
- Parameters:
n
- the short to write (passed as an integer)- Throws:
IOException
- if an I/O error occurs
-
writeChar
public void writeChar(int ch) throws IOException
Writes a char value, comprised of the 16 low-order bits of the argumentch
; the 16 high-order bits ofch
are ignored.- Specified by:
writeChar
in interfaceDataOutput
- Parameters:
ch
- the char to write (passed as an integer)- Throws:
IOException
- if an I/O error occurs
-
writeInt
public void writeInt(int n) throws IOException
Writes an int value.- Specified by:
writeInt
in interfaceDataOutput
- Parameters:
n
- the int to write- Throws:
IOException
- if an I/O error occurs
-
writeLong
public void writeLong(long l) throws IOException
Writes a long value.- Specified by:
writeLong
in interfaceDataOutput
- Parameters:
l
- the long to write- Throws:
IOException
- if an I/O error occurs
-
writeFloat
public void writeFloat(float fl) throws IOException
Writes a float value.- Specified by:
writeFloat
in interfaceDataOutput
- Parameters:
fl
- the float to write- Throws:
IOException
- if an I/O error occurs
-
writeDouble
public void writeDouble(double dfl) throws IOException
Writes a double value.- Specified by:
writeDouble
in interfaceDataOutput
- Parameters:
dfl
- the double to write- Throws:
IOException
- if an I/O error occurs
-
writeBytes
public void writeBytes(String s) throws IOException
Writes the Strings
, but only the low-order byte from each character of the String is written.- Specified by:
writeBytes
in interfaceDataOutput
- Parameters:
s
- the String to write- Throws:
IOException
- if an I/O error occursNullPointerException
- ifs
isnull
-
writeChars
public void writeChars(String s) throws IOException
Writes the Strings
as a sequence of characters.- Specified by:
writeChars
in interfaceDataOutput
- Parameters:
s
- the String to write- Throws:
IOException
- if an I/O error occursNullPointerException
- ifs
isnull
-
writeUTF
public void writeUTF(String s) throws IOException
Writes the Strings
as a sequence of characters, but using UTF-8 encoding for the characters, and including the String length data so that the correspondingDataInput.readUTF()
method can reconstitute a String from the written data.- Specified by:
writeUTF
in interfaceDataOutput
- Parameters:
s
- the String to write- Throws:
IOException
- if an I/O error occursNullPointerException
- ifs
isnull
-
flush
public void flush() throws IOException
Flushes this OutputStream and forces any buffered output bytes to be written.- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in interfacecom.oracle.coherence.common.io.OutputStreaming
- Overrides:
flush
in classOutputStream
- Throws:
IOException
- if an I/O error occurs
-
close
public void close() throws IOException
Closes this OutputStream and releases any associated system resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacecom.oracle.coherence.common.io.OutputStreaming
- Overrides:
close
in classOutputStream
- Throws:
IOException
- if an I/O error occurs
-
-