KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > config > MultipleValidationException


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/config/MultipleValidationException.java,v 1.4 2004/08/18 12:25:56 hkollmann Exp $
3  * $Revision: 1.4 $
4  * $Date: 2004/08/18 12:25:56 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */

23
24 package org.dbforms.config;
25
26 import java.util.Vector JavaDoc;
27
28
29
30 /**
31  * This exception may be thrown by user code in classes implementing the
32  * interceptor interface Allows developers to define more then one error - to
33  * be used in conjunction with the XML errors mechanism
34  */

35 public class MultipleValidationException extends ValidationException {
36    private Vector JavaDoc messages = null;
37
38    /**
39     * Creates a new MultipleValidationException object.
40     *
41     * @param message DOCUMENT ME!
42     */

43    public MultipleValidationException(String JavaDoc message) {
44       super();
45       addMessage(message);
46    }
47
48
49    /**
50     * Creates a new MultipleValidationException object.
51     *
52     * @param messages DOCUMENT ME!
53     */

54    public MultipleValidationException(Vector JavaDoc messages) {
55       super();
56       this.setMessages(messages);
57    }
58
59    /**
60     * Returns the detail message string of this throwable. <br>
61     * Override the <code>getMessage</code> method of the
62     * <code>Throwable</code> class. <br>
63     * Note: the Throwable class' <code>toString</code> method calls
64     * <code>getLocalizedMessage()</code> to get the string representation of
65     * the detaile error message. The original
66     * <code>getLocalizedMessage()</code> implementation calls
67     * <code>getMessage()</code>. <br>
68     * Overriding <code>getMessage</code> to get the multiple messages from
69     * this exception class let Log4j category classes log all the error
70     * messages. (fossato, 2002.11.29)
71     *
72     * @return the detail message string of this <tt>Throwable</tt> instance
73     */

74    public String JavaDoc getMessage() {
75       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
76
77       if (messages != null) {
78          for (int i = 0; i < messages.size(); i++) {
79             Object JavaDoc o = messages.elementAt(i);
80
81             if (o != null) {
82                sb.append(o.toString())
83                  .append("\n");
84             }
85          }
86       }
87
88       return sb.toString();
89    }
90
91
92    /**
93     * Sets the messages
94     *
95     * @param messages The messages to set
96     */

97    public void setMessages(Vector JavaDoc messages) {
98       this.messages = messages;
99    }
100
101
102    /**
103     * Gets the messages
104     *
105     * @return Returns a Vector
106     */

107    public Vector JavaDoc getMessages() {
108       return messages;
109    }
110
111
112    /**
113     * DOCUMENT ME!
114     *
115     * @param message DOCUMENT ME!
116     */

117    public void addMessage(String JavaDoc message) {
118       if (messages == null) {
119          messages = new Vector JavaDoc();
120       }
121
122       messages.add(message);
123    }
124 }
125
Popular Tags