jodd.lagarto.dom
Class LagartoDOMBuilder

java.lang.Object
  extended by jodd.lagarto.LagartoParserEngine
      extended by jodd.lagarto.dom.LagartoDOMBuilder

public class LagartoDOMBuilder
extends LagartoParserEngine

Lagarto DOM builder creates DOM tree from HTML, XHTML or XML content.


Field Summary
protected  boolean caseSensitive
           
protected  boolean collectErrors
           
protected  java.lang.String conditionalCommentExpression
           
protected  long elapsed
           
protected  java.util.List<java.lang.String> errors
           
static java.lang.String[] HTML5_VOID_TAGS
          Default void tags.
protected  boolean ignoreComments
           
protected  boolean ignoreWhitespacesBetweenTags
           
protected  boolean impliedEndTags
           
protected  boolean selfCloseVoidTags
           
protected  java.lang.String[] voidTags
           
 
Fields inherited from class jodd.lagarto.LagartoParserEngine
calculatePosition, enableConditionalComments, parseSpecialTagsAsCdata
 
Constructor Summary
LagartoDOMBuilder()
           
 
Method Summary
protected  DOMBuilderTagVisitor createDOMDomBuilderTagVisitor()
          Creates DOMBuilderTagVisitor.
protected  Document doParse()
          Parses the content.
 LagartoDOMBuilder enableHtmlMode()
          Enables HTML5 parsing mode.
 LagartoDOMBuilder enableXhtmlMode()
          Enables XHTML mode.
 LagartoDOMBuilder enableXmlMode()
          Enables XML parsing mode.
 java.lang.String getConditionalCommentExpression()
           
 java.util.List<java.lang.String> getErrors()
          Returns list of warnings and errors occurred during parsing.
 long getParsingTime()
          Returns elapsed parsing time in milliseconds.
 java.lang.String[] getVoidTags()
           
 boolean hasVoidTags()
          Returns true if void tags are used.
 boolean isCaseSensitive()
           
 boolean isCollectErrors()
           
 boolean isIgnoreComments()
           
 boolean isIgnoreWhitespacesBetweenTags()
           
 boolean isImpliedEndTags()
           
 boolean isSelfCloseVoidTags()
           
 boolean isVoidTag(java.lang.String tagName)
          Returns true if tag name is void.
 Document parse(java.nio.CharBuffer content)
          Creates DOM tree from the provided content.
 Document parse(java.lang.CharSequence content)
          Creates DOM tree from provided content.
 void setCaseSensitive(boolean caseSensitive)
          Specifies if tag names are case sensitive.
 void setCollectErrors(boolean collectErrors)
          Enables error collection during parsing.
 void setConditionalCommentExpression(java.lang.String conditionalCommentExpression)
           
 void setIgnoreComments(boolean ignoreComments)
          Specifies if comments should be ignored in DOM tree.
 void setIgnoreWhitespacesBetweenTags(boolean ignoreWhitespacesBetweenTags)
          Specifies if whitespaces between open/closed tags should be ignored.
 void setImpliedEndTags(boolean impliedEndTags)
          Enables implied end tags for certain tags.
 void setSelfCloseVoidTags(boolean selfCloseVoidTags)
          Specifies if void tags should be self closed.
 void setVoidTags(java.lang.String... voidTags)
          Sets void tags.
 
Methods inherited from class jodd.lagarto.LagartoParserEngine
acceptTag, error, flushText, getLexer, initialize, isCalculatePosition, isEnableConditionalComments, isParseSpecialTagsAsCdata, nextToken, parse, parse, parseAttribute, parseCCEnd, parseCDATA, parseCommentOrConditionalComment, parseDoctype, parseRevealedCCStart, parseSpecialTag, parseTag, parseTagAndAttributes, parseText, setCalculatePosition, setEnableConditionalComments, setParseSpecialTagsAsCdata, skipWhiteSpace, text
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTML5_VOID_TAGS

public static final java.lang.String[] HTML5_VOID_TAGS
Default void tags. http://dev.w3.org/html5/spec/Overview.html#void-elements


ignoreWhitespacesBetweenTags

protected boolean ignoreWhitespacesBetweenTags

caseSensitive

protected boolean caseSensitive

ignoreComments

protected boolean ignoreComments

selfCloseVoidTags

protected boolean selfCloseVoidTags

collectErrors

protected boolean collectErrors

conditionalCommentExpression

protected java.lang.String conditionalCommentExpression

voidTags

protected java.lang.String[] voidTags

impliedEndTags

protected boolean impliedEndTags

errors

protected java.util.List<java.lang.String> errors

elapsed

protected long elapsed
Constructor Detail

LagartoDOMBuilder

public LagartoDOMBuilder()
Method Detail

isIgnoreWhitespacesBetweenTags

public boolean isIgnoreWhitespacesBetweenTags()

setIgnoreWhitespacesBetweenTags

public void setIgnoreWhitespacesBetweenTags(boolean ignoreWhitespacesBetweenTags)
Specifies if whitespaces between open/closed tags should be ignored.


isCaseSensitive

public boolean isCaseSensitive()

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Specifies if tag names are case sensitive.


isIgnoreComments

public boolean isIgnoreComments()

setIgnoreComments

public void setIgnoreComments(boolean ignoreComments)
Specifies if comments should be ignored in DOM tree.


getVoidTags

public java.lang.String[] getVoidTags()

setVoidTags

public void setVoidTags(java.lang.String... voidTags)
Sets void tags. If null, void tags are not used.


hasVoidTags

public boolean hasVoidTags()
Returns true if void tags are used. Using void tags makes parsing a different.


isVoidTag

public boolean isVoidTag(java.lang.String tagName)
Returns true if tag name is void. If void tags are not defined, returns false for any input.


isSelfCloseVoidTags

public boolean isSelfCloseVoidTags()

setSelfCloseVoidTags

public void setSelfCloseVoidTags(boolean selfCloseVoidTags)
Specifies if void tags should be self closed.


isCollectErrors

public boolean isCollectErrors()

setCollectErrors

public void setCollectErrors(boolean collectErrors)
Enables error collection during parsing.


getConditionalCommentExpression

public java.lang.String getConditionalCommentExpression()

setConditionalCommentExpression

public void setConditionalCommentExpression(java.lang.String conditionalCommentExpression)

isImpliedEndTags

public boolean isImpliedEndTags()

setImpliedEndTags

public void setImpliedEndTags(boolean impliedEndTags)
Enables implied end tags for certain tags. This flag reduces the performances a bit, so if you are dealing with 'straight' html that uses closes tags, consider switching this flag off.


enableHtmlMode

public LagartoDOMBuilder enableHtmlMode()
Enables HTML5 parsing mode.


enableXhtmlMode

public LagartoDOMBuilder enableXhtmlMode()
Enables XHTML mode.


enableXmlMode

public LagartoDOMBuilder enableXmlMode()
Enables XML parsing mode.


parse

public Document parse(java.lang.CharSequence content)
Creates DOM tree from provided content.


parse

public Document parse(java.nio.CharBuffer content)
Creates DOM tree from the provided content.


doParse

protected Document doParse()
Parses the content.


createDOMDomBuilderTagVisitor

protected DOMBuilderTagVisitor createDOMDomBuilderTagVisitor()
Creates DOMBuilderTagVisitor.


getErrors

public java.util.List<java.lang.String> getErrors()
Returns list of warnings and errors occurred during parsing. Returns null if parsing was successful; or if errors are not collected.


getParsingTime

public long getParsingTime()
Returns elapsed parsing time in milliseconds.



Copyright © 2003-2012 Jodd Team