org.simantics.databoard.util.binary
Class ByteBufferWriteable

java.lang.Object
  extended by org.simantics.databoard.util.binary.ByteBufferWriteable
All Implemented Interfaces:
java.io.DataOutput, BinaryWriteable

public class ByteBufferWriteable
extends java.lang.Object
implements BinaryWriteable

IWriteable implementation with ByteBuffer as backend

Author:
Toni Kalajainen (toni.kalajainen@vtt.fi)

Constructor Summary
ByteBufferWriteable(java.nio.ByteBuffer buf)
           
 
Method Summary
 void flush()
          Flush write buffer
 long position()
           
 void position(long newPosition)
           
 void write(byte[] src)
           
 void write(byte[] src, int offset, int length)
           
 void write(int b)
           
 void writeBoolean(boolean v)
           
 void writeByte(int b)
           
 void writeBytes(java.lang.String s)
           
 void writeChar(int value)
           
 void writeChars(java.lang.String s)
           
 void writeDouble(double value)
           
 void writeFloat(float value)
           
 void writeFully(java.nio.ByteBuffer src)
          Put n bytes from the remaining of the byte array.
 void writeFully(java.nio.ByteBuffer src, int length)
          Put n bytes from the remaining of the byte buffer.
 void writeInt(int value)
           
 void writeLong(long value)
           
 void writeShort(int value)
           
 void writeUTF(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBufferWriteable

public ByteBufferWriteable(java.nio.ByteBuffer buf)
Method Detail

write

public void write(int b)
Specified by:
write in interface java.io.DataOutput

writeByte

public void writeByte(int b)
               throws java.io.IOException
Specified by:
writeByte in interface java.io.DataOutput
Throws:
java.io.IOException

writeBoolean

public void writeBoolean(boolean v)
                  throws java.io.IOException
Specified by:
writeBoolean in interface java.io.DataOutput
Throws:
java.io.IOException

writeFully

public void writeFully(java.nio.ByteBuffer src)
Description copied from interface: BinaryWriteable
Put n bytes from the remaining of the byte array. This operation moves the pointer in byte buffer.

Specified by:
writeFully in interface BinaryWriteable

writeFully

public void writeFully(java.nio.ByteBuffer src,
                       int length)
Description copied from interface: BinaryWriteable
Put n bytes from the remaining of the byte buffer. This operation moves the pointer in byte buffer.

Specified by:
writeFully in interface BinaryWriteable

write

public void write(byte[] src,
                  int offset,
                  int length)
Specified by:
write in interface java.io.DataOutput

write

public void write(byte[] src)
Specified by:
write in interface java.io.DataOutput

writeDouble

public void writeDouble(double value)
Specified by:
writeDouble in interface java.io.DataOutput

writeFloat

public void writeFloat(float value)
Specified by:
writeFloat in interface java.io.DataOutput

writeInt

public void writeInt(int value)
Specified by:
writeInt in interface java.io.DataOutput

writeLong

public void writeLong(long value)
Specified by:
writeLong in interface java.io.DataOutput

writeShort

public void writeShort(int value)
Specified by:
writeShort in interface java.io.DataOutput

writeChar

public void writeChar(int value)
Specified by:
writeChar in interface java.io.DataOutput

writeBytes

public void writeBytes(java.lang.String s)
                throws java.io.IOException
Specified by:
writeBytes in interface java.io.DataOutput
Throws:
java.io.IOException

writeChars

public void writeChars(java.lang.String s)
                throws java.io.IOException
Specified by:
writeChars in interface java.io.DataOutput
Throws:
java.io.IOException

writeUTF

public void writeUTF(java.lang.String s)
              throws java.io.IOException
Specified by:
writeUTF in interface java.io.DataOutput
Throws:
java.io.IOException

flush

public void flush()
Description copied from interface: BinaryWriteable
Flush write buffer

Specified by:
flush in interface BinaryWriteable

position

public long position()
              throws java.io.IOException
Throws:
java.io.IOException

position

public void position(long newPosition)
              throws java.io.IOException
Throws:
java.io.IOException