KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > error > PropertyError


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.error;
8
9
10 import java.util.Locale JavaDoc;
11
12 import com.inversoft.util.StringTools;
13
14
15 /**
16  * This class is a simple javabean that holds a single error or a single
17  * property error (an error associated with a property).
18  *
19  * @author Brian Pontarelli
20  */

21 public class PropertyError extends BasicError {
22
23     private String JavaDoc property;
24
25
26     /**
27      * Constructs a <code>PropertyError</code> for the given property with
28      * no message
29      *
30      * @param property The property associated with this error
31      * @throws IllegalArgumentException If the property given is null or empty
32      */

33     public PropertyError(String JavaDoc property) {
34         setProperty(property);
35     }
36
37     /**
38      * Constructs a property error with the given message and property
39      *
40      * @param property The property associated with this error
41      * @param msg The message of this error
42      * @throws IllegalArgumentException If the property given is null or empty
43      */

44     public PropertyError(String JavaDoc property, String JavaDoc msg) {
45         super(msg);
46         setProperty(property);
47     }
48
49     /**
50      * Constructs a property error with the given message, property and Locale
51      * that can be used to decode the String contents.
52      *
53      * @param property The property associated with this error
54      * @param msg The message of this error
55      * @param locale (Optional) The Locale of the message
56      * @throws IllegalArgumentException If the property given is null or empty
57      */

58     public PropertyError(String JavaDoc property, String JavaDoc msg, Locale JavaDoc locale) {
59         super(msg, locale);
60         setProperty(property);
61     }
62
63     /**
64      * Constructs a property error with the given message, property, message
65      * format parameters and Locale, which can be used to decode the String
66      * contents.
67      *
68      * @param property The property associated with this error
69      * @param msg The message of this error
70      * @param params An array of parameters to the msg String. This uses the
71      * java.text.MessageFormat class for formatting
72      * @param locale (Optional) The Locale of the message
73      * @throws IllegalArgumentException If the property given is null or empty
74      */

75     public PropertyError(String JavaDoc property, String JavaDoc msg, Object JavaDoc [] params,
76             Locale JavaDoc locale) {
77         super(msg, params, locale);
78         setProperty(property);
79     }
80
81     /**
82      * Constructs a property error with the given message and property
83      *
84      * @param property The property associated with this error
85      * @param msg The message of this error
86      * @param params An array of parameters to the msg String. This uses the
87      * java.text.MessageFormat class for formatting
88      * @throws IllegalArgumentException If the property given is null or empty
89      */

90     public PropertyError(String JavaDoc property, String JavaDoc msg, Object JavaDoc [] params) {
91         super(msg, params);
92         setProperty(property);
93     }
94
95
96     /**
97      * Gets The property that this error is associated with
98      *
99      * @return The property that this error is associated with
100      */

101     public String JavaDoc getProperty() {
102         return property;
103     }
104     
105     /**
106      * Sets The property that this error is associated with
107      *
108      * @param property The property that this error is associated with
109      * @throws IllegalArgumentException If the property given is null or empty
110      */

111     public void setProperty(String JavaDoc property) {
112         if (StringTools.isEmpty(property)) {
113             throw new IllegalArgumentException JavaDoc("A property is required for a PropertyError");
114         }
115
116         this.property = property;
117     }
118 }
119
Popular Tags