|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--websphinx.HTMLTransformer | +--websphinx.LinkTransformer
Transformer that remaps URLs in links.
The default LinkTransformer simply converts all links to absolute URLs. Other common effects are easy to achieve:
Field Summary | |
protected java.net.URL |
base
|
(package private) boolean |
emitBaseElement
|
protected java.util.Hashtable |
map
|
(package private) boolean |
needToEmitBase
|
Fields inherited from class websphinx.HTMLTransformer |
content, emitEnd, emitStart, head, next, openedStream, readwrite, stream, tail, transformEnd |
Constructor Summary | |
LinkTransformer(HTMLTransformer next)
Make a LinkTransformer writing to another HTMLTransformer |
|
LinkTransformer(java.io.OutputStream out)
Make a LinkTransformer writing to a stream. |
|
LinkTransformer(java.lang.String filename)
Make a LinkTransformer writing to a file. |
|
LinkTransformer(java.lang.String filename,
boolean seekable)
Make a LinkTransformer that writes pages to a file. |
|
LinkTransformer(java.io.Writer writer)
|
Method Summary | |
java.net.URL |
getBase()
Get the base URL used by the LinkTransformer. |
boolean |
getEmitBaseElement()
Test whether the LinkTransformer should emit a <BASE> element pointing to the base URL. |
protected void |
handleBase(Element elem)
Handle the BASE element. |
protected void |
handleElement(Element elem)
Handle an element written through the transformer. |
protected void |
handleLink(Link link)
Handle a Link's transformation. |
boolean |
isMapped(java.net.URL url)
Test whether a URL is mapped. |
java.lang.String |
lookup(java.net.URL base,
java.net.URL url)
Look up the href for a URL, taking any mapping into account. |
void |
map(java.net.URL url,
java.lang.String href)
Map a URL to an href. |
void |
map(java.net.URL url,
java.net.URL newURL)
Map a URL to a new URL. |
void |
setBase(java.net.URL base)
Set the base URL used by the LinkTransformer. |
void |
setEmitBaseElement(boolean emitBase)
Set whether the LinkTransformer should emit a <BASE> element pointing to the base URL. |
void |
writePage(Page page)
Write a page through the transformer. |
Methods inherited from class websphinx.HTMLTransformer |
close, emit, emit, emitInternal, emitPendingRegion, finalize, flush, getFilePointer, getOutput, getRandomAccessFile, openFile, processElementsInRegion, seek, setOutput, setOutput, setRandomAccessFile, transformContents, transformElement, write, write, writeStream |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected java.util.Hashtable map
protected java.net.URL base
boolean emitBaseElement
boolean needToEmitBase
Constructor Detail |
public LinkTransformer(java.lang.String filename) throws java.io.IOException
filename
- Filename to write topublic LinkTransformer(java.lang.String filename, boolean seekable) throws java.io.IOException
filename
- Name of file to receive HTML outputseekable
- True if file should be opened for random accesspublic LinkTransformer(java.io.OutputStream out)
out
- stream to write topublic LinkTransformer(java.io.Writer writer)
public LinkTransformer(HTMLTransformer next)
next
- next transformer in filter chainMethod Detail |
public java.net.URL getBase()
public void setBase(java.net.URL base)
base
- base URL, or null if no base URL should be used.public boolean getEmitBaseElement()
public void setEmitBaseElement(boolean emitBase)
emitBase
- true if a <BASE> element should be
emitted with each page.public java.lang.String lookup(java.net.URL base, java.net.URL url)
base
- base URL (or null if an absolute URL is desired)url
- URL of interestpublic void map(java.net.URL url, java.lang.String href)
url
- URL of interesthref
- href which should be returned by lookup (null, url)public void map(java.net.URL url, java.net.URL newURL)
url
- URL of interestnewURL
- URL which should be returned by lookup (null, url)public boolean isMapped(java.net.URL url)
url
- URL of interestpublic void writePage(Page page) throws java.io.IOException
writePage
in class HTMLTransformer
page
- Page to writeprotected void handleElement(Element elem) throws java.io.IOException
handleElement
in class HTMLTransformer
elem
- Element to transformprotected void handleLink(Link link) throws java.io.IOException
link
- Link to transformprotected void handleBase(Element elem) throws java.io.IOException
elem
- BASE element to transform
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |