Class Problems

java.lang.Object
org.netbeans.validation.api.Problems
All Implemented Interfaces:
Iterable<Problem>

public final class Problems extends Object implements Iterable<Problem>
A collection of problems, to which a Validator can add additional problems.
Author:
Tim Boudreau
  • Constructor Details

    • Problems

      public Problems()
  • Method Details

    • add

      @Deprecated public final void add(String problem)
      Deprecated.
      use append() instead
      Convenience method to add a problem with the specified message and Severity.FATAL
      Parameters:
      problem -
    • add

      @Deprecated public final void add(String problem, Severity severity)
      Deprecated.
      use append() instead
      Add a problem with the specified severity
      Parameters:
      problem - the message
      severity - the severity
    • add

      @Deprecated public final void add(Problem problem)
      Deprecated.
      use append() instead
      Add a problem
      Parameters:
      problem - The problem (may be null)
    • append

      public final Problems append(String problem)
      Convenience method to add a problem with the specified message and Severity.FATAL
      Parameters:
      problem -
      Returns:
      this
      Since:
      1.6
    • append

      public final Problems append(String problem, Severity severity)
      Add a problem with the specified severity
      Parameters:
      problem - the message
      severity - the severity
      Returns:
      this
      Since:
      1.6
    • append

      public final Problems append(Problem problem)
      Add a problem
      Parameters:
      problem - The problem (may be null)
      Returns:
      this
      Since:
      1.6
    • addAll

      public final Problems addAll(Problems problems)
      Merge a set of problems into this one
      Parameters:
      problems - Problems with validation
      Returns:
      this
      Since:
      1.6
    • putAll

      @Deprecated public final void putAll(Problems problems)
      Deprecated.
      Use addAll instead
      Dump all problems in another instance of Problems into this one.
      Parameters:
      problems - The other problems.
    • hasFatal

      public final boolean hasFatal()
      Determine if this set of problems includes any that are fatal.
      Returns:
      true if a fatal problem has been encountered
    • create

      public static Problems create(String message)
      Create a new Problems with the initial (fatal) problem.
      Parameters:
      message - A localized message
      Returns:
      A Problems
    • create

      public static Problems create(Class<?> localizerClass, String bundleKey)
      Create a Problems which contains the localized message belonging to the passed class and key, according to the lookup semantics of Localizer.
      Parameters:
      localizerClass - A class which (or whose package) has an associated resource bundle
      bundleKey - The key in that bundle
      Returns:
      a Problems with a single fatal problem in it
    • getLeadProblem

      public final Problem getLeadProblem()
      Get the Problem with the highest severity. If there is more than one problem with equal severity, the one first added will be considered more severe.
      Returns:
      The most severe Problem in this set
    • allProblems

      public final List<? extends Problem> allProblems()
      Get the entire set of problems, sorted by severity first, order of addition second.
      Returns:
      A list of Problems
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • throwIfFatalPresent

      public void throwIfFatalPresent(String msg)
    • throwIfFatalPresent

      public void throwIfFatalPresent()
    • iterator

      public Iterator<Problem> iterator()
      Specified by:
      iterator in interface Iterable<Problem>