Package org.owasp.html
Class TagBalancingHtmlStreamEventReceiver
- java.lang.Object
-
- org.owasp.html.TagBalancingHtmlStreamEventReceiver
-
- All Implemented Interfaces:
HtmlStreamEventReceiver
public class TagBalancingHtmlStreamEventReceiver extends Object implements HtmlStreamEventReceiver
Wraps an HTML stream event receiver to fill in missing close tags. If the balancer is given the HTML<p>1<p>2, the wrapped receiver will see events equivalent to<p>1</p><p>2</p>.- Author:
- Mike Samuel (mikesamuel@gmail.com)
-
-
Constructor Summary
Constructors Constructor Description TagBalancingHtmlStreamEventReceiver(HtmlStreamEventReceiver underlying)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseDocument()Called first to indicate that no more events will be received.voidcloseTag(String elementName)Called to specify an end tag like</elementName>.static booleanisInterElementWhitespace(String text)True if text is the value of an inter-element whitespace text node as defined by HTML5.voidopenDocument()Called first to indicate that events follow.voidopenTag(String elementName, List<String> attrs)Called to specify a tag with the given name and attributes.voidsetNestingLimit(int limit)Set the maximum element nesting depth.voidtext(String text)Called to specify a text node.
-
-
-
Constructor Detail
-
TagBalancingHtmlStreamEventReceiver
public TagBalancingHtmlStreamEventReceiver(HtmlStreamEventReceiver underlying)
- Parameters:
underlying- An event receiver that should receive a stream of balanced events that is as close as possible to the stream of events received by this.
-
-
Method Detail
-
setNestingLimit
public void setNestingLimit(int limit)
Set the maximum element nesting depth.
-
openDocument
public void openDocument()
Description copied from interface:HtmlStreamEventReceiverCalled first to indicate that events follow.- Specified by:
openDocumentin interfaceHtmlStreamEventReceiver
-
closeDocument
public void closeDocument()
Description copied from interface:HtmlStreamEventReceiverCalled first to indicate that no more events will be received.- Specified by:
closeDocumentin interfaceHtmlStreamEventReceiver
-
openTag
public void openTag(String elementName, List<String> attrs)
Description copied from interface:HtmlStreamEventReceiverCalled to specify a tag with the given name and attributes.- Specified by:
openTagin interfaceHtmlStreamEventReceiverattrs- alternating attribute names and values.
-
closeTag
public void closeTag(String elementName)
Description copied from interface:HtmlStreamEventReceiverCalled to specify an end tag like</elementName>.- Specified by:
closeTagin interfaceHtmlStreamEventReceiver
-
isInterElementWhitespace
public static boolean isInterElementWhitespace(String text)
True if text is the value of an inter-element whitespace text node as defined by HTML5.This is the kind of text that is often inserted by HTML authors to nicely indent their HTML documents and which (modulo unconventional use of
white-space:pre) are not apparent to the end-user.
-
text
public void text(String text)
Description copied from interface:HtmlStreamEventReceiverCalled to specify a text node.- Specified by:
textin interfaceHtmlStreamEventReceiver
-
-