View Javadoc

1   /**
2    *
3    * Copyright 2003-2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     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  //
19  // This source code implements specifications defined by the Java
20  // Community Process. In order to remain compliant with the specification
21  // DO NOT add / change / or delete method signatures!
22  //
23  
24  package javax.servlet.jsp.tagext;
25  
26  
27  /**
28   * A validation message from either TagLibraryValidator or TagExtraInfo.
29   * <p>
30   * As of JSP 2.0, a JSP container must support a jsp:id attribute
31   * to provide higher quality validation errors.
32   * The container will track the JSP pages
33   * as passed to the container, and will assign to each element
34   * a unique "id", which is passed as the value of the jsp:id
35   * attribute.  Each XML element in the XML view available will
36   * be extended with this attribute.  The TagLibraryValidator
37   * can then use the attribute in one or more ValidationMessage
38   * objects.  The container then, in turn, can use these
39   * values to provide more precise information on the location
40   * of an error.
41   *  
42   * <p>
43   * The actual prefix of the <code>id</code> attribute may or may not be 
44   * <code>jsp</code> but it will always map to the namespace
45   * <code>http://java.sun.com/JSP/Page</code>.  A TagLibraryValidator
46   * implementation must rely on the uri, not the prefix, of the <code>id</code>
47   * attribute.
48   */
49  
50  public class ValidationMessage {
51  
52      /**
53       * Create a ValidationMessage.  The message String should be
54       * non-null.  The value of id may be null, if the message
55       * is not specific to any XML element, or if no jsp:id
56       * attributes were passed on.  If non-null, the value of
57       * id must be the value of a jsp:id attribute for the PageData
58       * passed into the validate() method.
59       *
60       * @param id Either null, or the value of a jsp:id attribute.
61       * @param message A localized validation message.
62       */
63      public ValidationMessage(String id, String message) {
64  	this.id = id;
65  	this.message = message;
66      }
67  
68  
69      /**
70       * Get the jsp:id.
71       * Null means that there is no information available.
72       *
73       * @return The jsp:id information.
74       */
75      public String getId() {
76  	return id;
77      }
78  
79      /**
80       * Get the localized validation message.
81       *
82       * @return A validation message
83       */
84      public String getMessage(){
85  	return message;
86      }
87  
88      // Private data
89      private String id;
90      private String message;
91  }