EntityType
- The type of the element of this list.public abstract class DefaultListJsonWriter<EntityType> extends AbstractJsonWriter<List<EntityType>>
List
as json.
It follow the classic Nuxeo list format :
{
"entity-type": "GIVEN_ENTITY_TYPE",
<-- pagination info if available are here.
"entries": [
{...}, <-- A Writer
must be able to manage this format.
{...},
...
{...}
]
}
This list generates pagination information if the list is a Paginable
.
This reader delegates the marshalling of entries to the MarshallerRegistry
. A Json Writer
compatible
with the required type must be registered.
ctx, registry
Constructor and Description |
---|
DefaultListJsonWriter(String entityType,
Class<EntityType> elClazz)
Use this constructor if the element of the list are not based on Java generic type.
|
DefaultListJsonWriter(String entityType,
Class<EntityType> elClazz,
Type elGenericType)
Use this constructor if the element of the list are based on Java generic type.
|
Modifier and Type | Method and Description |
---|---|
protected void |
extend(List<EntityType> list,
org.codehaus.jackson.JsonGenerator jg)
Override this method to write additional information in the list.
|
void |
write(List<EntityType> list,
org.codehaus.jackson.JsonGenerator jg)
Implement this method to writes the entity in the provided
JsonGenerator . |
accept, getGenerator, write, writeEntity, writeEntity, writeEntityField
public DefaultListJsonWriter(String entityType, Class<EntityType> elClazz)
entityType
- The list "entity-type".elClazz
- The class of the element of the list.public DefaultListJsonWriter(String entityType, Class<EntityType> elClazz, Type elGenericType)
entityType
- The list "entity-type".elClazz
- The class of the element of the list.elGenericType
- The generic type of the list (you can use to
generate it
public void write(List<EntityType> list, org.codehaus.jackson.JsonGenerator jg) throws IOException
AbstractJsonWriter
JsonGenerator
.
This method implementation can use injected properties.
The JsonGenerator
's flushing is done by this abstract class, it's also not not necessary to flush it. Do
not close the provided JsonGenerator
. It may be used is another marshaller calling this one.
write
in class AbstractJsonWriter<List<EntityType>>
list
- The entity to marshall as Json.jg
- The JsonGenerator
used to produce Json output.IOException
protected void extend(List<EntityType> list, org.codehaus.jackson.JsonGenerator jg) throws IOException
list
- The list to marshal.jg
- The JsonGenerator
which point inside the list object at the end of standard properties.IOException
Copyright © 2018 Nuxeo. All rights reserved.