Class AbstractCSVWriter<T>
- java.lang.Object
-
- org.nuxeo.ecm.core.io.marshallers.csv.AbstractCSVWriter<T>
-
- Type Parameters:
T- The Java type to marshall as CSV.
- All Implemented Interfaces:
Marshaller<T>,Writer<T>
- Direct Known Subclasses:
DocumentModelCSVWriter,DocumentModelListCSVWriter,DocumentPropertyCSVWriter,LogEntryCSVWriter,LogEntryListCSVWriter
@Supports("text/csv") public abstract class AbstractCSVWriter<T> extends Object implements Writer<T>
Base class for CSVWriter.It provides you a
CSVPrinterto manage the marshalling.- Since:
- 10.3
-
-
Field Summary
Fields Modifier and Type Field Description protected RenderingContextctxThe currentRenderingContext.protected MarshallerRegistryregistryprotected SchemaManagerschemaManagerstatic StringTEXT_CSVstatic javax.ws.rs.core.MediaTypeTEXT_CSV_TYPE
-
Constructor Summary
Constructors Constructor Description AbstractCSVWriter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanaccept(Class<?> clazz, Type genericType, javax.ws.rs.core.MediaType mediatype)Checks if this marshaller can handle the marshalling request.protected org.apache.commons.csv.CSVPrintergetCSVPrinter(T entity, OutputStream out)protected voidprintCalendar(Calendar value, org.apache.commons.csv.CSVPrinter printer)voidwrite(T entity, Class<?> clazz, Type genericType, javax.ws.rs.core.MediaType mediatype, OutputStream out)Writes the entity to outOutputStreamusing mediatype format.protected abstract voidwrite(T entity, org.apache.commons.csv.CSVPrinter printer)protected abstract voidwriteHeader(T entity, org.apache.commons.csv.CSVPrinter printer)
-
-
-
Field Detail
-
TEXT_CSV
public static final String TEXT_CSV
- See Also:
- Constant Field Values
-
TEXT_CSV_TYPE
public static final javax.ws.rs.core.MediaType TEXT_CSV_TYPE
-
ctx
@Inject protected RenderingContext ctx
The currentRenderingContext.
-
schemaManager
@Inject protected SchemaManager schemaManager
-
registry
@Inject protected MarshallerRegistry registry
-
-
Method Detail
-
accept
public boolean accept(Class<?> clazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Description copied from interface:MarshallerChecks if this marshaller can handle the marshalling request.Please note it's useless to check that clazz is an instance of EntityType or if generic type and entity type are compatible (unlike JAX-RS which just checks the clazz, not the generic type). It's also useless to check
Supportsis compatible with mediatype. This is already done by theMarshallerRegistryThis method implementation can use injected properties. So you can check the current
RenderingContextto accept or reject a marshalling request.- Specified by:
acceptin interfaceMarshaller<T>- Parameters:
clazz- The type to marshall.genericType- The generic type to marshall.mediatype- The managed mimetype.- Returns:
- true if this converter handle the request, false otherwise.
-
write
public void write(T entity, Class<?> clazz, Type genericType, javax.ws.rs.core.MediaType mediatype, OutputStream out) throws IOException
Description copied from interface:WriterWrites the entity to outOutputStreamusing mediatype format.This method implementation can use injected properties.
- Specified by:
writein interfaceWriter<T>- Parameters:
entity- The entity to marshall.clazz- The requested marshalled class.genericType- The requested marshalled generic type.mediatype- The target mediatype.out- The output of this marshaller.- Throws:
IOException- If some error append while writing entity to out.
-
write
protected abstract void write(T entity, org.apache.commons.csv.CSVPrinter printer) throws IOException
- Throws:
IOException
-
writeHeader
protected abstract void writeHeader(T entity, org.apache.commons.csv.CSVPrinter printer) throws IOException
- Throws:
IOException
-
getCSVPrinter
protected org.apache.commons.csv.CSVPrinter getCSVPrinter(T entity, OutputStream out) throws IOException
- Throws:
IOException
-
printCalendar
protected void printCalendar(Calendar value, org.apache.commons.csv.CSVPrinter printer) throws IOException
- Throws:
IOException
-
-