Search in sources :

Example 6 with Debug

use of org.apache.sis.util.Debug in project sis by apache.

the class CRSBuilder method toString.

/**
 * Returns a string representation of the keys and associated values in this {@code CRSBuilder}.
 */
@Debug
@Override
public final String toString() {
    final StringBuilder buffer = new StringBuilder("GeoTIFF keys ").append(majorRevision).append('.').append(minorRevision).append(" in ").append(reader.input.filename).append(System.lineSeparator());
    final TableAppender table = new TableAppender(buffer, " ");
    for (Map.Entry<Short, Object> entry : geoKeys.entrySet()) {
        final short key = entry.getKey();
        table.append(String.valueOf(key)).nextColumn();
        table.append(GeoKeys.name(key)).nextColumn();
        table.append(" = ").append(String.valueOf(entry.getValue())).nextLine();
    }
    try {
        table.flush();
    } catch (IOException e) {
        // Should never happen since we wrote to a StringBuffer.
        throw new AssertionError(e);
    }
    return buffer.toString();
}
Also used : TableAppender(org.apache.sis.io.TableAppender) IdentifiedObject(org.opengis.referencing.IdentifiedObject) NilReferencingObject(org.apache.sis.internal.referencing.NilReferencingObject) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap) Debug(org.apache.sis.util.Debug)

Example 7 with Debug

use of org.apache.sis.util.Debug in project sis by apache.

the class MathTransformTestCase method printInternalWKT.

/**
 * Prints the current {@linkplain #transform transform} as normal and internal WKT.
 * This method is for debugging purpose only.
 */
@Debug
protected final void printInternalWKT() {
    @SuppressWarnings("UseOfSystemOutOrSystemErr") final TableAppender table = new TableAppender(System.out);
    table.setMultiLinesCells(true);
    table.appendHorizontalSeparator();
    table.append("WKT of “").append(getName()).append('”').nextColumn();
    table.append("Internal WKT").appendHorizontalSeparator();
    String wkt;
    try {
        wkt = transform.toWKT();
    } catch (UnsupportedOperationException e) {
        wkt = transform.toString();
    }
    table.append(wkt).nextColumn();
    if (transform instanceof FormattableObject) {
        wkt = ((FormattableObject) transform).toString(Convention.INTERNAL);
    } else {
        wkt = transform.toString();
    }
    table.append(wkt).appendHorizontalSeparator();
    try {
        table.flush();
    } catch (IOException e) {
        throw new AssertionError(e);
    }
}
Also used : TableAppender(org.apache.sis.io.TableAppender) IOException(java.io.IOException) FormattableObject(org.apache.sis.io.wkt.FormattableObject) Debug(org.apache.sis.util.Debug)

Example 8 with Debug

use of org.apache.sis.util.Debug 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 9 with Debug

use of org.apache.sis.util.Debug in project sis by apache.

the class FallbackConverter method toString.

/**
 * Returns a tree representation of this converter.
 * The tree leaves represent the backing converters.
 */
@Debug
@Override
public String toString() {
    final TreeTable table = Column.createTable();
    toTree(table.getRoot(), true);
    return Column.format(table);
}
Also used : TreeTable(org.apache.sis.util.collection.TreeTable) Debug(org.apache.sis.util.Debug)

Example 10 with Debug

use of org.apache.sis.util.Debug in project sis by apache.

the class IndexedResourceBundle method list.

/**
 * Lists resources to the specified stream. If a resource has more than one line, only
 * the first line will be written. This method is used mostly for debugging purposes.
 *
 * @param  out  the destination stream.
 * @throws IOException if an output operation failed.
 */
@Debug
public final void list(final Appendable out) throws IOException {
    int keyLength = 0;
    final String[] keys = getKeyConstants().getKeyNames();
    for (final String key : keys) {
        if (key != null) {
            keyLength = Math.max(keyLength, key.length());
        }
    }
    final String lineSeparator = System.lineSeparator();
    final String[] values = ensureLoaded(null);
    for (int i = 0; i < values.length; i++) {
        final String key = keys[i];
        final String value = values[i];
        if (key != null && value != null) {
            int indexCR = value.indexOf('\r');
            if (indexCR < 0)
                indexCR = value.length();
            int indexLF = value.indexOf('\n');
            if (indexLF < 0)
                indexLF = value.length();
            final String number = String.valueOf(i);
            out.append(CharSequences.spaces(5 - number.length())).append(number).append(": ").append(key).append(CharSequences.spaces(keyLength - key.length())).append(" = ").append(value, 0, Math.min(indexCR, indexLF)).append(lineSeparator);
        }
    }
}
Also used : InternationalString(org.opengis.util.InternationalString) Debug(org.apache.sis.util.Debug)

Aggregations

Debug (org.apache.sis.util.Debug)20 IOException (java.io.IOException)4 InternationalString (org.opengis.util.InternationalString)4 TableAppender (org.apache.sis.io.TableAppender)3 ParameterBuilder (org.apache.sis.parameter.ParameterBuilder)3 TreeTable (org.apache.sis.util.collection.TreeTable)3 Map (java.util.Map)2 Parameters (org.apache.sis.parameter.Parameters)2 Console (java.io.Console)1 PrintWriter (java.io.PrintWriter)1 UncheckedIOException (java.io.UncheckedIOException)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 NilReferencingObject (org.apache.sis.internal.referencing.NilReferencingObject)1 FormattableObject (org.apache.sis.io.wkt.FormattableObject)1 ObjectConverter (org.apache.sis.util.ObjectConverter)1 DefaultTreeTable (org.apache.sis.util.collection.DefaultTreeTable)1 TreeTableFormat (org.apache.sis.util.collection.TreeTableFormat)1 ParameterDescriptor (org.opengis.parameter.ParameterDescriptor)1