Class SimpleProblem

  • All Implemented Interfaces:
    Problem

    public class SimpleProblem
    extends java.lang.Object
    implements Problem
    A default implementation serving as template for more specialized problems.
    Version:
    $Revision: 171 $
    Author:
    $Author: $
    • Field Detail

      • name

        protected java.lang.String name
      • region

        protected Region region
      • owner

        protected Unit owner
      • faction

        protected Faction faction
      • object

        protected java.lang.Object object
      • message

        protected java.lang.String message
      • line

        protected int line
    • Constructor Detail

      • SimpleProblem

        public SimpleProblem​(Problem.Severity severity,
                             ProblemType type,
                             Region region,
                             Unit owner,
                             Faction faction,
                             java.lang.Object object,
                             Inspector inspector,
                             java.lang.String message,
                             int line)
        Creates a new AbstractProblem object.
        Parameters:
        type - One of Problem.Severity.INFORMATION, Problem.Severity.WARNING, Problem.Severity.ERROR
        region - A region where the problem occurs
        owner - The unit responsible for this problem or null. If line >= 0 , it refers to an order of this unit.
        faction - The faction this problem belongs to or null
        object - The object that this problem criticizes
        inspector - The Inspector that reported this problem
        message - The message text of the problem
        line - The line number in the orders of owner where the problem occured or -1 if no such order can be identified. The first line is line 1!
        Throws:
        java.lang.NullPointerException - if object, inspector or message is null.
    • Method Detail

      • getFaction

        public Faction getFaction()
        Returns the value of faction.
        Specified by:
        getFaction in interface Problem
        Returns:
        The faction this problem belongs to or null if not applicable
        See Also:
        Problem.getFaction()
      • getLine

        public int getLine()
        Description copied from interface: Problem
        Returns the line in the orders of the unit that caused the problem. The first order is line 1!
        Specified by:
        getLine in interface Problem
        Returns:
        The line that is the cause of the order or -1 if no single line can be made responsible
        See Also:
        Problem.getLine()
      • getMessage

        public java.lang.String getMessage()
        Returns the value of message.
        Specified by:
        getMessage in interface Problem
        Returns:
        Returns message.
        See Also:
        Problem.getMessage()
      • toString

        public java.lang.String toString()
        Returns the message of the problem.
        Specified by:
        toString in interface Problem
        Overrides:
        toString in class java.lang.Object
      • addSuppressComment

        public Unit addSuppressComment()
        Adds a comment to the unit that is responsible for this problem. This comment causes the problem to be suppressed in subsequent runs of inspectors.
        Specified by:
        addSuppressComment in interface Problem
        Returns:
        Returns a Unit whose orders were changed to suppress this warning or null if no orders were changed
        See Also:
        Problem.addSuppressComment()