code.google.com home

org.owasp.html
Class HtmlStreamRenderer

java.lang.Object
  extended by org.owasp.html.HtmlStreamRenderer
All Implemented Interfaces:
HtmlStreamEventReceiver

@NotThreadSafe
public class HtmlStreamRenderer
extends java.lang.Object
implements HtmlStreamEventReceiver

Given a series of HTML tokens, writes valid, normalized HTML to the output. The output will have well-defined tag boundaries, but there may be orphaned or missing close and open tags. The result of two renderers can always be concatenated to produce a larger snippet of HTML, but if the first was called with writeOpenTag("plaintext", ...), then any tags in the second will not be interpreted as tags in the concatenated version.


Method Summary
 void closeDocument()
           
 void closeTag(java.lang.String elementName)
           
static HtmlStreamRenderer create(java.lang.Appendable output, Handler<? super java.io.IOException> ioExHandler, Handler<? super java.lang.String> badHtmlHandler)
          Factory.
static HtmlStreamRenderer create(java.lang.StringBuilder output, Handler<? super java.lang.String> badHtmlHandler)
          Factory.
 boolean isDocumentOpen()
           
 void openDocument()
           
 void openTag(java.lang.String elementName, java.util.List<java.lang.String> attrs)
           
 void text(java.lang.String text)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static HtmlStreamRenderer create(@WillCloseWhenClosed
                                        java.lang.Appendable output,
                                        Handler<? super java.io.IOException> ioExHandler,
                                        Handler<? super java.lang.String> badHtmlHandler)
Factory.

Parameters:
output - the buffer to which HTML is streamed.
ioExHandler - called with any exception raised by output.
badHtmlHandler - receives alerts when HTML cannot be rendered because there is not valid HTML tree that results from that series of calls. E.g. it is not possible to create an HTML <style> element whose textual content is "</style>".

create

public static HtmlStreamRenderer create(java.lang.StringBuilder output,
                                        Handler<? super java.lang.String> badHtmlHandler)
Factory.

Parameters:
output - the buffer to which HTML is streamed.
badHtmlHandler - receives alerts when HTML cannot be rendered because there is not valid HTML tree that results from that series of calls. E.g. it is not possible to create an HTML <style> element whose textual content is "</style>".

openDocument

public final void openDocument()
                        throws java.lang.IllegalStateException
Specified by:
openDocument in interface HtmlStreamEventReceiver
Throws:
java.lang.IllegalStateException

closeDocument

public final void closeDocument()
                         throws java.lang.IllegalStateException
Specified by:
closeDocument in interface HtmlStreamEventReceiver
Throws:
java.lang.IllegalStateException

isDocumentOpen

public final boolean isDocumentOpen()

openTag

public final void openTag(java.lang.String elementName,
                          java.util.List<java.lang.String> attrs)
Specified by:
openTag in interface HtmlStreamEventReceiver
attrs - alternating attribute names and values.

closeTag

public final void closeTag(java.lang.String elementName)
Specified by:
closeTag in interface HtmlStreamEventReceiver

text

public final void text(java.lang.String text)
Specified by:
text in interface HtmlStreamEventReceiver

code.google.com home