Example usage for com.google.common.collect ArrayTable toArray

List of usage examples for com.google.common.collect ArrayTable toArray

Introduction

In this page you can find the example usage for com.google.common.collect ArrayTable toArray.

Prototype

@GwtIncompatible("reflection")
public V[][] toArray(Class<V> valueClass) 

Source Link

Document

Returns a two-dimensional array with the table contents.

Usage

From source file:lu.list.itis.dkd.aig.util.MatrixFormatter.java

/**
 * Method returning the matrix in CSV format.
 *
 * @param matrix// w  w  w. j a  va  2s  .com
 *        The matrix to format.
 * @return A string representation in CSV format of the matrix.
 */
public static String format(final ArrayTable<Match, Match, Float> matrix) {
    final StringBuilder stringBuilder = new StringBuilder();
    final Joiner joiner = Joiner.on("; ").useForNull("0"); //$NON-NLS-1$ //$NON-NLS-2$
    final Float[][] values = matrix.toArray(Float.class);

    stringBuilder.append(joiner.join(matrix.columnKeySet()));
    stringBuilder.append("\n"); //$NON-NLS-1$

    for (final Float[] value : values) {
        stringBuilder.append(joiner.join(value));
        stringBuilder.append("\n"); //$NON-NLS-1$
    }

    return stringBuilder.toString();
}