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();
}
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);
}
}
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);
}
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);
}
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);
}
}
}
Aggregations