KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > util > rewriter > Rewriter


1 /*
2  * Copyright 2000-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 package org.apache.jetspeed.util.rewriter;
18
19 // java.io
20
import java.io.Reader JavaDoc;
21
22 // java.net
23
import java.net.MalformedURLException JavaDoc;
24
25 // this makes it dependent on Swing...need an abstraction WTP
26
import javax.swing.text.html.HTML JavaDoc;
27 import javax.swing.text.MutableAttributeSet JavaDoc;
28
29 /**
30  *
31  * Interface for URL rewriting.
32  *
33  * @author <a HREF="mailto:taylor@apache.org">David Sean Taylor</a>
34  * @version $Id: Rewriter.java,v 1.6 2004/02/23 03:18:59 jford Exp $
35  */

36
37 public interface Rewriter
38 {
39
40     /*
41      * Entry point into rewriting HTML content.
42      *
43      * Reads stream from proxied host, runs configured HTML parser against that stream,
44      * rewriting relevant links, and writes the parsed stream back to the client.
45      *
46      * @param input the HTML input stream.
47      * @param input the base URL host string used to create full links back to host
48      * @return the rewritten HTML output stream.
49      *
50      * @exception MalformedURLException a servlet exception.
51      */

52     String JavaDoc rewrite(Reader JavaDoc input, String JavaDoc baseURL)
53             throws MalformedURLException JavaDoc;
54                                
55
56     /* <p>
57      * This callback is called by the HTMLParserAdaptor implementation to write
58      * back all rewritten URLs to point to the proxy server. Each implementation
59      * writes specifically for their own type of resources.</p>
60      * <p>
61      * Given the targetURL, rewrites the link as a link back to the proxy server.
62      * </p>
63      * @param targetURL the URL to be rewritten back to the proxy server.
64      * @param baseURL the base URL of the target host.
65      * @param proxyURL the base URL of the proxy server.
66      * @return the rewritten URL to the proxy server.
67      *
68      * @exception MalformedURLException a servlet exception.
69      */

70     String JavaDoc generateNewUrl(String JavaDoc targetURL, HTML.Tag JavaDoc tag, HTML.Attribute JavaDoc attribute);
71
72     /*
73      * Returns true if all rewritten URLs should be sent back to the proxy server.
74      *
75      * @return true if all URLs are rewritten back to proxy server.
76      */

77     boolean proxyAllTags();
78
79     // parser event handling
80
boolean enterSimpleTagEvent(HTML.Tag JavaDoc tag, MutableAttributeSet JavaDoc attrs);
81     String JavaDoc exitSimpleTagEvent(HTML.Tag JavaDoc tag, MutableAttributeSet JavaDoc attrs);
82
83     boolean enterStartTagEvent(HTML.Tag JavaDoc tag, MutableAttributeSet JavaDoc attrs);
84     String JavaDoc exitStartTagEvent(HTML.Tag JavaDoc tag, MutableAttributeSet JavaDoc attrs);
85
86     boolean enterEndTagEvent(HTML.Tag JavaDoc tag);
87     String JavaDoc exitEndTagEvent(HTML.Tag JavaDoc tag);
88
89     boolean enterText(char[] values, int param);
90
91     void convertTagEvent(HTML.Tag JavaDoc tag, MutableAttributeSet JavaDoc attrs);
92 }
93
94
Popular Tags