All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qiniu.convert.COSObjToString Maven / Gradle / Ivy

There is a newer version: 8.4.8
Show newest version
package com.qiniu.convert;

import com.qcloud.cos.model.COSObjectSummary;
import com.qiniu.interfaces.IStringFormat;
import com.qiniu.util.LineUtils;

import java.io.IOException;
import java.util.List;
import java.util.Set;

public class COSObjToString extends Converter {

    private IStringFormat stringFormatter;

    public COSObjToString(String format, String separator, Set rmFields) throws IOException {
        if (separator == null) throw new IOException("separator can not be null.");
        if ("json".equals(format)) {
            stringFormatter = line -> LineUtils.toFormatString(line, rmFields);
        } else if ("csv".equals(format)) {
            stringFormatter = line -> LineUtils.toFormatString(line, ",", rmFields);
        } else if ("tab".equals(format)) {
            stringFormatter = line -> LineUtils.toFormatString(line, separator, rmFields);
        } else {
            throw new IOException("please check your format for map to string.");
        }
    }

    @Override
    public String convertToV(COSObjectSummary line) throws IOException {
        return stringFormatter.toFormatString(line);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy