1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * Portions Copyright Apache Software Foundation.
7 *
8 * The contents of this file are subject to the terms of either the GNU
9 * General Public License Version 2 only ("GPL") or the Common Development
10 * and Distribution License("CDDL") (collectively, the "License"). You
11 * may not use this file except in compliance with the License. You can obtain
12 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
13 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
14 * language governing permissions and limitations under the License.
15 *
16 * When distributing the software, include this License Header Notice in each
17 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
18 * Sun designates this particular file as subject to the "Classpath" exception
19 * as provided by Sun in the GPL Version 2 section of the License file that
20 * accompanied this code. If applicable, add the following below the License
21 * Header, with the fields enclosed by brackets [] replaced by your own
22 * identifying information: "Portions Copyrighted [year]
23 * [name of copyright owner]"
24 *
25 * Contributor(s):
26 *
27 * If you wish your version of this file to be governed by only the CDDL or
28 * only the GPL Version 2, indicate your decision by adding "[Contributor]
29 * elects to include this software in this distribution under the [CDDL or GPL
30 * Version 2] license." If you don't indicate a single choice of license, a
31 * recipient has the option to distribute your version of this file under
32 * either the CDDL, the GPL Version 2 or to extend the choice of license to
33 * its licensees as provided above. However, if you add GPL Version 2 code
34 * and therefore, elected the GPL Version 2 license, then the option applies
35 * only if the new code is made subject to such option by the copyright
36 * holder.
37 */
38
39 package javax.servlet.jsp.tagext;
40
41
42 /**
43 * A validation message from either TagLibraryValidator or TagExtraInfo.
44 * <p>
45 * As of JSP 2.0, a JSP container must support a jsp:id attribute
46 * to provide higher quality validation errors.
47 * The container will track the JSP pages
48 * as passed to the container, and will assign to each element
49 * a unique "id", which is passed as the value of the jsp:id
50 * attribute. Each XML element in the XML view available will
51 * be extended with this attribute. The TagLibraryValidator
52 * can then use the attribute in one or more ValidationMessage
53 * objects. The container then, in turn, can use these
54 * values to provide more precise information on the location
55 * of an error.
56 *
57 * <p>
58 * The actual prefix of the <code>id</code> attribute may or may not be
59 * <code>jsp</code> but it will always map to the namespace
60 * <code>http://java.sun.com/JSP/Page</code>. A TagLibraryValidator
61 * implementation must rely on the uri, not the prefix, of the <code>id</code>
62 * attribute.
63 */
64
65 public class ValidationMessage {
66
67 /**
68 * Create a ValidationMessage. The message String should be
69 * non-null. The value of id may be null, if the message
70 * is not specific to any XML element, or if no jsp:id
71 * attributes were passed on. If non-null, the value of
72 * id must be the value of a jsp:id attribute for the PageData
73 * passed into the validate() method.
74 *
75 * @param id Either null, or the value of a jsp:id attribute.
76 * @param message A localized validation message.
77 */
78 public ValidationMessage(String id, String message) {
79 this.id = id;
80 this.message = message;
81 }
82
83
84 /**
85 * Get the jsp:id.
86 * Null means that there is no information available.
87 *
88 * @return The jsp:id information.
89 */
90 public String getId() {
91 return id;
92 }
93
94 /**
95 * Get the localized validation message.
96 *
97 * @return A validation message
98 */
99 public String getMessage(){
100 return message;
101 }
102
103 // Private data
104 private String id;
105 private String message;
106 }