01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
23: *
24: * @author Manfred Geiler (latest modification by $Author: mbr $)
25: * @author Thomas Spiegl
26: * @version $Revision: 512227 $ $Date: 2007-02-27 13:25:16 +0100 (Di, 27 Feb 2007) $
27: */
28: public class ValidatorException extends FacesException {
29: private static final long serialVersionUID = 5965885122446047949L;
30: private FacesMessage _facesMessage;
31:
32: public ValidatorException(FacesMessage message) {
33: super (facesMessageToString(message));
34: _facesMessage = message;
35: }
36:
37: public ValidatorException(FacesMessage message, Throwable cause) {
38: super (facesMessageToString(message), cause);
39: _facesMessage = message;
40: }
41:
42: public FacesMessage getFacesMessage() {
43: return _facesMessage;
44:
45: }
46:
47: private static String facesMessageToString(FacesMessage message) {
48: final String summary = message.getSummary();
49: final String detail = message.getDetail();
50:
51: if (summary != null) {
52: if (detail != null) {
53: return summary + ": " + detail;
54: }
55:
56: return summary;
57: }
58:
59: return detail != null ? detail : "";
60: }
61:
62: }
|