Search in sources :

Example 1 with TreeTableFormat

use of org.apache.sis.util.collection.TreeTableFormat in project sis by apache.

the class Column method format.

/**
 * Formats the given tree table. This method is used for the implementation of
 * {@link FallbackConverter#toString()} and {@link ConverterRegistry#toString()}
 * methods. Since they are mostly for debugging purpose, we do not bother to cache
 * the {@link TreeTableFormat} instance.
 */
@Debug
static String format(final TreeTable table) {
    final TreeTableFormat format = new TreeTableFormat(null, null);
    format.setColumnSeparatorPattern("?[ ] ← ");
    return format.format(table);
}
Also used : TreeTableFormat(org.apache.sis.util.collection.TreeTableFormat) Debug(org.apache.sis.util.Debug)

Example 2 with TreeTableFormat

use of org.apache.sis.util.collection.TreeTableFormat in project sis by apache.

the class TreeTableView method toString.

/**
 * Returns a string representation of this tree table.
 * The current implementation uses a shared instance of {@link TreeTableFormat}.
 * This is okay for debugging or occasional usages. However for more extensive usages,
 * developers are encouraged to create and configure their own {@link TreeTableFormat}
 * instance.
 *
 * @return a string representation of this tree table.
 */
@Override
public String toString() {
    synchronized (TreeTableView.class) {
        if (format == null) {
            final TreeTableFormat f = new TreeTableFormat(Locale.getDefault(Locale.Category.FORMAT), TimeZone.getDefault());
            f.setColumns(TableColumn.NAME, TableColumn.VALUE);
            format = f;
        }
        /*
             * The NULL_COLLECTION semaphore prevents creation of new empty collections by getter methods
             * (a consequence of lazy instantiation). The intent is to avoid creation of unnecessary objects
             * for all unused properties. Users should not see behavioral difference, except if they override
             * some getters with an implementation invoking other getters. However in such cases, users would
             * have been exposed to null values at XML marshalling time anyway.
             */
        final boolean allowNull = Semaphores.queryAndSet(Semaphores.NULL_COLLECTION);
        try {
            return format.format(this);
        } finally {
            if (!allowNull) {
                Semaphores.clear(Semaphores.NULL_COLLECTION);
            }
        }
    }
}
Also used : TreeTableFormat(org.apache.sis.util.collection.TreeTableFormat)

Example 3 with TreeTableFormat

use of org.apache.sis.util.collection.TreeTableFormat in project sis by apache.

the class TestUtilities method formatNameAndValue.

/**
 * Returns a unlocalized string representation of {@code NAME} and {@code VALUE} columns of the given tree table.
 * Dates and times, if any, will be formatted using the {@code "yyyy-MM-dd HH:mm:ss"} pattern in UTC timezone.
 * This method is used mostly as a convenient way to verify the content of an ISO 19115 metadata object.
 *
 * @param  table  the table for which to get a string representation.
 * @return a unlocalized string representation of the given tree table.
 */
public static String formatNameAndValue(final TreeTable table) {
    synchronized (TestUtilities.class) {
        if (tableFormat == null) {
            final TreeTableFormat f = new TreeTableFormat(null, null);
            f.setColumns(TableColumn.NAME, TableColumn.VALUE);
            tableFormat = f;
        }
        return tableFormat.format(table);
    }
}
Also used : TreeTableFormat(org.apache.sis.util.collection.TreeTableFormat)

Aggregations

TreeTableFormat (org.apache.sis.util.collection.TreeTableFormat)3 Debug (org.apache.sis.util.Debug)1