KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > refactoring > api > Problem


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.refactoring.api;
20
21
22 /** Class used to represent problems encountered when performing
23  * various refactoring calls. Problems can be chained (using setNext method)
24  * - every problem can point to the following problem.
25  *
26  * @author Martin Matula
27  */

28 public final class Problem {
29     private final boolean fatal;
30     private final String JavaDoc message;
31     private Problem next = null;
32     private ProblemDetails details;
33
34     /** Creates new instance of Problem class.
35      * @param fatal Indicates whether the problem is fatal.
36      * @param message Textual description of the problem.
37      */

38     public Problem(boolean fatal, String JavaDoc message) {
39         this.fatal = fatal;
40         this.message = message;
41     }
42     
43     /** Creates new instance of Problem class.
44      * @param fatal Indicates whether the problem is fatal.
45      * @param message Textual description of the problem.
46      * @param details Problem details
47      * @see ProblemDetails
48      */

49     public Problem(boolean fatal, String JavaDoc message, ProblemDetails details) {
50         this(fatal, message);
51         this.details = details;
52     }
53     
54     /** Indicates whether the problem is fatal.
55      * @return <code>true</code> if the problem is fatal, otherwise returns <code>false</code>.
56      */

57     public boolean isFatal() {
58         return fatal;
59     }
60     
61     /** Returns textual description of the problem.
62      * @return Textual description of the problem.
63      */

64     public String JavaDoc getMessage() {
65         return message;
66     }
67     
68     /** Returns the following problem (or <code>null</code> if there none).
69      * @return The following problem.
70      */

71     public Problem getNext() {
72         return next;
73     }
74     
75     /**
76      * Sets the following problem. The problem can be set only once - subsequent
77      * attempts to call this method will result in IllegalStateException.
78      * @param next The following problem.
79      * @throws java.lang.IllegalStateException subsequent attempts to call this method will result in IllegalStateException.
80      */

81     public void setNext(Problem next) throws IllegalStateException JavaDoc {
82         if (this.next != null) {
83             throw new IllegalStateException JavaDoc("Cannot change \"next\" property of Problem."); //NOI18N
84
}
85         this.next = next;
86     }
87
88     /**
89      * Getter for ProblemDetails
90      * @return instance of ProblemDetails or null
91      */

92     public ProblemDetails getDetails() {
93         return details;
94     }
95 }
96
Popular Tags