public abstract class AbstractJsonConvertibleRecord extends java.lang.Object implements JsonConvertibleRecord
createIOMaps
method to define the input and output
Predicate maps that determine how objects, fields, arrays should be stored
using the Jackson streaming API.
For examples, see MarsRecord
, AbstractMolecule
,
AbstractMarsMetadata
.
Constructor and Description |
---|
AbstractJsonConvertibleRecord()
Constructor for creating a JsonConvertibleRecord.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
createIOMaps()
Must be implemented in subclasses to define how fields, objects, arrays
should be saved based on the Jackson streaming API.
|
java.lang.String |
dumpJSON()
Get the record in Json string format.
|
void |
fromJSON(com.fasterxml.jackson.core.JsonParser jParser)
Read a record from JSON.
|
java.util.function.Predicate<com.fasterxml.jackson.core.JsonGenerator> |
getJsonGenerator(java.lang.String field)
Get the JsonGenerator for a field.
|
java.util.function.Predicate<com.fasterxml.jackson.core.JsonParser> |
getJsonParser(java.lang.String field)
Get the JsonParser for a field.
|
void |
setJsonField(java.lang.String field,
MarsUtil.ThrowingConsumer<com.fasterxml.jackson.core.JsonGenerator,java.io.IOException> output,
MarsUtil.ThrowingConsumer<com.fasterxml.jackson.core.JsonParser,java.io.IOException> input) |
void |
setShowWarnings(boolean showWarnings) |
void |
toJSON(com.fasterxml.jackson.core.JsonGenerator jGenerator)
Stream a record to JSON.
|
public AbstractJsonConvertibleRecord()
public void toJSON(com.fasterxml.jackson.core.JsonGenerator jGenerator) throws java.io.IOException
toJSON
in interface JsonConvertibleRecord
jGenerator
- A JsonGenerator for streaming a record to a file.java.io.IOException
- if there is a problem reading from the file.public void fromJSON(com.fasterxml.jackson.core.JsonParser jParser) throws java.io.IOException
fromJSON
in interface JsonConvertibleRecord
jParser
- A JsonParser for loading the record from a file.java.io.IOException
- if there is a problem reading from the file.public void setShowWarnings(boolean showWarnings)
setShowWarnings
in interface JsonConvertibleRecord
public void setJsonField(java.lang.String field, MarsUtil.ThrowingConsumer<com.fasterxml.jackson.core.JsonGenerator,java.io.IOException> output, MarsUtil.ThrowingConsumer<com.fasterxml.jackson.core.JsonParser,java.io.IOException> input)
setJsonField
in interface JsonConvertibleRecord
public java.util.function.Predicate<com.fasterxml.jackson.core.JsonGenerator> getJsonGenerator(java.lang.String field)
getJsonGenerator
in interface JsonConvertibleRecord
field
- Json field.public java.util.function.Predicate<com.fasterxml.jackson.core.JsonParser> getJsonParser(java.lang.String field)
getJsonParser
in interface JsonConvertibleRecord
field
- Json field.public java.lang.String dumpJSON()
dumpJSON
in interface JsonConvertibleRecord
protected abstract void createIOMaps()