KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > refactoring > ui > j > 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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.refactoring.ui.j.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     public Problem(boolean fatal, String JavaDoc message, ProblemDetails details) {
44         this(fatal, message);
45         this.details = details;
46     }
47     
48     /** Indicates whether the problem is fatal.
49      * @return <code>true</code> if the problem is fatal, otherwise returns <code>false</code>.
50      */

51     public boolean isFatal() {
52         return fatal;
53     }
54     
55     /** Returns textual description of the problem.
56      * @return Textual description of the problem.
57      */

58     public String JavaDoc getMessage() {
59         return message;
60     }
61     
62     /** Returns the following problem (or <code>null</code> if there none).
63      * @return The following problem.
64      */

65     public Problem getNext() {
66         return next;
67     }
68     
69     /**
70      * Sets the following problem. The problem can be set only once - subsequent
71      * attempts to call this method will result in IllegalStateException.
72      * @param next The following problem.
73      * @throws java.lang.IllegalStateException subsequent attempts to call this method will result in IllegalStateException.
74      */

75     public void setNext(Problem next) throws IllegalStateException JavaDoc {
76         if (this.next != null) {
77             throw new IllegalStateException JavaDoc("Cannot change \"next\" property of Problem."); //NOI18N
78
}
79         this.next = next;
80     }
81
82     /**
83      * Getter for ProblemDetails
84      * @return instance of ProblemDetails or null
85      */

86     public ProblemDetails getDetails() {
87         return details;
88     }
89 }
90
Popular Tags