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

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

package io.bdeploy.common.cli.data;

import java.io.PrintStream;
import java.util.List;

class DataTableJson extends DataTableBase {

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

    @Override
    public void doRender() {
        output.println("[");

        for (int i = 0; i < rows.size(); ++i) {
            List row = rows.get(i);

            output.print("  { ");

            int colIndex = 0;
            for (int y = 0; y < row.size(); ++y) {
                DataTableColumn col = columns.get(colIndex);

                output.print(DataRenderingHelper.quoteJson(col.getName()) + ": "
                        + DataRenderingHelper.quoteJson(row.get(y).getData()));

                if (y == (row.size() - 1)) {
                    if (i == (rows.size() - 1)) {
                        output.println(" }");
                    } else {
                        output.println(" },");
                    }
                } else {
                    output.print(", ");
                }

                colIndex += row.get(y).getSpan();
            }
        }

        output.println("]");
    }

    @Override
    public DataTable addHorizontalRuler() {
        // Ignored
        return this;
    }

    @Override
    public DataTable setHideHeadersHint(boolean hide) {
        // Ignored
        return this;
    }

    @Override
    public DataTable setLineWrapHint(boolean wrap) {
        // Ignored
        return this;
    }

    @Override
    public DataTable setWordBreakHint(boolean allowBreak) {
        // Ignored
        return this;
    }

    @Override
    public DataTable setIndentHint(int indent) {
        // Ignored
        return this;
    }

    @Override
    public DataTable setMaxTableLengthHint(int maxTableLength) {
        // Ignored
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy