Search in sources :

Example 1 with Debug

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);
}
Also used : ObjectConverter(org.apache.sis.util.ObjectConverter) TreeTable(org.apache.sis.util.collection.TreeTable) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Debug(org.apache.sis.util.Debug)

Example 2 with Debug

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();
}
Also used : DefaultTreeTable(org.apache.sis.util.collection.DefaultTreeTable) TreeTable(org.apache.sis.util.collection.TreeTable) DefaultTreeTable(org.apache.sis.util.collection.DefaultTreeTable) Debug(org.apache.sis.util.Debug)

Example 3 with Debug

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();
}
Also used : GenericName(org.opengis.util.GenericName) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Debug(org.apache.sis.util.Debug)

Example 4 with Debug

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;
}
Also used : Parameters(org.apache.sis.parameter.Parameters) Debug(org.apache.sis.util.Debug)

Example 5 with Debug

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);
    }
}
Also used : Console(java.io.Console) PrintWriter(java.io.PrintWriter) 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