Class HTMLParser
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringconvertCharEntity(String charEntity) Overrides XMLParser.convertCharEntity to add in HTML char entitiesprotected ElementcreateNewElement(String name) Overrides XMLParser.createNewElement to return an HTMLElement instanceprotected ElementcreateNewTextElement(String text) Overrides XMLParser.createNewTextElement to return an HTMLElement instanceprotected String{Returns a string identifying the document type this parser supports.protected booleanisEmptyTag(String tagName) Checks whether the specified tag is an empty tag as defined in EMPTY_TAGSprotected booleanisSupported(Element element) Overrides the Element.isSupported to let the parser know which tags are supported in XHTML-MP 1.0A convenience method that casts the returned type of the parse method to HTMLElement.protected voidparseTagContent(Element element, Reader is) Overrides XMLParser.parseTagContent to enable embedded CSS segments (Style tags)protected booleanshouldEvaluate(Element element) Overrides the Element.shouldEvaluate method to return false on the script tag.Methods inherited from class XMLParser
addCharEntitiesRange, addCharEntity, attribute, endTag, eventParser, isCaseSensitive, isWhiteSpace, notifyError, parse, parseCommentOrXMLDeclaration, parseTag, setCaseSensitive, setIncludeWhitespacesBetweenTags, setParserCallback, startTag, textElementModifier and TypeMethodDescriptionvoidaddCharEntitiesRange(String[] symbols, int startcode) Adds the given symbols array to the user defined char entities table with the startcode provided as the code of the first string, startcode+1 for the second etc.voidaddCharEntity(String symbol, int code) Adds the given symbol and code to the user defined char entities table http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_referencesprotected voidInvoked for every attribute value of the givne tag This callback method is invoked only on the eventParser.protected voidInvoked when a tag ends This callback method is invoked only on the eventParser.voidThe event parser requires deriving this class and overriding callback methods to work effectively.booleanSets the parser to be case sensitive and retain case, otherwise it will convert all data to lower caseprotected booleanisWhiteSpace(char ch) Checks if the specified character is a white space or not.protected voidnotifyError(int errorId, String tag, String attribute, String value, String description) A utility method used to notify an error to the ParserCallback and throw an IllegalArgumentException if parsingError returned falseThis is the entry point for parsing a document and the only non-private member method in this classprotected ElementparseCommentOrXMLDeclaration(Reader is, String endTag) This utility method is used to parse comments and XML declarations in the XML.protected ElementThis method collects the tag name and all of its attributes.voidsetCaseSensitive(boolean caseSensitive) Sets the parser to be case sensitive and retain case, otherwise it will convert all data to lower casevoidsetIncludeWhitespacesBetweenTags(boolean include) voidsetParserCallback(ParserCallback parserCallback) Sets the specified callback to serve as the callback for parsing errorsprotected booleanInvoked when a tag is opened, this method should return true to process the tag or return false to skip the tag.protected voidtextElement(String text) Invoked when the event parser encounters a text element.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
Constructor Details
-
HTMLParser
public HTMLParser()Constructs a new instance of HTMLParser
-
-
Method Details
-
parseTagContent
Overrides XMLParser.parseTagContent to enable embedded CSS segments (Style tags)
Parameters
-
element: The current parent element -
is: The reader containing the XML
Throws
IOException: if an I/O error in the stream is encountered
- Overrides:
parseTagContentin classXMLParser- Throws:
IOException
-
-
createNewElement
Overrides XMLParser.createNewElement to return an HTMLElement instance
Parameters
name: The HTMLElement's name
Returns
a new instance of the names HTMLElement
- Overrides:
createNewElementin classXMLParser
-
createNewTextElement
Overrides XMLParser.createNewTextElement to return an HTMLElement instance
Parameters
text: The HTMLElement's text
Returns
a new instance of the HTMLElement
- Overrides:
createNewTextElementin classXMLParser
-
convertCharEntity
Overrides XMLParser.convertCharEntity to add in HTML char entities
Parameters
charEntity: The char entity to convert
Returns
A string containing a single char, or the original char entity string (with & and ;) if the char entity couldn't be resolved
- Overrides:
convertCharEntityin classXMLParser
-
isEmptyTag
Checks whether the specified tag is an empty tag as defined in EMPTY_TAGS
Parameters
tagName: The tag name to check
Returns
true if that tag is defined as an empty tag, false otherwise
- Overrides:
isEmptyTagin classXMLParser
-
parseHTML
A convenience method that casts the returned type of the parse method to HTMLElement. Basically calling this method is simlar to calling parse and casting to HTMLElement.
Parameters
isr: The input stream containing the HTML
Returns
The HTML document
-
getSupportedStandardName
{
Returns a string identifying the document type this parser supports. This should be overriden by subclassing parsers.
Returns
a string identifying the document type this parser supports.
}- Overrides:
getSupportedStandardNamein classXMLParser
-
isSupported
Overrides the Element.isSupported to let the parser know which tags are supported in XHTML-MP 1.0
Returns
true if the tag is a supported XHTML Mobile Profile 1.0 tag, false otherwise
- Overrides:
isSupportedin classXMLParser
-
shouldEvaluate
Overrides the Element.shouldEvaluate method to return false on the script tag. The script tag should be skipped entirely, since it may contain characters like greater-than and lesser-than which may break the HTML All other tags are evaluated (i.e. added including all their children to the tree), even if not supported (But of course their functionality is ignored by HTMLComponent)
Returns
false if this is the SCRIPT tag, true otherwise
- Overrides:
shouldEvaluatein classXMLParser
-