uk.org.blankaspect.nlf
Interface Chunk.Writer

Enclosing class:
Chunk

public static interface Chunk.Writer

This interface specifies the methods that must be implemented by a class that writes chunk data to a data output. The data output is likely to be an instance of java.io.RandomAccessFile.

The Document.write(java.io.File) method, which is provided as a standard way of writing a Nested List File, writes a document in two passes. It uses the value that is returned by the reset(int) method on the first pass to determine whether a chunk should be rewritten on the second pass.

Since:
1.0
See Also:
Chunk.getWriter(), Chunk.setWriter(Chunk.Writer)

Method Summary
 long getLength()
          Returns the length (size) of the chunk in bytes.
 boolean reset(int pass)
          Resets the chunk writer before any writing is performed.
 void write(java.io.DataOutput dataOutput)
          Writes the chunk data to the specified data output.
 

Method Detail

reset

boolean reset(int pass)
              throws java.io.IOException
Resets the chunk writer before any writing is performed. The writer is reset at the start of each pass of the document writer.

Parameters:
pass - the index of the pass (0 = first pass, 1 = second pass) of the document writer that calls this method.
Returns:
true on the first pass if the chunk should be rewritten on the second pass; false otherwise.
Throws:
java.io.IOException - if an I/O error occurs.
Since:
1.0

getLength

long getLength()
Returns the length (size) of the chunk in bytes.

Returns:
the length (size) of the chunk in bytes.
Since:
1.0

write

void write(java.io.DataOutput dataOutput)
           throws java.io.IOException
Writes the chunk data to the specified data output. The data output is likely to be an instance of java.io.RandomAccessFile.

Parameters:
dataOutput - the data output to which the chunk data are to be written.
Throws:
java.io.IOException - if an I/O error occurs.
Since:
1.0