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() |
ModelMojoWriter(M model) |
Modifier and Type | Method and Description |
---|---|
protected void |
finishWritingTextFile()
Finish writing a text file.
|
abstract java.lang.String |
mojoVersion()
Version of the mojo file produced.
|
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 void |
writeln(java.lang.String s,
boolean escapeNewlines)
Write a single line of text to a previously opened text file, escape new line characters if enabled.
|
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.
|
protected void |
writeTo(java.util.zip.ZipOutputStream zos) |
void |
writeTo(java.util.zip.ZipOutputStream zos,
java.lang.String zipDirectory) |
public ModelMojoWriter()
public ModelMojoWriter(M model)
public abstract java.lang.String mojoVersion()
major.minor
format, where minor
is a 2-digit number. For example "1.00",
"2.05", "2.13". See README in mojoland repository for more details.protected abstract void writeModelData() throws java.io.IOException
java.io.IOException
protected final void writekv(java.lang.String key, java.lang.Object value) throws java.io.IOException
java.io.IOException
protected final void writekv(java.lang.String key, int[] value) throws java.io.IOException
java.io.IOException
protected final void writekv(java.lang.String key, double[] value) throws java.io.IOException
java.io.IOException
protected final void writeblob(java.lang.String filename, byte[] blob) throws java.io.IOException
java.io.IOException
protected final void startWritingTextFile(java.lang.String filename)
protected final void writeln(java.lang.String s, boolean escapeNewlines)
protected final void writeln(java.lang.String s)
protected final void finishWritingTextFile() throws java.io.IOException
java.io.IOException
public final void writeTo(java.io.OutputStream os)
writeTo
in class StreamWriter
os
- output stream provided by frameworkprotected void writeTo(java.util.zip.ZipOutputStream zos) throws java.io.IOException
java.io.IOException
public final void writeTo(java.util.zip.ZipOutputStream zos, java.lang.String zipDirectory) throws java.io.IOException
java.io.IOException