001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    //
021    // This source code implements specifications defined by the Java
022    // Community Process. In order to remain compliant with the specification
023    // DO NOT add / change / or delete method signatures!
024    //
025    
026    package javax.servlet.jsp.tagext;
027    
028    
029    /**
030     * A validation message from either TagLibraryValidator or TagExtraInfo.
031     * <p>
032     * As of JSP 2.0, a JSP container must support a jsp:id attribute
033     * to provide higher quality validation errors.
034     * The container will track the JSP pages
035     * as passed to the container, and will assign to each element
036     * a unique "id", which is passed as the value of the jsp:id
037     * attribute.  Each XML element in the XML view available will
038     * be extended with this attribute.  The TagLibraryValidator
039     * can then use the attribute in one or more ValidationMessage
040     * objects.  The container then, in turn, can use these
041     * values to provide more precise information on the location
042     * of an error.
043     *  
044     * <p>
045     * The actual prefix of the <code>id</code> attribute may or may not be 
046     * <code>jsp</code> but it will always map to the namespace
047     * <code>http://java.sun.com/JSP/Page</code>.  A TagLibraryValidator
048     * implementation must rely on the uri, not the prefix, of the <code>id</code>
049     * attribute.
050     */
051    public class ValidationMessage {
052    
053        /**
054         * Create a ValidationMessage.  The message String should be
055         * non-null.  The value of id may be null, if the message
056         * is not specific to any XML element, or if no jsp:id
057         * attributes were passed on.  If non-null, the value of
058         * id must be the value of a jsp:id attribute for the PageData
059         * passed into the validate() method.
060         *
061         * @param id Either null, or the value of a jsp:id attribute.
062         * @param message A localized validation message.
063         */
064        public ValidationMessage(String id, String message) {
065            this.id = id;
066            this.message = message;
067        }
068    
069    
070        /**
071         * Get the jsp:id.
072         * Null means that there is no information available.
073         *
074         * @return The jsp:id information.
075         */
076        public String getId() {
077            return id;
078        }
079    
080        /**
081         * Get the localized validation message.
082         *
083         * @return A validation message
084         */
085        public String getMessage(){
086            return message;
087        }
088    
089        // Private data
090        private String id;
091        private String message;
092    }