M - model class that your ModelMojoWriter serializesP - model parameters class that corresponds to your modelO - model output class that corresponds to your modelpublic abstract class ModelMojoWriter<M extends Model<M,P,O>,P extends Model.Parameters,O extends Model.Output> extends StreamWriter
writeModelData(). Within
this function you can use any of the following:
writekv(String, Object) to serialize any "simple" values (those that can be represented as a
single-line string).writeblob(String, byte[]) to add arbitrary blobs of data to the archive.startWritingTextFile(String) / writeln(String) / finishWritingTextFile() to
add text files to the archive.Model.getMojo() method in your model's class to
return an instance of your new child class.| Modifier and Type | Field and Description |
|---|---|
protected M |
model
Reference to the model being written.
|
| Constructor and Description |
|---|
ModelMojoWriter(M model) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
finishWritingTextFile()
Finish writing a text file.
|
protected void |
startWritingTextFile(java.lang.String filename)
Write a text file to the MOJO archive (or rather open such file for writing).
|
protected void |
writeblob(java.lang.String filename,
byte[] blob)
Write a binary file to the MOJO archive.
|
protected void |
writekv(java.lang.String key,
double[] value) |
protected void |
writekv(java.lang.String key,
int[] value) |
protected void |
writekv(java.lang.String key,
java.lang.Object value)
Write a simple value to the model.ini/[info] section.
|
protected void |
writeln(java.lang.String s)
Write a single line of text to a previously opened text file.
|
protected abstract void |
writeModelData()
Override in subclasses to write the actual model data.
|
void |
writeTo(java.io.OutputStream os)
Used from `ModelsHandler.fetchMojo()` to serialize the Mojo into a StreamingSchema.
|
public ModelMojoWriter(M model)
protected abstract void writeModelData()
throws java.io.IOException
java.io.IOExceptionprotected final void writekv(java.lang.String key,
java.lang.Object value)
throws java.io.IOException
java.io.IOExceptionprotected final void writekv(java.lang.String key,
int[] value)
throws java.io.IOException
java.io.IOExceptionprotected final void writekv(java.lang.String key,
double[] value)
throws java.io.IOException
java.io.IOExceptionprotected final void writeblob(java.lang.String filename,
byte[] blob)
throws java.io.IOException
java.io.IOExceptionprotected final void startWritingTextFile(java.lang.String filename)
protected final void writeln(java.lang.String s)
protected final void finishWritingTextFile()
throws java.io.IOException
java.io.IOExceptionpublic final void writeTo(java.io.OutputStream os)
writeTo in class StreamWriteros - output stream provided by framework