source: nutchez-0.1/tomcat/webapps/examples/WEB-INF/classes/validators/DebugValidator.java @ 168

Last change on this file since 168 was 66, checked in by waue, 15 years ago

NutchEz - an easy way to nutch

File size: 2.8 KB
Line 
1/*
2* Licensed to the Apache Software Foundation (ASF) under one or more
3* contributor license agreements.  See the NOTICE file distributed with
4* this work for additional information regarding copyright ownership.
5* The ASF licenses this file to You under the Apache License, Version 2.0
6* (the "License"); you may not use this file except in compliance with
7* the License.  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
19package validators;
20
21
22import java.io.InputStream;
23import java.io.IOException;
24import javax.servlet.jsp.tagext.PageData;
25import javax.servlet.jsp.tagext.TagLibraryValidator;
26import javax.servlet.jsp.tagext.ValidationMessage;
27
28
29/**
30 * Example tag library validator that simply dumps the XML version of each
31 * page to standard output (which will typically be sent to the file
32 * <code>$CATALINA_HOME/logs/catalina.out</code>).  To utilize it, simply
33 * include a <code>taglib</code> directive for this tag library at the top
34 * of your JSP page.
35 *
36 * @author Craig McClanahan
37 * @version $Revision: 467217 $ $Date: 2006-10-24 05:14:34 +0200 (Tue, 24 Oct 2006) $
38 */
39
40public class DebugValidator extends TagLibraryValidator {
41
42
43    // ----------------------------------------------------- Instance Variables
44
45
46    // --------------------------------------------------------- Public Methods
47
48
49    /**
50     * Validate a JSP page.  This will get invoked once per directive in the
51     * JSP page.  This method will return <code>null</code> if the page is
52     * valid; otherwise the method should return an array of
53     * <code>ValidationMessage</code> objects.  An array of length zero is
54     * also interpreted as no errors.
55     *
56     * @param prefix The value of the prefix argument in this directive
57     * @param uri The value of the URI argument in this directive
58     * @param page The page data for this page
59     */
60    public ValidationMessage[] validate(String prefix, String uri,
61                                        PageData page) {
62
63        System.out.println("---------- Prefix=" + prefix + " URI=" + uri +
64                           "----------");
65
66        InputStream is = page.getInputStream();
67        while (true) {
68            try {
69                int ch = is.read();
70                if (ch < 0)
71                    break;
72                System.out.print((char) ch);
73            } catch (IOException e) {
74                break;
75            }
76        }
77        System.out.println();
78        System.out.println("-----------------------------------------------");
79        return (null);
80
81    }
82
83
84}
Note: See TracBrowser for help on using the repository browser.