
com.qiniu.convert.LineToMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qsuits Show documentation
Show all versions of qsuits Show documentation
qiniu-suits is a efficient tools for qiniu api implemented by java8.
package com.qiniu.convert;
import com.qiniu.interfaces.ILineParser;
import com.qiniu.interfaces.ITypeConvert;
import com.qiniu.util.LineUtils;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
public class LineToMap implements ITypeConvert> {
private ILineParser lineParser;
private List errorList = new ArrayList<>();
public LineToMap(String parseType, String separator, Map indexMap) throws IOException {
if ("json".equals(parseType)) {
this.lineParser = line -> LineUtils.getItemMap(line, indexMap, false);
} else if ("csv".equals(parseType)) {
this.lineParser = line -> LineUtils.getItemMap(line, ",", indexMap, false);
} else if ("tab".equals(parseType)) {
this.lineParser = line -> LineUtils.getItemMap(line, separator, indexMap, false);
} else {
throw new IOException("please check your format for line to map.");
}
}
public Map convertToV(String line) throws IOException {
return lineParser.getItemMap(line);
}
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy