uk.me.parabola.imgfmt.app
Interface ImgFileWriter

All Superinterfaces:
java.io.Closeable
All Known Implementing Classes:
BufferedImgFileWriter, SectionWriter

public interface ImgFileWriter
extends java.io.Closeable

I want to be able to experiment with different schemes to write out. I am hoping that you do not need to write files with contiguous blocks, however since all maps seem to do that it may not be possible. Having a block list is then a bit strange. Perhaps you can but it performs worse so no one does it?

Author:
Steve Ratcliffe

Method Summary
 long getSize()
          Returns the size of the file.
 int position()
          Get the position.
 void position(long pos)
          Set the position of the file.
 void put(byte b)
          Write out a single byte.
 void put(byte[] val)
          Write out an arbitrary length sequence of bytes.
 void put(byte[] src, int start, int length)
          Write out part of a byte array.
 void put3(int val)
          Write out three bytes.
 void putChar(char c)
          Write out two bytes.
 void putInt(int val)
          Write out 4 byte value.
 void sync()
          Called to write out any saved buffers.
 
Methods inherited from interface java.io.Closeable
close
 

Method Detail

sync

void sync()
          throws java.io.IOException
Called to write out any saved buffers. The strategy may write directly to the file in which case this would have nothing or little to do.

Throws:
java.io.IOException - If there is an error writing.

position

int position()
Get the position. Needed because may not be reflected in the underlying file if being buffered.

Returns:
The logical position within the file.

position

void position(long pos)
Set the position of the file.

Parameters:
pos - The new position in the file.

put

void put(byte b)
Write out a single byte.

Parameters:
b - The byte to write.

putChar

void putChar(char c)
Write out two bytes. Done in the correct byte order.

Parameters:
c - The value to write.

put3

void put3(int val)
Write out three bytes. Done in the correct byte order.

Parameters:
val - The value to write, only the bottom three bytes will be written.

putInt

void putInt(int val)
Write out 4 byte value.

Parameters:
val - The value to write.

put

void put(byte[] val)
Write out an arbitrary length sequence of bytes.

Parameters:
val - The values to write.

put

void put(byte[] src,
         int start,
         int length)
Write out part of a byte array.

Parameters:
src - The array to take bytes from.
start - The start position.
length - The number of bytes to write.

getSize

long getSize()
Returns the size of the file. Note that this is not a general purpose routine and it may not be possible to give the correct answer at all times.

Returns:
The file size in bytes.