public abstract class AbstractRewriter extends Object implements Rewriter
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
log |
Constructor and Description |
---|
AbstractRewriter() |
Modifier and Type | Method and Description |
---|---|
void |
enterConvertTagEvent(String tag,
MutableAttributes attrs)
Rewriter event called back just before tag conversion (rewriter callbacks) begins by the ParserAdaptor.
|
String |
enterConvertTextEvent(String tag,
String text)
Rewriter event called back for text conversion by the ParserAdaptor.
|
boolean |
enterEndTagEvent(String tag)
Rewriter event called back on the leading edge of processing an end tag by the ParserAdaptor.
|
boolean |
enterSimpleTagEvent(String tag,
MutableAttributes attrs)
Rewriter event called back on the leading edge of processing a simple tag by the ParserAdaptor.
|
boolean |
enterStartTagEvent(String tag,
MutableAttributes attrs)
Rewriter event called back on the leading edge of processing a start tag by the ParserAdaptor.
|
boolean |
enterText(char[] values,
int param)
Rewriter event called back when text is found for
Returns false to indicate to the ParserAdaptor to short-circuit processing on this tag.
|
String |
exitEndTagEvent(String tag)
Rewriter event called back on the trailing edge of a end tag by the ParserAdaptor.
|
String |
exitSimpleTagEvent(String tag,
MutableAttributes attrs)
Rewriter event called back on the trailing edge of a simple tag by the ParserAdaptor.
|
String |
exitStartTagEvent(String tag,
MutableAttributes attrs)
Rewriter event called back on the trailing edge of a start tag by the ParserAdaptor.
|
String |
getBaseRelativeUrl(String relativeUrl)
Gets a new URL relative to Base according to the site / and URL
rewriting rules of java.net.URL
|
String |
getBaseUrl()
Gets the base URL for rewriting.
|
boolean |
getUseProxy()
Gets whether this rewriter require a proxy server.
|
void |
parse(ParserAdaptor adaptor,
Reader reader)
Parses the reader of content receiving call backs for rewriter events.
|
void |
rewrite(ParserAdaptor adaptor,
Reader reader,
Writer writer)
Parses the reader of content receiving call backs for rewriter events.
|
abstract String |
rewriteUrl(String url,
String tag,
String attribute)
This event is the inteface between the Rewriter and ParserAdaptor for rewriting URLs.
|
void |
setBaseUrl(String base)
Sets the base URL for rewriting.
|
void |
setUseProxy(boolean useProxy)
Set whether this rewriter require a proxy server.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
rewriteText, shouldRemoveComments, shouldRemoveTag, shouldStripTag
public void parse(ParserAdaptor adaptor, Reader reader) throws RewriterException
Rewriter
parse
in interface Rewriter
adaptor
- the parser adaptor which handles generating SAX-like events called back on this object.reader
- the input stream over the content to be parsed.RewriterException
public void rewrite(ParserAdaptor adaptor, Reader reader, Writer writer) throws RewriterException
Rewriter
rewrite
in interface Rewriter
adaptor
- the parser adaptor which handles generating SAX-like events called back on this object.reader
- the input stream over the content to be parsed.writer
- the output stream where content is rewritten to.RewriterException
public abstract String rewriteUrl(String url, String tag, String attribute)
Rewriter
rewriteUrl
in interface Rewriter
url
- the URL to be rewrittentag
- The tag being processedattribute
- The current attribute being processsedpublic void setBaseUrl(String base)
Rewriter
setBaseUrl
in interface Rewriter
base
- The base URL for this rewriterpublic String getBaseUrl()
Rewriter
getBaseUrl
in interface Rewriter
public String getBaseRelativeUrl(String relativeUrl)
Rewriter
getBaseRelativeUrl
in interface Rewriter
public boolean getUseProxy()
Rewriter
getUseProxy
in interface Rewriter
public void setUseProxy(boolean useProxy)
Rewriter
setUseProxy
in interface Rewriter
useProxy
- true if it requires a proxypublic boolean enterSimpleTagEvent(String tag, MutableAttributes attrs)
Rewriter
enterSimpleTagEvent
in interface Rewriter
tag
- The name of the tag being processed.attrs
- The attribute list for the tag.public String exitSimpleTagEvent(String tag, MutableAttributes attrs)
Rewriter
exitSimpleTagEvent
in interface Rewriter
tag
- The name of the tag being processed.attrs
- The attribute list for the tag.public boolean enterStartTagEvent(String tag, MutableAttributes attrs)
Rewriter
enterStartTagEvent
in interface Rewriter
tag
- The name of the tag being processed.attrs
- The attribute list for the tag.public String exitStartTagEvent(String tag, MutableAttributes attrs)
Rewriter
exitStartTagEvent
in interface Rewriter
tag
- The name of the tag being processed.attrs
- The attribute list for the tag.public boolean enterEndTagEvent(String tag)
Rewriter
enterEndTagEvent
in interface Rewriter
tag
- The name of the tag being processed.public String exitEndTagEvent(String tag)
Rewriter
exitEndTagEvent
in interface Rewriter
tag
- The name of the tag being processed.public boolean enterText(char[] values, int param)
Rewriter
public void enterConvertTagEvent(String tag, MutableAttributes attrs)
Rewriter
enterConvertTagEvent
in interface Rewriter
tag
- The name of the tag being processed.attrs
- The attribute list for the tag.public String enterConvertTextEvent(String tag, String text)
Rewriter
enterConvertTextEvent
in interface Rewriter
tag
- The name of the tag being processed.text
- the text to be converted.Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.