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

io.bdeploy.common.cli.data.DataResultCsv Maven / Gradle / Ivy

Go to download

Public API including dependencies, ready to be used for integrations and plugins.

There is a newer version: 7.4.0
Show newest version
package io.bdeploy.common.cli.data;

import java.io.PrintStream;
import java.util.Map;

import io.bdeploy.common.util.ExceptionHelper;

class DataResultCsv extends DataResultBase {

    DataResultCsv(PrintStream output) {
        super(output);
    }

    @Override
    public void render() {
        out().println("\"Result Field\",\"Result Value\"");
        if (getMessage() != null) {
            out().println("\"Message\"," + DataRenderingHelper.quoteCsv(getMessage()));
        }

        if (getThrowable() != null) {
            out().println(
                    "\"Error\"," + DataRenderingHelper.quoteCsv(ExceptionHelper.mapExceptionCausesToReason(getThrowable())));
        } else {
            for (Map.Entry entry : getFields().entrySet()) {
                out().println(
                        DataRenderingHelper.quoteCsv(entry.getKey()) + "," + DataRenderingHelper.quoteCsv(entry.getValue()));
            }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy