use of org.apache.sis.util.Debug in project sis by apache.
the class ConverterRegistry method toString.
/**
* Returns a string representation of registered converters for debugging purpose.
* The converters are show in a tree where all real converters are leafs. Parents
* of those leafs are {@link FallbackConverter}s which delegate their work to the
* leafs.
*
* @return a string representation of registered converters.
*/
@Debug
@Override
public String toString() {
final TreeTable table = Column.createTable();
final TreeTable.Node root = table.getRoot();
root.setValue(Column.TARGET, getClass());
synchronized (converters) {
for (final Map.Entry<ClassPair<?, ?>, ObjectConverter<?, ?>> entry : converters.entrySet()) {
TreeTable.Node addTo = root;
final ClassPair<?, ?> key = entry.getKey();
final ObjectConverter<?, ?> converter = entry.getValue();
if (converter.getSourceClass() != key.sourceClass || converter.getTargetClass() != key.targetClass) {
/*
* If we enter this block, then the converter is not really for this
* (source, target) classes pair. Instead, we are leveraging a converter
* which was defined for an other ClassPair. We show this fact be first
* showing this ClassPair, then the actual converter (source, target) as
* below:
*
* Number ← String (the ClassPair key)
* └─Integer ← String (the ObjectConverter value)
*
* This is the same idea than the formatting done by FallbackConverter,
* except that there is only one child. Actually this can be though as
* a lightweight fallback converter.
*/
addTo = addTo.newChild();
addTo.setValue(Column.SOURCE, key.sourceClass);
addTo.setValue(Column.TARGET, key.targetClass);
}
if (converter instanceof FallbackConverter<?, ?>) {
((FallbackConverter<?, ?>) converter).toTree(addTo.newChild(), true);
} else {
Column.toTree(converter, addTo);
}
}
}
return Column.format(table);
}
use of org.apache.sis.util.Debug in project sis by apache.
the class StorageConnector method toString.
/**
* Returns a string representation of this {@code StorageConnector} for debugging purpose.
* This string representation is for debugging purpose only and may change in any future version.
*
* @return a string representation of this {@code StorageConnector} for debugging purpose.
*/
@Debug
@Override
public String toString() {
final TreeTable table = new DefaultTreeTable(TableColumn.NAME, TableColumn.VALUE);
final TreeTable.Node root = table.getRoot();
root.setValue(TableColumn.NAME, Classes.getShortClassName(this));
root.setValue(TableColumn.VALUE, getStorageName());
if (options != null) {
final TreeTable.Node op = root.newChild();
op.setValue(TableColumn.NAME, "options");
op.setValue(TableColumn.VALUE, options);
}
final Coupled c = getView(null);
if (c != null) {
c.append(root.newChild(), views);
}
return table.toString();
}
use of org.apache.sis.util.Debug in project sis by apache.
the class AbstractOperation method toString.
/**
* Returns a string representation of this operation.
* The returned string is for debugging purpose and may change in any future SIS version.
*
* @return a string representation of this operation for debugging purpose.
*/
@Debug
@Override
public String toString() {
final StringBuilder buffer = new StringBuilder(40).append(Classes.getShortClassName(this)).append('[');
final GenericName name = getName();
if (name != null) {
buffer.append('“');
}
buffer.append(name);
if (name != null) {
buffer.append('”');
}
final AbstractIdentifiedType result = getResult();
if (result != null) {
final Object type;
if (result instanceof DefaultAttributeType<?>) {
type = Classes.getShortName(((DefaultAttributeType<?>) result).getValueClass());
} else {
type = result.getName();
}
buffer.append(" : ").append(type);
}
try {
formatResultFormula(buffer.append("] = "));
} catch (IOException e) {
// Should never happen since we write in a StringBuilder.
throw new UncheckedIOException(e);
}
return buffer.toString();
}
use of org.apache.sis.util.Debug in project sis by apache.
the class MolodenskyFormula method getParameterValues.
/**
* Returns a copy of internal parameter values of this transform.
* The returned group contains parameters for the source ellipsoid semi-axis lengths
* and the differences between source and target ellipsoid parameters.
*
* <div class="note"><b>Note:</b>
* this method is mostly for {@linkplain org.apache.sis.io.wkt.Convention#INTERNAL debugging purposes}
* since the isolation of non-linear parameters in this class is highly implementation dependent.
* Most GIS applications will instead be interested in the {@linkplain #getContextualParameters()
* contextual parameters}.</div>
*
* @return a copy of the internal parameter values for this transform.
*/
@Debug
@Override
public ParameterValueGroup getParameterValues() {
final Unit<?> unit = context.getOrCreate(Molodensky.SRC_SEMI_MAJOR).getUnit();
final double semiMinor = context.getOrCreate(Molodensky.SRC_SEMI_MINOR).doubleValue(unit);
final Parameters pg = Parameters.castOrWrap(getParameterDescriptors().createValue());
pg.getOrCreate(Molodensky.SRC_SEMI_MAJOR).setValue(semiMajor, unit);
pg.getOrCreate(Molodensky.SRC_SEMI_MINOR).setValue(semiMinor, unit);
completeParameters(pg, semiMinor, unit, Double.NaN);
return pg;
}
use of org.apache.sis.util.Debug in project sis by apache.
the class FormattableObject method print.
/**
* Prints a string representation of this object to the {@linkplain System#out standard output stream}.
* If a {@linkplain Console console} is attached to the running JVM (i.e. if the application is run
* from the command-line and the output is not redirected to a file) and if Apache SIS thinks that
* the console supports the ANSI escape codes (a.k.a. X3.64), then a syntax coloring will be applied.
*
* <p>This is a convenience method for debugging purpose and for console applications.</p>
*/
@Debug
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public void print() {
final Console console = System.console();
final PrintWriter out = (console != null) ? console.writer() : null;
final String wkt = formatWKT(Convention.WKT2_SIMPLIFIED, (out != null) && X364.isAnsiSupported(), false);
if (out != null) {
out.println(wkt);
} else {
System.out.println(wkt);
}
}
Aggregations