KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > xml > ValidationException


1 /*
2  * Copyright 2004-2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 /*
19  * Previously Copyright (c) 2001-2004 James House
20  */

21 package org.quartz.xml;
22
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collection JavaDoc;
25 import java.util.Collections JavaDoc;
26 import java.util.Iterator JavaDoc;
27
28 /**
29  * Reports QuartzMetaDataProcessor validation exceptions.
30  *
31  * @author <a HREF="mailto:bonhamcm@thirdeyeconsulting.com">Chris Bonham</a>
32  */

33 public class ValidationException extends Exception JavaDoc {
34     /*
35      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36      *
37      * Data members.
38      *
39      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40      */

41
42     private Collection JavaDoc validationExceptions = new ArrayList JavaDoc();
43
44     /*
45      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46      *
47      * Constructors.
48      *
49      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50      */

51
52     /**
53      * Constructor for ValidationException.
54      */

55     public ValidationException() {
56         super();
57     }
58
59     /**
60      * Constructor for ValidationException.
61      *
62      * @param message
63      * exception message.
64      */

65     public ValidationException(String JavaDoc message) {
66         super(message);
67     }
68
69     /**
70      * Constructor for ValidationException.
71      *
72      * @param errors
73      * collection of validation exceptions.
74      */

75     public ValidationException(Collection JavaDoc errors) {
76         this();
77         this.validationExceptions = Collections
78                 .unmodifiableCollection(validationExceptions);
79     }
80
81     /*
82      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83      *
84      * Interface.
85      *
86      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87      */

88
89     /**
90      * Returns collection of errors.
91      *
92      * @return collection of errors.
93      */

94     public Collection JavaDoc getValidationExceptions() {
95         return validationExceptions;
96     }
97
98     /**
99      * Returns the detail message string.
100      *
101      * @return the detail message string.
102      */

103     public String JavaDoc getMessage() {
104         if (getValidationExceptions().size() == 0) { return super.getMessage(); }
105
106         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
107
108         boolean first = true;
109
110         for (Iterator JavaDoc iter = getValidationExceptions().iterator(); iter
111                 .hasNext(); ) {
112             Exception JavaDoc e = (Exception JavaDoc) iter.next();
113
114             if (!first) {
115                 sb.append('\n');
116                 first = false;
117             }
118
119             sb.append(e.getMessage());
120         }
121
122         return sb.toString();
123     }
124 }
125
Popular Tags