|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| DebugValidator.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 | /* | |
| 2 | * Copyright 2004 The Apache Software Foundation | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | ||
| 17 | ||
| 18 | package validators; | |
| 19 | ||
| 20 | ||
| 21 | import java.io.InputStream; | |
| 22 | import java.io.IOException; | |
| 23 | import javax.servlet.jsp.tagext.PageData; | |
| 24 | import javax.servlet.jsp.tagext.TagLibraryValidator; | |
| 25 | import javax.servlet.jsp.tagext.ValidationMessage; | |
| 26 | ||
| 27 | ||
| 28 | /** | |
| 29 | * Example tag library validator that simply dumps the XML version of each | |
| 30 | * page to standard output (which will typically be sent to the file | |
| 31 | * <code>$CATALINA_HOME/logs/catalina.out</code>). To utilize it, simply | |
| 32 | * include a <code>taglib</code> directive for this tag library at the top | |
| 33 | * of your JSP page. | |
| 34 | * | |
| 35 | * @author Craig McClanahan | |
| 36 | * @version $Revision: 267129 $ $Date: 2004-03-18 08:40:35 -0800 (Thu, 18 Mar 2004) $ | |
| 37 | */ | |
| 38 | ||
| 39 | public class DebugValidator extends TagLibraryValidator { | |
| 40 | ||
| 41 | ||
| 42 | // ----------------------------------------------------- Instance Variables | |
| 43 | ||
| 44 | ||
| 45 | // --------------------------------------------------------- Public Methods | |
| 46 | ||
| 47 | ||
| 48 | /** | |
| 49 | * Validate a JSP page. This will get invoked once per directive in the | |
| 50 | * JSP page. This method will return <code>null</code> if the page is | |
| 51 | * valid; otherwise the method should return an array of | |
| 52 | * <code>ValidationMessage</code> objects. An array of length zero is | |
| 53 | * also interpreted as no errors. | |
| 54 | * | |
| 55 | * @param prefix The value of the prefix argument in this directive | |
| 56 | * @param uri The value of the URI argument in this directive | |
| 57 | * @param page The page data for this page | |
| 58 | */ | |
| 59 | 0 | public ValidationMessage[] validate(String prefix, String uri, |
| 60 | PageData page) { | |
| 61 | ||
| 62 | 0 | System.out.println("---------- Prefix=" + prefix + " URI=" + uri + |
| 63 | "----------"); | |
| 64 | ||
| 65 | 0 | InputStream is = page.getInputStream(); |
| 66 | 0 | while (true) { |
| 67 | 0 | try { |
| 68 | 0 | int ch = is.read(); |
| 69 | 0 | if (ch < 0) |
| 70 | 0 | break; |
| 71 | 0 | System.out.print((char) ch); |
| 72 | } catch (IOException e) { | |
| 73 | 0 | break; |
| 74 | } | |
| 75 | } | |
| 76 | 0 | System.out.println(); |
| 77 | 0 | System.out.println("-----------------------------------------------"); |
| 78 | 0 | return (null); |
| 79 | ||
| 80 | } | |
| 81 | ||
| 82 | ||
| 83 | } |
|
||||||||||