KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > displaytag > exception > MissingAttributeException


1 /**
2  * Licensed under the Artistic License; you may not use this file
3  * except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://displaytag.sourceforge.net/license.html
7  *
8  * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
9  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
10  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11  */

12 package org.displaytag.exception;
13
14 import org.apache.commons.lang.ArrayUtils;
15 import org.displaytag.Messages;
16
17
18 /**
19  * Exception thrown when a required attribute is not set. This is thrown when the user is required to set at least one
20  * of multiple attributes and the check can't be enforced by the tld.
21  * @author Fabrizio Giustina
22  * @version $Revision: 720 $ ($Author: fgiust $)
23  */

24 public class MissingAttributeException extends BaseNestableJspTagException
25 {
26
27     /**
28      * D1597A17A6.
29      */

30     private static final long serialVersionUID = 899149338534L;
31
32     /**
33      * list of tag attributes.
34      */

35     private final String JavaDoc[] attributes;
36
37     /**
38      * Constructor for MissingAttributeException.
39      * @param source Class where the exception is generated
40      * @param attributeNames String attribute name
41      */

42     public MissingAttributeException(Class JavaDoc source, String JavaDoc[] attributeNames)
43     {
44         super(source, Messages.getString("MissingAttributeException.msg", //$NON-NLS-1$
45
new Object JavaDoc[]{ArrayUtils.toString(attributeNames)}));
46
47         // copy attributes to allow them to be retrieved using getAttributeNames()
48
this.attributes = (String JavaDoc[]) ArrayUtils.clone(attributeNames);
49     }
50
51     /**
52      * @return SeverityEnum.ERROR
53      * @see org.displaytag.exception.BaseNestableJspTagException#getSeverity()
54      * @see org.displaytag.exception.SeverityEnum
55      */

56     public SeverityEnum getSeverity()
57     {
58         return SeverityEnum.ERROR;
59     }
60
61     /**
62      * returns an array containing the names of missing attributes.
63      * @return String[] array of missing attributes
64      */

65     public String JavaDoc[] getAttributeNames()
66     {
67         return (String JavaDoc[]) ArrayUtils.clone(this.attributes);
68     }
69
70 }
Popular Tags