Skip to content

Commit

Permalink
Update Apache Commons.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Oct 26, 2023
1 parent 8e4342d commit 024c2c7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class FileContentMatcherPeak extends AbstractFileContentMatcher implement
public boolean checkFileFormat(File file) {

try {
try (CSVParser parser = new CSVParser(new FileReader(file), CSVFormat.EXCEL.withHeader())) {
CSVFormat csvFormat = CSVFormat.EXCEL.builder().setHeader().build();
try (CSVParser parser = new CSVParser(new FileReader(file), csvFormat)) {
String[] array = parser.getHeaderMap().keySet().toArray(new String[0]);
return Arrays.equals(array, CSVPeakConverter.HEADERS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public IProcessingInfo<IPeaks<?>> convert(File file, IProgressMonitor monitor) {

public static void writePeaks(IPeaks<? extends IPeak> peaks, Writer writer, boolean writeHeader) throws IOException {

try (CSVPrinter csv = new CSVPrinter(writer, CSVFormat.EXCEL.withNullString("").withQuoteMode(QuoteMode.ALL))) {
CSVFormat csvFormat = CSVFormat.EXCEL.builder().setNullString("").setQuoteMode(QuoteMode.ALL).build();
try (CSVPrinter csv = new CSVPrinter(writer, csvFormat)) {
if(writeHeader) {
csv.printRecord(Arrays.asList(HEADERS));
}
Expand Down Expand Up @@ -214,7 +215,8 @@ public static void writePeaks(IPeaks<? extends IPeak> peaks, Writer writer, bool
public static IPeaks<IPeak> readPeaks(Reader reader) throws IOException, ParseException {

Peaks result = new Peaks();
try (CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader(HEADERS).withSkipHeaderRecord())) {
CSVFormat csvFormat = CSVFormat.EXCEL.builder().setHeader(HEADERS).setSkipHeaderRecord(true).build();
try (CSVParser parser = new CSVParser(reader, csvFormat)) {
NumberFormat nf;
synchronized(NUMBER_FORMAT) {
nf = (NumberFormat)NUMBER_FORMAT.clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private IChromatogramMSD readChromatogram(File file, boolean overview) throws IO
String zeroMarker = PreferenceSupplier.getImportZeroMarker();
zeroMarker = zeroMarker.startsWith(ZERO_VALUE) ? zeroMarker : ZERO_VALUE;
char delimiter = PreferenceSupplier.getImportDelimiter().getCharacter();
CSVParser csvParser = new CSVParser(fileReader, CSVFormat.newFormat(delimiter).withHeader());
CSVParser csvParser = new CSVParser(fileReader, CSVFormat.newFormat(delimiter).builder().setHeader().build());
chromatogram = new VendorChromatogram();
if(!overview) {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ public class PCRExportConverter extends AbstractPlateExportConverter implements
private static final Logger logger = Logger.getLogger(PCRExportConverter.class);
//
private static final String DESCRIPTION = "PCR CSV Export";
private static final CSVFormat csvFormat = CSVFormat.RFC4180.withDelimiter(PreferenceSupplier.getDelimiter().getCharacter());
//
private DecimalFormat decimalFormat = new DecimalFormat("00" + PreferenceSupplier.getDecimalSeparator().getCharacter() + "00");

@Override
public IProcessingInfo<File> convert(File file, IPlate plate, IProgressMonitor monitor) {

decimalFormat.applyPattern("#,##0.00");
CSVFormat csvFormat = CSVFormat.RFC4180.builder() //
.setDelimiter(PreferenceSupplier.getDelimiter().getCharacter()).build();
IProcessingInfo<File> processingInfo = new ProcessingInfo<>();
if(plate != null) {
try (CSVPrinter csvPrinter = new CSVPrinter(new FileWriter(file, false), csvFormat)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ private Samples extract() {
/*
* Data
*/
CSVParser parser = new CSVParser(reader, CSVFormat.TDF.withHeader());
CSVFormat csvFormat = CSVFormat.TDF.builder().setHeader().build();
CSVParser parser = new CSVParser(reader, csvFormat);
Map<Integer, String> indexMap = extractIndexMap(parser);
for(CSVRecord record : parser.getRecords()) {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
<version>1.16.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<version>2.14.0</version>
<type>jar</type>
</dependency>
<dependency>
Expand All @@ -56,19 +56,19 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.22</version>
<version>1.24.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.8</version>
<version>1.10.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<version>3.13.0</version>
<type>jar</type>
</dependency>
<dependency>
Expand Down

0 comments on commit 024c2c7

Please sign in to comment.