01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package javax.servlet.jsp.tagext;
19:
20: /**
21: * A validation message from either TagLibraryValidator or TagExtraInfo.
22: * <p>
23: * As of JSP 2.0, a JSP container must support a jsp:id attribute
24: * to provide higher quality validation errors.
25: * The container will track the JSP pages
26: * as passed to the container, and will assign to each element
27: * a unique "id", which is passed as the value of the jsp:id
28: * attribute. Each XML element in the XML view available will
29: * be extended with this attribute. The TagLibraryValidator
30: * can then use the attribute in one or more ValidationMessage
31: * objects. The container then, in turn, can use these
32: * values to provide more precise information on the location
33: * of an error.
34: *
35: * <p>
36: * The actual prefix of the <code>id</code> attribute may or may not be
37: * <code>jsp</code> but it will always map to the namespace
38: * <code>http://java.sun.com/JSP/Page</code>. A TagLibraryValidator
39: * implementation must rely on the uri, not the prefix, of the <code>id</code>
40: * attribute.
41: */
42:
43: public class ValidationMessage {
44:
45: /**
46: * Create a ValidationMessage. The message String should be
47: * non-null. The value of id may be null, if the message
48: * is not specific to any XML element, or if no jsp:id
49: * attributes were passed on. If non-null, the value of
50: * id must be the value of a jsp:id attribute for the PageData
51: * passed into the validate() method.
52: *
53: * @param id Either null, or the value of a jsp:id attribute.
54: * @param message A localized validation message.
55: */
56: public ValidationMessage(String id, String message) {
57: this .id = id;
58: this .message = message;
59: }
60:
61: /**
62: * Get the jsp:id.
63: * Null means that there is no information available.
64: *
65: * @return The jsp:id information.
66: */
67: public String getId() {
68: return id;
69: }
70:
71: /**
72: * Get the localized validation message.
73: *
74: * @return A validation message
75: */
76: public String getMessage() {
77: return message;
78: }
79:
80: // Private data
81: private String id;
82: private String message;
83: }
|