org.simantics.databoard.util.binary
Class ByteBufferWriteable

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

public class ByteBufferWriteable
extends java.lang.Object
implements BinaryWriteable, Seekable

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
 java.nio.ByteOrder order()
           
 void order(java.nio.ByteOrder order)
           
 long position()
          Get position
 void position(long newPosition)
          Seek new position.
 void put(byte b)
          Write a byte
 void put(byte[] src)
           
 void put(byte[] src, int offset, int length)
           
 void put(java.nio.ByteBuffer src)
          Put n bytes from the remaining of the byte array.
 void put(java.nio.ByteBuffer src, int length)
          Put n bytes from the remaining of the byte buffer.
 void putDouble(double value)
           
 void putFloat(float value)
           
 void putInt(int value)
           
 void putLong(long value)
           
 void putShort(short value)
           
 
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

put

public void put(byte b)
Description copied from interface: BinaryWriteable
Write a byte

Specified by:
put in interface BinaryWriteable

put

public void put(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:
put in interface BinaryWriteable

put

public void put(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:
put in interface BinaryWriteable

put

public void put(byte[] src,
                int offset,
                int length)
Specified by:
put in interface BinaryWriteable

put

public void put(byte[] src)
Specified by:
put in interface BinaryWriteable

putDouble

public void putDouble(double value)
Specified by:
putDouble in interface BinaryWriteable

putFloat

public void putFloat(float value)
Specified by:
putFloat in interface BinaryWriteable

putInt

public void putInt(int value)
Specified by:
putInt in interface BinaryWriteable

putLong

public void putLong(long value)
Specified by:
putLong in interface BinaryWriteable

putShort

public void putShort(short value)
Specified by:
putShort in interface BinaryWriteable

order

public java.nio.ByteOrder order()
Specified by:
order in interface BinaryWriteable

order

public void order(java.nio.ByteOrder order)
Specified by:
order in interface BinaryWriteable

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
Description copied from interface: Seekable
Get position

Specified by:
position in interface Seekable
Returns:
position
Throws:
java.io.IOException

position

public void position(long newPosition)
              throws java.io.IOException
Description copied from interface: Seekable
Seek new position. The next value will be written after the index of the given pointer.

Specified by:
position in interface Seekable
Parameters:
newPosition - new position
Throws:
java.io.IOException