websphinx
Class HTMLTransformer

java.lang.Object
  |
  +--websphinx.HTMLTransformer
Direct Known Subclasses:
LinkTransformer

public class HTMLTransformer
extends java.lang.Object


Constructor Summary
HTMLTransformer(HTMLTransformer next)
          Make an HTMLTransformer that writes pages to a downstream HTMLTransformer.
HTMLTransformer(java.io.OutputStream out)
          Make an HTMLTransformer that writes pages to a stream.
HTMLTransformer(java.lang.String filename)
          Make an HTMLTransformer that writes pages to a file.
HTMLTransformer(java.lang.String filename, boolean seekable)
          Make an HTMLTransformer that writes pages to a file.
 
Method Summary
 void close()
          Close the transformer.
protected  void emit(Region r)
          Emit a region on the transformer chain's final output.
protected  void emit(java.lang.String string)
          Emit a string on the transformer chain's final output.
protected  void finalize()
          Finalizes the transformer (calling close()).
 void flush()
          Flushes transformer to its destination stream.
 long getFilePointer()
          Get the file pointer.
 java.io.OutputStream getOutputStream()
           
 java.io.Writer getOutputWriter()
           
 java.io.RandomAccessFile getRandomAccessFile()
           
protected  void handleElement(Element elem)
          Handle the transformation of an HTML element.
 void seek(long pos)
          Seek to a file position.
 void setOutput(java.io.OutputStream out)
           
 void setRandomAccessFile(java.io.RandomAccessFile raf)
           
protected  void transformContents(Element elem)
          Transform the contents of an element.
protected  void transformElement(Element elem)
          Transform an element by passing it through the entire filter chain.
 void write(Region region)
          Writes a chunk of HTML through the HTML transformer.
 void write(java.lang.String string)
          Writes a literal string through the HTML transformer (without parsing it or transforming it).
 void writePage(Page page)
          Writes a page through the HTML transformer.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLTransformer

public HTMLTransformer(java.io.OutputStream out)
Make an HTMLTransformer that writes pages to a stream.

Parameters:
out - Stream to receive HTML output

HTMLTransformer

public HTMLTransformer(java.lang.String filename)
                throws java.io.IOException
Make an HTMLTransformer that writes pages to a file.

Parameters:
filename - Name of file to receive HTML output
Throws:
java.io.IOException - if file cannot be opened

HTMLTransformer

public HTMLTransformer(java.lang.String filename,
                       boolean seekable)
                throws java.io.IOException
Make an HTMLTransformer that writes pages to a file.

Parameters:
filename - Name of file to receive HTML output
seekable - True if file should be opened for random access

HTMLTransformer

public HTMLTransformer(HTMLTransformer next)
Make an HTMLTransformer that writes pages to a downstream HTMLTransformer. Use this constructor to chain together several HTMLTransformers.

Parameters:
next - HTMLTransformer to receive HTML output
Method Detail

setOutput

public void setOutput(java.io.OutputStream out)

getOutputStream

public java.io.OutputStream getOutputStream()

getOutputWriter

public java.io.Writer getOutputWriter()

setRandomAccessFile

public void setRandomAccessFile(java.io.RandomAccessFile raf)

getRandomAccessFile

public java.io.RandomAccessFile getRandomAccessFile()

write

public void write(java.lang.String string)
           throws java.io.IOException
Writes a literal string through the HTML transformer (without parsing it or transforming it).

Parameters:
string - String to write

write

public void write(Region region)
           throws java.io.IOException
Writes a chunk of HTML through the HTML transformer.

Parameters:
region - Region to write

writePage

public void writePage(Page page)
               throws java.io.IOException
Writes a page through the HTML transformer.

Parameters:
page - Page to write

flush

public void flush()
           throws java.io.IOException
Flushes transformer to its destination stream. Empties any buffers in the transformer chain.


close

public void close()
           throws java.io.IOException
Close the transformer. Flushes all buffered data to disk by calling flush(). This call may be time-consuming! Don't use the transformer again after closing it.

Throws:
java.io.IOException - if an I/O error occurs

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalizes the transformer (calling close()).

Overrides:
finalize in class java.lang.Object

getFilePointer

public long getFilePointer()
                    throws java.io.IOException
Get the file pointer.

Returns:
current file pointer
Throws:
java.io.IOException - if this transformer not opened for random access

seek

public void seek(long pos)
          throws java.io.IOException
Seek to a file position.

Parameters:
pos - file position to seek
Throws:
java.io.IOException - if this transformer not opened for random access

transformElement

protected void transformElement(Element elem)
                         throws java.io.IOException
Transform an element by passing it through the entire filter chain.

Parameters:
elem - Element to be transformed

transformContents

protected void transformContents(Element elem)
                          throws java.io.IOException
Transform the contents of an element. Passes the child elements through the filter chain and emits the text between them.

Parameters:
elem - Element whose contents should be transformed

handleElement

protected void handleElement(Element elem)
                      throws java.io.IOException
Handle the transformation of an HTML element. Override this method to modify the HTML as it is written.

Parameters:
elem - Element to transform

emit

protected void emit(Region r)
             throws java.io.IOException
Emit a region on the transformer chain's final output. (The region isn't passed through the chain.)

Parameters:
r - Region to emit

emit

protected void emit(java.lang.String string)
             throws java.io.IOException
Emit a string on the transformer chain's final output.

Parameters:
string - String to emit