Package org.apache.johnzon.mapper
Class DynamicMappingGenerator
- java.lang.Object
-
- org.apache.johnzon.mapper.DynamicMappingGenerator
-
- All Implemented Interfaces:
MappingGenerator
- Direct Known Subclasses:
DynamicMappingGenerator.SkipEnclosingWriteEnd
public class DynamicMappingGenerator extends Object implements MappingGenerator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DynamicMappingGenerator.DelegatingGenerator
static class
DynamicMappingGenerator.InObjectOrPrimitiveJsonGenerator
static class
DynamicMappingGenerator.SkipEnclosingWriteEnd
private static class
DynamicMappingGenerator.SkipLastWriteEndGenerator
private static class
DynamicMappingGenerator.WritingState
-
Field Summary
Fields Modifier and Type Field Description private MappingGenerator
delegate
protected DynamicMappingGenerator.InObjectOrPrimitiveJsonGenerator
generator
private String
keyName
private Runnable
writeEnd
private Runnable
writeStart
-
Constructor Summary
Constructors Constructor Description DynamicMappingGenerator(MappingGenerator delegate, Runnable writeStart, Runnable writeEnd, String keyName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private jakarta.json.stream.JsonGenerator
ensureGenerator(jakarta.json.stream.JsonGenerator generator)
void
flushIfNeeded()
jakarta.json.stream.JsonGenerator
getJsonGenerator()
protected jakarta.json.stream.JsonGenerator
getRawJsonGenerator()
protected void
reset()
MappingGenerator
writeObject(Object o, jakarta.json.stream.JsonGenerator generator)
Write the given Object o into the current JSON layer.MappingGenerator
writeObject(String key, Object o, jakarta.json.stream.JsonGenerator generator)
-
-
-
Field Detail
-
delegate
private final MappingGenerator delegate
-
writeStart
private final Runnable writeStart
-
writeEnd
private final Runnable writeEnd
-
keyName
private final String keyName
-
generator
protected DynamicMappingGenerator.InObjectOrPrimitiveJsonGenerator generator
-
-
Constructor Detail
-
DynamicMappingGenerator
public DynamicMappingGenerator(MappingGenerator delegate, Runnable writeStart, Runnable writeEnd, String keyName)
-
-
Method Detail
-
getRawJsonGenerator
protected jakarta.json.stream.JsonGenerator getRawJsonGenerator()
-
getJsonGenerator
public jakarta.json.stream.JsonGenerator getJsonGenerator()
- Specified by:
getJsonGenerator
in interfaceMappingGenerator
- Returns:
- the
JsonGenerator
used internally to write the JSON output.
-
writeObject
public MappingGenerator writeObject(String key, Object o, jakarta.json.stream.JsonGenerator generator)
- Specified by:
writeObject
in interfaceMappingGenerator
-
writeObject
public MappingGenerator writeObject(Object o, jakarta.json.stream.JsonGenerator generator)
Description copied from interface:MappingGenerator
Write the given Object o into the current JSON layer. This will not open a new json layer ('{', '}') but really just write the attributes of o to the currently opened layer. Consider you have a classpublic class Customer { private String firstName; private String lastName; private Address address; ... }
then the resulting JSON String will e.g. look like"firstName":"Karl", "lastName":"SomeName", "address":{"street":"mystreet"}
- Specified by:
writeObject
in interfaceMappingGenerator
- Parameters:
o
- the object to writegenerator
- the jsonp generator to use- Returns:
- itself, for easier chaining of commands
-
ensureGenerator
private jakarta.json.stream.JsonGenerator ensureGenerator(jakarta.json.stream.JsonGenerator generator)
-
reset
protected void reset()
-
flushIfNeeded
public void flushIfNeeded()
-
-