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

io.deephaven.engine.util.HtmlTable Maven / Gradle / Ivy

There is a newer version: 0.37.1
Show newest version
/**
 * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
 */
package io.deephaven.engine.util;

import io.deephaven.engine.table.Table;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.engine.rowset.RowSet;
import io.deephaven.time.DateTimeUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.jetbrains.annotations.NotNull;

import java.time.Instant;
import java.util.Collection;
import java.util.List;

public class HtmlTable {
    @NotNull
    public static String html(Table source) {
        List columnNames = source.getDefinition().getColumnNames();
        String[] columns = columnNames.toArray(new String[columnNames.size()]);
        StringBuilder out = new StringBuilder();
        out.append("\n");

        out.append("\n");
        for (String column : columns) {
            out.append("\n");
        }
        out.append("\n");

        final Collection columnSources = source.getColumnSources();
        for (final RowSet.Iterator ii = source.getRowSet().iterator(); ii.hasNext();) {
            out.append("");
            final long key = ii.nextLong();
            for (ColumnSource columnSource : columnSources) {
                out.append("");
            }
            out.append("\n");
        }
        out.append("
").append(column).append("
"); final Object value = columnSource.get(key); if (value instanceof String) { out.append(StringEscapeUtils.escapeCsv((String) value)); } else if (value instanceof Instant) { out.append(DateTimeUtils.formatDateTime((Instant) value, DateTimeUtils.timeZone())); } else { out.append(TableTools.nullToNullString(value)); } out.append("
\n"); return out.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy