ibis.io
Class DataSerializationOutputStream

java.lang.Object
  extended by ibis.io.ByteSerializationOutputStream
      extended by ibis.io.DataSerializationOutputStream
All Implemented Interfaces:
DataOutput, SerializationOutput
Direct Known Subclasses:
IbisSerializationOutputStream

public class DataSerializationOutputStream
extends ByteSerializationOutputStream

This is the SerializationOutputStream version that is used for data serialization. With data serialization, you can only write basic types and arrays of basic types. It also serves as a base type for Ibis serialization.


Constructor Summary
DataSerializationOutputStream(DataOutputStream out)
          Constructor with a DataOutputStream.
 
Method Summary
 void close()
          Flushes and closes this stream, and flushes the underlying streams.
 void flush()
          Flushes everything collected sofar.
 void internalWriteByteBuffer(ByteBuffer value)
           
 String serializationImplName()
          Returns the actual implementation used by this output.
 void statistics()
          Print some statistics.
 void writeArray(boolean[] ref, int off, int len)
          Writes (a slice of) an array of booleans.
 void writeArray(byte[] ref, int off, int len)
          Writes (a slice of) an array of bytes.
 void writeArray(char[] ref, int off, int len)
          Writes (a slice of) an array of characters.
 void writeArray(double[] ref, int off, int len)
          Writes (a slice of) an array of doubles.
 void writeArray(float[] ref, int off, int len)
          Writes (a slice of) an array of floats.
 void writeArray(int[] ref, int off, int len)
          Writes (a slice of) an array of integers.
 void writeArray(long[] ref, int off, int len)
          Writes (a slice of) an array of longs.
 void writeArray(short[] ref, int off, int len)
          Writes (a slice of) an array of shorts.
 void writeArrayBoolean(boolean[] ref, int offset, int len)
          Method to put a boolean array in the "array cache".
 void writeArrayByte(byte[] ref, int offset, int len)
          Method to put a byte array in the "array cache".
 void writeArrayChar(char[] ref, int offset, int len)
          Method to put a char array in the "array cache".
 void writeArrayDouble(double[] ref, int offset, int len)
          Method to put a double array in the "array cache".
 void writeArrayFloat(float[] ref, int offset, int len)
          Method to put a float array in the "array cache".
 void writeArrayInt(int[] ref, int offset, int len)
          Method to put a int array in the "array cache".
 void writeArrayLong(long[] ref, int offset, int len)
          Method to put a long array in the "array cache".
 void writeArrayShort(short[] ref, int offset, int len)
          Method to put a short array in the "array cache".
 void writeBoolean(boolean value)
          Writes a boolean value to the accumulator.
 void writeByte(byte value)
          Writes a byte value to the accumulator.
 void writeByteBuffer(ByteBuffer value)
          Writes the contents of the byte buffer (between its current position and its limit).
 void writeChar(char value)
          Writes a char value to the accumulator.
 void writeDouble(double value)
          Writes a double value to the accumulator.
 void writeFloat(float value)
          Writes a float value to the accumulator.
 void writeInt(int value)
          Writes a int value to the accumulator.
 void writeLong(long value)
          Writes a long value to the accumulator.
 void writeShort(short value)
          Writes a short value to the accumulator.
 void writeString(String str)
          Writes a String to the output.
 void writeUTF(String str)
           
 
Methods inherited from class ibis.io.ByteSerializationOutputStream
realClose, reInitOnNewConnection, reset, reset, setReplacer, writeArray, writeArray, writeArray, writeArray, writeArray, writeArray, writeArray, writeArray, writeArray, writeArray, writeObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSerializationOutputStream

public DataSerializationOutputStream(DataOutputStream out)
                              throws IOException
Constructor with a DataOutputStream.

Parameters:
out - the underlying DataOutputStream
Throws:
IOException - gets thrown when an IO error occurs.
Method Detail

serializationImplName

public String serializationImplName()
Description copied from interface: SerializationOutput
Returns the actual implementation used by this output.

Specified by:
serializationImplName in interface SerializationOutput
Overrides:
serializationImplName in class ByteSerializationOutputStream
Returns:
the name of the actual serialization implementation used

statistics

public void statistics()
Description copied from interface: SerializationOutput
Print some statistics.

Specified by:
statistics in interface SerializationOutput
Overrides:
statistics in class ByteSerializationOutputStream

writeArrayBoolean

public void writeArrayBoolean(boolean[] ref,
                              int offset,
                              int len)
                       throws IOException
Method to put a boolean array in the "array cache". If the cache is full it is written to the arrayOutputStream. This method is public because it gets called from rewritten code.

Parameters:
ref - the array to be written
offset - the offset at which to start
len - number of elements to write
Throws:
IOException - on IO error.

writeArrayByte

public void writeArrayByte(byte[] ref,
                           int offset,
                           int len)
                    throws IOException
Method to put a byte array in the "array cache". If the cache is full it is written to the arrayOutputStream. This method is public because it gets called from rewritten code.

Parameters:
ref - the array to be written
offset - the offset at which to start
len - number of elements to write
Throws:
IOException - on IO error.

internalWriteByteBuffer

public void internalWriteByteBuffer(ByteBuffer value)
                             throws IOException
Throws:
IOException

writeArrayChar

public void writeArrayChar(char[] ref,
                           int offset,
                           int len)
                    throws IOException
Method to put a char array in the "array cache". If the cache is full it is written to the arrayOutputStream. This method is public because it gets called from rewritten code.

Parameters:
ref - the array to be written
offset - the offset at which to start
len - number of elements to write
Throws:
IOException - on IO error.

writeArrayShort

public void writeArrayShort(short[] ref,
                            int offset,
                            int len)
                     throws IOException
Method to put a short array in the "array cache". If the cache is full it is written to the arrayOutputStream. This method is public because it gets called from rewritten code.

Parameters:
ref - the array to be written
offset - the offset at which to start
len - number of elements to write
Throws:
IOException - on IO error.

writeArrayInt

public void writeArrayInt(int[] ref,
                          int offset,
                          int len)
                   throws IOException
Method to put a int array in the "array cache". If the cache is full it is written to the arrayOutputStream. This method is public because it gets called from rewritten code.

Parameters:
ref - the array to be written
offset - the offset at which to start
len - number of elements to write
Throws:
IOException - on IO error.

writeArrayLong

public void writeArrayLong(long[] ref,
                           int offset,
                           int len)
                    throws IOException
Method to put a long array in the "array cache". If the cache is full it is written to the arrayOutputStream. This method is public because it gets called from rewritten code.

Parameters:
ref - the array to be written
offset - the offset at which to start
len - number of elements to write
Throws:
IOException - on IO error.

writeArrayFloat

public void writeArrayFloat(float[] ref,
                            int offset,
                            int len)
                     throws IOException
Method to put a float array in the "array cache". If the cache is full it is written to the arrayOutputStream. This method is public because it gets called from rewritten code.

Parameters:
ref - the array to be written
offset - the offset at which to start
len - number of elements to write
Throws:
IOException - on IO error.

writeArrayDouble

public void writeArrayDouble(double[] ref,
                             int offset,
                             int len)
                      throws IOException
Method to put a double array in the "array cache". If the cache is full it is written to the arrayOutputStream. This method is public because it gets called from rewritten code.

Parameters:
ref - the array to be written
offset - the offset at which to start
len - number of elements to write
Throws:
IOException - on IO error.

flush

public void flush()
           throws IOException
Flushes everything collected sofar.

Specified by:
flush in interface SerializationOutput
Overrides:
flush in class ByteSerializationOutputStream
Throws:
IOException - on an IO error.

writeBoolean

public void writeBoolean(boolean value)
                  throws IOException
Writes a boolean value to the accumulator.

Specified by:
writeBoolean in interface DataOutput
Overrides:
writeBoolean in class ByteSerializationOutputStream
Parameters:
value - The boolean value to write.
Throws:
IOException - on IO error.

writeByte

public void writeByte(byte value)
               throws IOException
Writes a byte value to the accumulator.

Specified by:
writeByte in interface DataOutput
Overrides:
writeByte in class ByteSerializationOutputStream
Parameters:
value - The byte value to write.
Throws:
IOException - on IO error.

writeChar

public void writeChar(char value)
               throws IOException
Writes a char value to the accumulator.

Specified by:
writeChar in interface DataOutput
Overrides:
writeChar in class ByteSerializationOutputStream
Parameters:
value - The char value to write.
Throws:
IOException - on IO error.

writeShort

public void writeShort(short value)
                throws IOException
Writes a short value to the accumulator.

Specified by:
writeShort in interface DataOutput
Overrides:
writeShort in class ByteSerializationOutputStream
Parameters:
value - The short value to write.
Throws:
IOException - on IO error.

writeInt

public void writeInt(int value)
              throws IOException
Writes a int value to the accumulator.

Specified by:
writeInt in interface DataOutput
Overrides:
writeInt in class ByteSerializationOutputStream
Parameters:
value - The int value to write.
Throws:
IOException - on IO error.

writeLong

public void writeLong(long value)
               throws IOException
Writes a long value to the accumulator.

Specified by:
writeLong in interface DataOutput
Overrides:
writeLong in class ByteSerializationOutputStream
Parameters:
value - The long value to write.
Throws:
IOException - on IO error.

writeFloat

public void writeFloat(float value)
                throws IOException
Writes a float value to the accumulator.

Specified by:
writeFloat in interface DataOutput
Overrides:
writeFloat in class ByteSerializationOutputStream
Parameters:
value - The float value to write.
Throws:
IOException - on IO error.

writeDouble

public void writeDouble(double value)
                 throws IOException
Writes a double value to the accumulator.

Specified by:
writeDouble in interface DataOutput
Overrides:
writeDouble in class ByteSerializationOutputStream
Parameters:
value - The double value to write.
Throws:
IOException - on IO error.

writeString

public void writeString(String str)
                 throws IOException
Description copied from interface: SerializationOutput
Writes a String to the output. A duplicate check for this String object is performed: if the object was already written to this message, a handle for this object is written instead of the object itself.

Specified by:
writeString in interface SerializationOutput
Overrides:
writeString in class ByteSerializationOutputStream
Parameters:
str - the string to write.
Throws:
IOException - an error occurred

writeUTF

public void writeUTF(String str)
              throws IOException
Throws:
IOException

writeArray

public void writeArray(boolean[] ref,
                       int off,
                       int len)
                throws IOException
Description copied from interface: DataOutput
Writes (a slice of) an array of booleans.

Specified by:
writeArray in interface DataOutput
Overrides:
writeArray in class ByteSerializationOutputStream
Parameters:
ref - the array to write
off - the offset at which to start
len - the number of elements to be copied
Throws:
IOException - on an IO error

writeArray

public void writeArray(byte[] ref,
                       int off,
                       int len)
                throws IOException
Description copied from interface: DataOutput
Writes (a slice of) an array of bytes.

Specified by:
writeArray in interface DataOutput
Overrides:
writeArray in class ByteSerializationOutputStream
Parameters:
ref - the array to write
off - the offset at which to start
len - the number of elements to be copied
Throws:
IOException - on an IO error

writeByteBuffer

public void writeByteBuffer(ByteBuffer value)
                     throws IOException
Description copied from interface: DataOutput
Writes the contents of the byte buffer (between its current position and its limit).

Specified by:
writeByteBuffer in interface DataOutput
Overrides:
writeByteBuffer in class ByteSerializationOutputStream
Parameters:
value - the byte buffer from which data is to be written
Throws:
IOException - an error occurred

writeArray

public void writeArray(short[] ref,
                       int off,
                       int len)
                throws IOException
Description copied from interface: DataOutput
Writes (a slice of) an array of shorts.

Specified by:
writeArray in interface DataOutput
Overrides:
writeArray in class ByteSerializationOutputStream
Parameters:
ref - the array to write
off - the offset at which to start
len - the number of elements to be copied
Throws:
IOException - on an IO error

writeArray

public void writeArray(char[] ref,
                       int off,
                       int len)
                throws IOException
Description copied from interface: DataOutput
Writes (a slice of) an array of characters.

Specified by:
writeArray in interface DataOutput
Overrides:
writeArray in class ByteSerializationOutputStream
Parameters:
ref - the array to write
off - the offset at which to start
len - the number of elements to be copied
Throws:
IOException - on an IO error

writeArray

public void writeArray(int[] ref,
                       int off,
                       int len)
                throws IOException
Description copied from interface: DataOutput
Writes (a slice of) an array of integers.

Specified by:
writeArray in interface DataOutput
Overrides:
writeArray in class ByteSerializationOutputStream
Parameters:
ref - the array to write
off - the offset at which to start
len - the number of elements to be copied
Throws:
IOException - on an IO error

writeArray

public void writeArray(long[] ref,
                       int off,
                       int len)
                throws IOException
Description copied from interface: DataOutput
Writes (a slice of) an array of longs.

Specified by:
writeArray in interface DataOutput
Overrides:
writeArray in class ByteSerializationOutputStream
Parameters:
ref - the array to write
off - the offset at which to start
len - the number of elements to be copied
Throws:
IOException - on an IO error

writeArray

public void writeArray(float[] ref,
                       int off,
                       int len)
                throws IOException
Description copied from interface: DataOutput
Writes (a slice of) an array of floats.

Specified by:
writeArray in interface DataOutput
Overrides:
writeArray in class ByteSerializationOutputStream
Parameters:
ref - the array to write
off - the offset at which to start
len - the number of elements to be copied
Throws:
IOException - on an IO error

writeArray

public void writeArray(double[] ref,
                       int off,
                       int len)
                throws IOException
Description copied from interface: DataOutput
Writes (a slice of) an array of doubles.

Specified by:
writeArray in interface DataOutput
Overrides:
writeArray in class ByteSerializationOutputStream
Parameters:
ref - the array to write
off - the offset at which to start
len - the number of elements to be copied
Throws:
IOException - on an IO error

close

public void close()
           throws IOException
Description copied from interface: SerializationOutput
Flushes and closes this stream, and flushes the underlying streams.

Specified by:
close in interface SerializationOutput
Overrides:
close in class ByteSerializationOutputStream
Throws:
IOException - an error occurred