ch.javasoft.jsmat
Class ReservedMatrixWriter<A>

java.lang.Object
  extended by ch.javasoft.jsmat.ReservedWriter
      extended by ch.javasoft.jsmat.ReservedMatrixWriter<A>

public class ReservedMatrixWriter<A>
extends ReservedWriter

Writer to write simple reserved variables (matrices). Extends ReservedWriter mainly by adding the append(Object) method to write data to the variable.


Field Summary
 
Fields inherited from class ch.javasoft.jsmat.ReservedWriter
mDataOutput, mReserved, mWriter
 
Constructor Summary
ReservedMatrixWriter(MatWriter<? extends DataOutput> writer, MatReservedMatrix<A> reservedMatrix)
          Constructor to write to top-level variables.
ReservedMatrixWriter(ReservedComplexWriter complexWriter, MatReservedMatrix<A> reservedMatrix)
          Constructor to write to complex types, such as structs.
 
Method Summary
 void append(A data)
          Append data to the reserved variable.
 void close()
          Closes the writer and completes writing of the corresponding reserved variable.
 
Methods inherited from class ch.javasoft.jsmat.ReservedWriter
closeVariableWriter, open
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReservedMatrixWriter

public ReservedMatrixWriter(ReservedComplexWriter complexWriter,
                            MatReservedMatrix<A> reservedMatrix)
Constructor to write to complex types, such as structs.

Parameters:
complexWriter - the writer for the complex type
reservedMatrix - the reserved variable of the nested type, e.g. a field of a struct

ReservedMatrixWriter

public ReservedMatrixWriter(MatWriter<? extends DataOutput> writer,
                            MatReservedMatrix<A> reservedMatrix)
Constructor to write to top-level variables.

Parameters:
writer - the mat writer, e.g. writing a matlab file
reservedMatrix - the reserved variable
Method Detail

append

public void append(A data)
            throws IOException
Append data to the reserved variable. Note that all together, the exact size as specified by the reserved variable has to be written, or an io exception will be thrown.

Parameters:
data - the data to append
Throws:
IOException - if the writer has already been closed, or if the write operation appended more data to the variable then reserved, or if any other io exception occurrs

close

public void close()
           throws IOException
Closes the writer and completes writing of the corresponding reserved variable.

Before invoking the super.close(), the written data length is checked and an exception is thrown if the length differs from the reserved size.

Overrides:
close in class ReservedWriter
Throws:
IOException - if the length of the written data is not as expected, that is, not as predefined by the reserved variable, or if any other io exception occurrs