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