Package org.htmlunit.html.parser.neko
Class HtmlUnitNekoHtmlParser
- java.lang.Object
-
- org.htmlunit.html.parser.neko.HtmlUnitNekoHtmlParser
-
- All Implemented Interfaces:
HTMLParser
public final class HtmlUnitNekoHtmlParser extends java.lang.Object implements HTMLParser
SAX parser implementation that uses the NekoHTML
HTMLConfigurationto parse HTML into a HtmlUnit-specific DOM (HU-DOM) tree.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,ElementFactory>ELEMENT_FACTORIESstatic SvgElementFactorySVG_FACTORYThe SVG factory.
-
Constructor Summary
Constructors Constructor Description HtmlUnitNekoHtmlParser()Ctor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.ThrowableextractNestedException(java.lang.Throwable e)Extract nested exception within an XNIException (Nekohtml uses reflection and generated exceptions are wrapped many times within XNIException and InvocationTargetException)ElementFactorygetElementFactory(SgmlPage page, java.lang.String namespaceURI, java.lang.String qualifiedName, boolean insideSvg, boolean svgSupport)INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory.ElementFactorygetFactory(java.lang.String tagName)INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.ElementFactorygetSvgFactory()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.voidparse(WebResponse webResponse, HtmlPage page, boolean xhtml, boolean createdByJavascript)Parses the WebResponse into an object tree representation.voidparseFragment(DomNode parent, java.lang.String source)Parses the HTML content from the given string into an object tree representation.voidparseFragment(DomNode parent, DomNode context, java.lang.String source, boolean createdByJavascript)Parses the HTML content from the given string into an object tree representation.
-
-
-
Field Detail
-
SVG_FACTORY
public static final SvgElementFactory SVG_FACTORY
The SVG factory.
-
ELEMENT_FACTORIES
private static final java.util.Map<java.lang.String,ElementFactory> ELEMENT_FACTORIES
-
-
Method Detail
-
parseFragment
public void parseFragment(DomNode parent, java.lang.String source) throws org.xml.sax.SAXException, java.io.IOException
Parses the HTML content from the given string into an object tree representation.- Specified by:
parseFragmentin interfaceHTMLParser- Parameters:
parent- the parent for the new nodessource- the (X)HTML to be parsed- Throws:
org.xml.sax.SAXException- if a SAX error occursjava.io.IOException- if an IO error occurs
-
parseFragment
public void parseFragment(DomNode parent, DomNode context, java.lang.String source, boolean createdByJavascript) throws org.xml.sax.SAXException, java.io.IOException
Parses the HTML content from the given string into an object tree representation.- Specified by:
parseFragmentin interfaceHTMLParser- Parameters:
parent- where the new parsed nodes will be added tocontext- the context to build the fragment context stacksource- the (X)HTML to be parsedcreatedByJavascript- if true the (script) tag was created by javascript- Throws:
org.xml.sax.SAXException- if a SAX error occursjava.io.IOException- if an IO error occurs
-
parse
public void parse(WebResponse webResponse, HtmlPage page, boolean xhtml, boolean createdByJavascript) throws java.io.IOException
Parses the WebResponse into an object tree representation.- Specified by:
parsein interfaceHTMLParser- Parameters:
webResponse- the response datapage- the HtmlPage to add the nodesxhtml- if true use the XHtml parsercreatedByJavascript- if true the (script) tag was created by javascript- Throws:
java.io.IOException- if there is an IO error
-
extractNestedException
static java.lang.Throwable extractNestedException(java.lang.Throwable e)
Extract nested exception within an XNIException (Nekohtml uses reflection and generated exceptions are wrapped many times within XNIException and InvocationTargetException)- Parameters:
e- the original XNIException- Returns:
- the cause exception
-
getSvgFactory
public ElementFactory getSvgFactory()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Specified by:
getSvgFactoryin interfaceHTMLParser- Returns:
- a factory for creating SvgElements representing the given tag
-
getFactory
public ElementFactory getFactory(java.lang.String tagName)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Specified by:
getFactoryin interfaceHTMLParser- Parameters:
tagName- an HTML element tag name- Returns:
- a factory for creating HtmlElements representing the given tag
-
getElementFactory
public ElementFactory getElementFactory(SgmlPage page, java.lang.String namespaceURI, java.lang.String qualifiedName, boolean insideSvg, boolean svgSupport)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory.- Specified by:
getElementFactoryin interfaceHTMLParser- Parameters:
page- the pagenamespaceURI- the namespace URIqualifiedName- the qualified nameinsideSvg- is the node inside an SVG node or notsvgSupport- true if called from javascript createElementNS- Returns:
- the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory
-
-