org.apache.shindig.gadgets.parse
Class GadgetHtmlParser
java.lang.Object
org.apache.shindig.gadgets.parse.GadgetHtmlParser
- Direct Known Subclasses:
- CajaHtmlParser, NekoSimplifiedHtmlParser
public abstract class GadgetHtmlParser
- extends Object
Parser for arbitrary HTML content
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PARSED_DOCUMENTS
public static final String PARSED_DOCUMENTS
- See Also:
- Constant Field Values
PARSED_FRAGMENTS
public static final String PARSED_FRAGMENTS
- See Also:
- Constant Field Values
documentFactory
protected final DOMImplementation documentFactory
GadgetHtmlParser
protected GadgetHtmlParser(DOMImplementation documentFactory)
setCacheProvider
@Inject
public void setCacheProvider(CacheProvider cacheProvider)
setSerializerProvider
@Inject
public void setSerializerProvider(com.google.inject.Provider<HtmlSerializer> serProvider)
attemptFullDocParseFirst
protected static boolean attemptFullDocParseFirst(String content)
- Parameters:
content -
- Returns:
- true if we detect a preamble of doctype or html
parseDom
public Document parseDom(String source)
throws GadgetException
- Throws:
GadgetException
transferChildren
protected void transferChildren(Node to,
Node from)
prependToNode
protected void prependToNode(Node to,
LinkedList<Node> from)
parseFragment
public void parseFragment(String source,
Node result)
throws GadgetException
- Parses a snippet of markup and appends the result as children to the
provided node.
- Parameters:
source - markup to be parsedresult - Node to append results to
- Throws:
GadgetException
errorDom
protected Document errorDom(DOMException e)
shouldCache
protected boolean shouldCache()
parseDomImpl
protected abstract Document parseDomImpl(String source)
throws GadgetException
- TODO: remove the need for parseDomImpl as a parsing method. Gadget HTML is
tag soup handled in custom fashion, or is a legitimate fragment. In either case,
we can simply use the fragment parsing implementation and patch up in higher-level calls.
- Parameters:
source - a piece of HTML
- Returns:
- a Document parsed from the HTML
- Throws:
GadgetException
parseFragmentImpl
protected abstract DocumentFragment parseFragmentImpl(String source)
throws GadgetException
- Parameters:
source - a snippet of HTML markup
- Returns:
- a DocumentFragment containing the parsed elements
- Throws:
GadgetException
Copyright © 2007-2012. All Rights Reserved.