Skip to content

Commit

Permalink
Merge branch 'remove-csvfactory'
Browse files Browse the repository at this point in the history
  • Loading branch information
sett4 committed Jul 28, 2019
2 parents 9aa2a0e + e78ee41 commit 5a7be13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
26 changes: 5 additions & 21 deletions src/main/java/com/github/sett4/dataformat/xlsx/XlsxMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
import com.fasterxml.jackson.databind.util.LRUMap;
import com.fasterxml.jackson.databind.util.NameTransformer;
import com.fasterxml.jackson.dataformat.csv.CsvFactory;
import com.fasterxml.jackson.dataformat.csv.CsvParser;
import com.fasterxml.jackson.dataformat.csv.CsvSchema;

import java.util.Collection;
Expand Down Expand Up @@ -81,27 +79,13 @@ public XlsxMapper configure(XlsxGenerator.Feature f, boolean state) {
return state ? enable(f) : disable(f);
}

public XlsxMapper configure(CsvParser.Feature f, boolean state) {
return state ? enable(f) : disable(f);
}

public XlsxMapper enable(XlsxGenerator.Feature f) {
((CsvFactory) _jsonFactory).enable(f);
return this;
}

public XlsxMapper enable(CsvParser.Feature f) {
((CsvFactory) _jsonFactory).enable(f);
_jsonFactory.enable(f);
return this;
}

public XlsxMapper disable(XlsxGenerator.Feature f) {
((CsvFactory) _jsonFactory).disable(f);
return this;
}

public XlsxMapper disable(CsvParser.Feature f) {
((CsvFactory) _jsonFactory).disable(f);
_jsonFactory.disable(f);
return this;
}

Expand All @@ -113,11 +97,11 @@ public XlsxMapper disable(CsvParser.Feature f) {

/**
* Overridden with more specific type, since factory we have
* is always of type {@link CsvFactory}
* is always of type {@link XlsxFactory}
*/
@Override
public CsvFactory getFactory() {
return (CsvFactory) _jsonFactory;
public XlsxFactory getFactory() {
return (XlsxFactory) _jsonFactory;
}

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.github.sett4.dataformat.xlsx.serialize;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SequenceWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
import com.github.sett4.dataformat.xlsx.ModuleTestBase;
import com.github.sett4.dataformat.xlsx.XlsxGenerator;
import com.github.sett4.dataformat.xlsx.XlsxMapper;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
Expand All @@ -31,6 +34,7 @@ public void testSchema() throws Exception {
System.out.println(file);

XlsxMapper mapper = new XlsxMapper();
mapper.enable(XlsxGenerator.Feature.WRITE_NUMBERS_AS_STRINGS);
CsvSchema schema = mapper.schemaFor(FiveMinuteUser.class).withHeader();
SequenceWriter sequenceWriter = mapper.writer(schema).writeValues(file);
sequenceWriter.write(user);
Expand Down

0 comments on commit 5a7be13

Please sign in to comment.