KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > control > activity > task > IllegalTaskException


1 /**
2  * Dream Copyright (C) 2003-2004 INRIA Rhone-Alpes
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 2 of the License, or (at your option) any
7  * later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Contact: dream@objectweb.org
19  *
20  * Initial developer(s): Matthieu Leclercq
21  * Contributor(s):
22  */

23
24 package org.objectweb.dream.control.activity.task;
25
26 import java.io.PrintStream JavaDoc;
27
28 import org.objectweb.fractal.api.control.NameController;
29
30 /**
31  * Exception thrown by task controller when an operation on a task can't be
32  * done.
33  */

34 public class IllegalTaskException extends Exception JavaDoc
35 {
36   Task task;
37   Throwable JavaDoc cause;
38
39   /**
40    * @param task a task.
41    */

42   public IllegalTaskException(Task task)
43   {
44     this.task = task;
45   }
46
47   /**
48    * @param task a task.
49    * @param message a message.
50    * @param cause a cause.
51    */

52   public IllegalTaskException(Task task, String JavaDoc message, Throwable JavaDoc cause)
53   {
54     super(message);
55     this.task = task;
56     this.cause = cause;
57   }
58
59   /**
60    * @return the task.
61    */

62   public Task getTask()
63   {
64     return task;
65   }
66
67   /**
68    * @see java.lang.Throwable#toString()
69    */

70   public String JavaDoc toString()
71   {
72     String JavaDoc s;
73     if (task == null)
74     {
75       s = super.toString();
76     }
77     else
78     {
79       if (task instanceof NameController)
80       {
81         s = super.toString() + " task name : "
82             + ((NameController) task).getFcName();
83       }
84       else
85       {
86         s = super.toString();
87       }
88     }
89     if (cause != null)
90     {
91       s += " causeb by " + cause.toString();
92     }
93     return s;
94   }
95
96   /**
97    * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
98    */

99   public void printStackTrace(PrintStream JavaDoc s)
100   {
101     super.printStackTrace(s);
102     if (cause != null)
103     {
104       s.print("Caused by : ");
105       cause.printStackTrace(s);
106     }
107   }
108 }
Popular Tags