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

TBDThe following code example demonstrates the reading and writing of CSV documents.

Producing CSV

TBDThe following code example demonstrates the creation of a CSV document.

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

TBDThe following code example demonstrates the consumption of a CSV document.

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");
    }
}
Explanation

...