Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

 

Supported

Media Types

Data Model

Provider registration

Read

Yes

text/csv

org.apache.wink.common.model.csv.CsvDeserializer,
org.apache.wink.common.model.csv.CsvTable,
org.apache.wink.common.model.csv.MultiCsvTable

Not required. Registered by default

Write

Yes

text/csv

org.apache.wink.common.model.csv.CsvSerializer,
org.apache.wink.common.model.csv.CsvTable,
org.apache.wink.common.model.csv.MultiCsvTable

Not required. Registered by default

Examples

TBD

Producing CSV

TBD

Code Block
@GET
@Produces("text/csv")
public CsvTable getJohns() {
    CsvTable cvs = new CsvTable("Id", "First Name", "Last Name", "Email");
    cvs.addRow("1","John","Kennedy","john@Kennedy.org");
    cvs.addRow("2","John","Lennon","john@Lennon.org");
    cvs.addRow("3","John","Malkovich","john@malkovich.org");
    cvs.addRow("4","John","McCain","john@McCain.org");
    return cvs;
}
Consuming CSV

TBD

Code Block
@POST
@Consumes("text/csv")
public void postCsv(CsvTable csv) {
    for (String[] row : csv.getRows()) {
        for(String cell: row){
            System.out.print(cell + " ,");
        }
        System.out.print("\n");
    }
}