com.ibm.wbi.markuplanguage.html
Class HeadProcessor

java.lang.Object
  |
  +--com.ibm.wbi.markuplanguage.html.HeadProcessor

public class HeadProcessor
extends java.lang.Object

Class to process HTML documents, adding specified content to the top of the HEAD section and/or the top of the BODY section.


Constructor Summary
HeadProcessor(java.io.InputStream is, java.io.OutputStream os)
          Creates a new HeadProcessor instance.
 
Method Summary
protected  void doBodyInsertion()
          Insert the body string to the top of the BODY section.
protected  void doHeadInsertion()
          Insert the head string to the top of the HEAD section.
 int getAdditionalLength()
          Get the additional number of bytes that were added to the HTML source.
 java.lang.String getTitle()
          Access the title of the document.
 java.lang.String getTopOfBodyInsertion()
          Get the string that should be inserted at top of BODY section.
 java.lang.String getTopOfHeadInsertion()
          Get the string that should be inserted at top of HEAD section.
 void process()
          Process the HTML document, adding the specified content to the top of the HEAD section and the top of the BODY section.
 void setTopOfBodyInsertion(java.lang.String s)
          Indicate that a string should be inserted at top of BODY section.
 void setTopOfHeadInsertion(java.lang.String s)
          Indicate that a string should be inserted at top of HEAD section.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeadProcessor

public HeadProcessor(java.io.InputStream is,
                     java.io.OutputStream os)
Creates a new HeadProcessor instance.
Parameters:
is - InputStream holding the HTML source to process.
os - OuputStream for the modified HTML source from the input stream. (This is an in-out parameter.)
Method Detail

getAdditionalLength

public int getAdditionalLength()
Get the additional number of bytes that were added to the HTML source.
Returns:
Additional length in number of bytes.

getTitle

public java.lang.String getTitle()
Access the title of the document. This is only available after the process() method has run.
Returns:
The title if it was found, null otherwise.

setTopOfBodyInsertion

public void setTopOfBodyInsertion(java.lang.String s)
Indicate that a string should be inserted at top of BODY section.
Parameters:
String - to insert at top of BODY.

getTopOfBodyInsertion

public java.lang.String getTopOfBodyInsertion()
Get the string that should be inserted at top of BODY section.
Returns:
BODY insertion string, null if not set.

setTopOfHeadInsertion

public void setTopOfHeadInsertion(java.lang.String s)
Indicate that a string should be inserted at top of HEAD section.
Parameters:
String - to insert at top of HEAD.

getTopOfHeadInsertion

public java.lang.String getTopOfHeadInsertion()
Get the string that should be inserted at top of HEAD section.
Returns:
HEAD insertion string, null if not set.

process

public void process()
             throws java.io.IOException
Process the HTML document, adding the specified content to the top of the HEAD section and the top of the BODY section. When processing is complete, the title of the document (if any) will be available from the getTitle() method.
Throws:
java.io.IOException - when reading from the input stream or writing to the output stream caused an exception.

doHeadInsertion

protected void doHeadInsertion()
                        throws java.io.IOException
Insert the head string to the top of the HEAD section.

doBodyInsertion

protected void doBodyInsertion()
                        throws java.io.IOException
Insert the body string to the top of the BODY section.