KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > faces > validator > ValidatorException


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package javax.faces.validator;
17
18 import javax.faces.FacesException;
19 import javax.faces.application.FacesMessage;
20
21 /**
22  * @author Manfred Geiler (latest modification by $Author: mwessendorf $)
23  * @author Thomas Spiegl
24  * @version $Revision: 1.3 $ $Date: 2004/07/01 22:01:11 $
25  */

26 public class ValidatorException
27         extends FacesException
28 {
29     private FacesMessage _facesMessage;
30
31     public ValidatorException(FacesMessage message)
32     {
33         super(facesMessageToString(message));
34         _facesMessage = message;
35     }
36
37     public ValidatorException(FacesMessage message,
38                               Throwable JavaDoc cause)
39     {
40         super(facesMessageToString(message), cause);
41         _facesMessage = message;
42     }
43
44     public FacesMessage getFacesMessage()
45     {
46         return _facesMessage;
47
48     }
49
50     private static String JavaDoc facesMessageToString(FacesMessage message)
51     {
52         if (message.getSummary() != null)
53         {
54             if (message.getDetail() != null)
55             {
56                 return message.getSummary() + ": " + message.getDetail();
57             }
58             else
59             {
60                 return message.getSummary();
61             }
62         }
63         else
64         {
65             if (message.getDetail() != null)
66             {
67                 return message.getDetail();
68             }
69             else
70             {
71                 return "";
72             }
73         }
74     }
75
76 }
77
Popular Tags