Class LoadResult<R>

java.lang.Object
esa.opensf.osfi.LoadResult<R>
Type Parameters:
R - Type of the result object

public final class LoadResult<R> extends Object
Immutable type that represents the result of a "load" operation, either from ParamReader loading some configuration file, or raw parsing/validation of an XML file. It encapsulates the actual result together with a list of events of varying severities, e.g. warnings and errors collected during validation.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Helper that processes events during a load operation to generate a LoadResult.
    static final class 
    "Event" raised during a load operation (of parameters, of an XML file, etc).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Events recorded during the process.
    final R
    Result of the load operation.
    static final int
    Partially recoverable problems with the data source that imply a certain loss of data but which do not prevent further processing.
    static final int
    Unrecoverable problems with the data source that stop all processing.
    static final int
    General reports that do not represent any problem with the data source.
    static final int
    Recoverable issues with the data source e.g.
    final String
    Data source for the operation, e.g.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    hasEvents(int minSeverity)
     
    Equivalent to calling unwrap(int) with SEV_ERROR.
    unwrap(int minThrowSeverity)
    If no events at or above the given severity level exist, return result.

    Methods inherited from class java.lang.Object

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

    • SEV_INFO

      public static final int SEV_INFO
      General reports that do not represent any problem with the data source.
      See Also:
    • SEV_WARNING

      public static final int SEV_WARNING
      Recoverable issues with the data source e.g. a <parameter> element that still stores its data in the deprecated value attribute.
      See Also:
    • SEV_ERROR

      public static final int SEV_ERROR
      Partially recoverable problems with the data source that imply a certain loss of data but which do not prevent further processing. For example, a <parameter> element of MATRIX type that contains an invalid number of columns in a row. The parameter itself cannot be parsed and is lost, but the rest of the file can be parsed.
      See Also:
    • SEV_FATAL

      public static final int SEV_FATAL
      Unrecoverable problems with the data source that stop all processing. For example, malformed XML in a configuration file will often prevent further parsing, and no results can be extracted.
      See Also:
    • source

      public final String source
      Data source for the operation, e.g. a file. Never null.
    • result

      public final R result
      Result of the load operation. May be null if errors stopped the process.
    • loadEvents

      public final List<LoadResult.Event> loadEvents
      Events recorded during the process. May be empty but never null.
  • Method Details

    • hasEvents

      public boolean hasEvents(int minSeverity)
      Parameters:
      minSeverity - cutoff value, events below this level are not considered.
      Returns:
      true if any events with at least the given severity have been recorded.
    • unwrap

      public R unwrap(int minThrowSeverity) throws XmlParseException
      If no events at or above the given severity level exist, return result. Otherwise, throw a XmlParseException with the first such event as its cause.
      Parameters:
      minThrowSeverity - Events below this level will be ignored in the check.
      Returns:
      The result field of this instance
      Throws:
      XmlParseException - if any event with severity equal or higher than the argument exists
    • unwrap

      public R unwrap() throws XmlParseException
      Equivalent to calling unwrap(int) with SEV_ERROR.
      Returns:
      The result field of this instance
      Throws:
      XmlParseException - if any event with severity equal or higher than the argument exists