|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.kebrt.html2latex.Parser
public class Parser
HTML parser.
Field Summary | |
---|---|
private java.io.File |
_file
Input file. |
private java.io.FileReader |
_fr
Input file. |
private ParserHandler |
_handler
Handler which receives events from the parser. |
private java.util.Stack<ElementStart> |
_openElements
Stack containing all opened and still non-closed elements. |
private java.io.BufferedReader |
_reader
Input file. |
Constructor Summary | |
---|---|
Parser()
|
Method Summary | |
---|---|
private void |
destroy()
Closes the input input file specified in the parse() method. |
private void |
doParsing()
Reads the input file char by char. |
private void |
checkValidity(ElementEnd element)
Checks whether the document is well-formed. |
private void |
init()
Opens the input file specified in the parse() method. |
void |
parse(java.io.File inputFile,
ParserHandler handler)
Parses the HTML file and converts it using the particular handler. |
private MyElement |
parseElement(java.lang.String elementString)
Parses element. |
private void |
readContent(char firstChar)
Reads text content of an element. |
private void |
readElement()
Reads elements (tags). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.io.File _file
private java.io.FileReader _fr
private java.io.BufferedReader _reader
private ParserHandler _handler
private java.util.Stack<ElementStart> _openElements
Constructor Detail |
---|
public Parser()
Method Detail |
---|
public void parse(java.io.File inputFile, ParserHandler handler) throws FatalErrorException
<p
)</p>)
inputFile
- input HTML filehandler
- receives events such as startElement (ie. <html)
>
, endElement, ...
FatalErrorException
- fatal error (ie. input file can't be opened) occursprivate void init() throws FatalErrorException
parse()
method.
FatalErrorException
- when input file can't be openedprivate void destroy() throws FatalErrorException
parse()
method.
FatalErrorException
- when input file can't be closedprivate void doParsing() throws java.io.IOException
"<"
char is reached readElement()
is called otherwise readContent()
is called.
java.io.IOException
- when input error occursprivate void readElement() throws java.io.IOException
comment
, startElement
and
endElement
events to the handler.
java.io.IOException
- when input error occursprivate MyElement parseElement(java.lang.String elementString)
ElementStart
object
if it's a start element.
elementString
- string containing the element with its
attributes (but without leading "<" and ending
">")
ElementStart
or ElementEnd
object.private void readContent(char firstChar) throws java.io.IOException
character
event to the handler.
firstChar
- first char read in doParsing()
method
java.io.IOException
- when input error occursprivate void checkValidity(ElementEnd element)
endElement
events for the elements which
were opened but not correctly closed.
element
- the latest ending element which was reached
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |