KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > validation > ReportHelper


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.config.serverbeans.validation;
25
26 import java.util.Map JavaDoc;
27 import java.util.HashMap JavaDoc;
28
29 import com.sun.enterprise.config.ConfigBean;
30 import com.sun.enterprise.config.serverbeans.ElementProperty;
31
32 /**
33  * helper class with convenience util methods
34  * for reporting errors
35 */

36
37 /* Class for attribute type Integer */
38
39 public abstract class ReportHelper {
40     
41     final static String JavaDoc ATTR_ERROR_MSG_PREFIX = "AttrValidationError.";
42     final static String JavaDoc ERROR_MSG_PREFIX = "ValidationError.";
43     /***********************************************************
44      * reports attribute validation error
45      ************************************************************/

46     static public void reportAttributeError(ValidationContext valCtx,
47             String JavaDoc msgNameSuffix, String JavaDoc defaultMsg, Object JavaDoc[] values)
48     {
49         valCtx.result.failed( /*getAttributeNameMsgPrefix(valCtx) + */
50                valCtx.smh.getLocalString(ATTR_ERROR_MSG_PREFIX + msgNameSuffix, defaultMsg, values) );
51     }
52
53     /***********************************************************
54      * reports validation error
55      ************************************************************/

56     static public void reportValidationError(ValidationContext valCtx,
57             String JavaDoc msgNameSuffix, String JavaDoc defaultMsg, Object JavaDoc[] values)
58     {
59         valCtx.result.failed(
60               valCtx.smh.getLocalString(ERROR_MSG_PREFIX + msgNameSuffix,
61               defaultMsg, values) );
62     }
63
64     static private String JavaDoc getAttributeNameMsgPrefix(ValidationContext valCtx)
65     {
66         if(valCtx.attrName==null)
67             return "";
68         return valCtx.smh.getLocalString("common.AttributeErrorMsgPrefix",
69               "Attribute {0}: ", new Object JavaDoc[] {valCtx.attrName});
70     }
71 }
72
Popular Tags