Class ErrorHandler.Report

java.lang.Object
org.apache.sis.image.ErrorHandler.Report
Enclosing interface:
ErrorHandler

public static class ErrorHandler.Report extends Object
Information about errors that occurred while reading or writing tiles in an image. A single Report may be generated for failures in more than one tiles.

Multi-threading

This class is safe for use in multi-threading. The synchronization lock is this. However, the LogRecord instance returned by getDescription() is not thread-safe. Operations applied on the LogRecord should be inside a block synchronized on the Report.this lock.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private LogRecord
    Description of the error that occurred, or null if none.
    private int[]
    The tile indices as (x,y) tuples where errors occurred, or null if none.
    private int
    Number of valid elements in indices.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an initially empty report.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(Point tile, Throwable error, Supplier<LogRecord> record)
    Reports an error that occurred while computing an image tile.
    private static void
    Adds the more exception to the list if suppressed exceptions if not already present.
    private static boolean
    Returns true if the given exceptions are of the same class, have the same message and the same stack trace.
    Returns a description of the first error as a log record.
    Returns indices of all tiles where an error has been reported.
    boolean
    Returns true if no error has been reported.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • indices

      private int[] indices
      The tile indices as (x,y) tuples where errors occurred, or null if none.
    • length

      private int length
      Number of valid elements in indices.
    • description

      private LogRecord description
      Description of the error that occurred, or null if none.
  • Constructor Details

    • Report

      public Report()
      Creates an initially empty report. Error reports can be added by calls to add(…).
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns true if no error has been reported. This is true only if the add(…) method has never been invoked.
      Returns:
      whether this report is empty.
    • equals

      private static boolean equals(Throwable t1, Throwable t2)
      Returns true if the given exceptions are of the same class, have the same message and the same stack trace. The cause and the suppressed exceptions are ignored.
    • addSuppressed

      private static void addSuppressed(Throwable error, Throwable more)
      Adds the more exception to the list if suppressed exceptions if not already present.
    • add

      public boolean add(Point tile, Throwable error, Supplier<LogRecord> record)
      Reports an error that occurred while computing an image tile. This method can be invoked many times on the same Report instance.

      Logging information

      Report creates a LogRecord the first time that this add(…) method is invoked. The log record is created using the given supplier if non-null. That supplier should set the log level, message, source class name, source method name and logger name. The exception property will be set by this method.
      Parameters:
      tile - column (x) and row (y) indices of the tile where the error occurred, or null if unknown.
      error - the error that occurred.
      record - the record supplier, invoked only when this method is invoked for the first time. If null, a default LogRecord will be created.
      Returns:
      true if this is the first time that an error is reported (in which case a LogRecord instance has been created), or false if a LogRecord already exists.
    • getTileIndices

      public Point[] getTileIndices()
      Returns indices of all tiles where an error has been reported.
      Returns:
      indices of all tiles in error, or an empty array if none.
    • getDescription

      public LogRecord getDescription()
      Returns a description of the first error as a log record. The exception can be obtained by LogRecord.getThrown(). If more than one error occurred, the other errors are reported as suppressed exceptions. The return value is never null unless this report is empty.
      Returns:
      errors description, or null if this report is empty.