public interface IParser
Modifier and Type | Field and Description |
---|---|
static int |
LOWER_CASE
Constant for tag case (lower case).
|
static int |
ORIGINAL_CASE
Constant for tag case (original).
|
static int |
UPPER_CASE
Constant for tag case (upper case).
|
Modifier and Type | Method and Description |
---|---|
void |
addErrorHandler(IErrorHandler errorHandler)
Adds an ErrorHandler instance.
|
void |
addErrorLogListener(IErrorLogListener listener)
Adds an error log listener.
|
boolean |
autoGenerated(Element element)
Checks if the specified element is automatically generated by this parser
or not.
|
String |
changeDefaultTagCase(String tag)
Change a specified string to specified cased.
|
void |
elementHandle(boolean logical)
Determines which this parser invokes
DocumentHandler.startElement(java.lang.String,
org.xml.sax.AttributeList) and
DocumentHandler.endElement(java.lang.String)
logically or physically . |
void |
error(int code,
String msg)
Records an error.
|
Element |
getContext()
Gets a current context element.
|
Element[] |
getContextElements() |
Document |
getDocument()
Gets a document parsed by this instance.
|
IErrorHandler[] |
getErrorHandlers()
Gets node-level error handlers included in this parser
|
Object |
getExtraErrInfo()
Gets extra error information.
|
Node |
getNode()
Gets a Node or
EndTag from a currently reading stream as a result
of tokenizing. |
int |
getPushbackBufferSize() |
boolean |
hasEndTag(Element element)
Checks if a specified element has its end tag or not.
|
void |
keepUnknownElements(boolean keep)
Determines unknown elements are kept or not.
|
void |
pushBackNode(Node node)
Pushes back a node to this parser.
|
void |
reopenContext(int i) |
void |
setAttrNameCase(int attrCase)
Specifies attribute names' case.
|
void |
setContext(Element element)
Sets current context element node.
|
void |
setCurrentNode(Node node)
Sets current node
|
void |
setDefaultTagCase(int tagCase)
Specifies element names' case whose start tags are omitted.
|
void |
setDocumentHandler(DocumentHandler handler)
Sets a DocumentHandler instance for this parser.
|
void |
setHasEndTag(Element element)
Determines that a specified element has its end tag.
|
void |
setTagCase(int tagCase)
Specifies element names' case.
|
static final int UPPER_CASE
static final int LOWER_CASE
static final int ORIGINAL_CASE
void addErrorHandler(IErrorHandler errorHandler)
true
), no more
errorHandlers are invoked.errorHandler
- errorHandler instance to be added to this parservoid addErrorLogListener(IErrorLogListener listener)
listener
- target listenerboolean autoGenerated(Element element)
TBODY
under TABLE
is
automatically generated in following document.
<TABLE> <TR><TD><TD> </TABLE>
element
- element node to be checkedElement
is automatically generated by this.
Otherwise false.String changeDefaultTagCase(String tag)
tag
- target tag case (LOWER_CASE
,
ORIGINAL_CASE
or UPPER_CASE
)setDefaultTagCase(int)
void elementHandle(boolean logical)
DocumentHandler.startElement(java.lang.String,
org.xml.sax.AttributeList)
and
DocumentHandler.endElement(java.lang.String)
logically
or physically
.
Logical
means that if a start or end tag of a element is omitted, a parser
invokes each method. Physical
means that parsers invokes
each method if and only if their tag apparently exist. If
physical
, a parser does not care if the tag is illegal or
not. Default is physical
logical
- if true, deal with tags as logical. Otherwise, as physicalvoid error(int code, String msg)
IErrorLogListener.errorLog(int,String)
method.code
- error code.msg
- message of the error.Element getContext()
setContext(org.w3c.dom.Element)
Element[] getContextElements()
Document getDocument()
IErrorHandler[] getErrorHandlers()
Object getExtraErrInfo()
IParserError.SUDDEN_ENDTAG
error occurs, parser set missed end
tags between error node and future context to extra error information.Node getNode() throws ParseException, IOException, SAXException
EndTag
from a currently reading stream as a result
of tokenizing.Node
or EndTag
ParseException
IOException
SAXException
pushBackNode(org.w3c.dom.Node)
int getPushbackBufferSize()
boolean hasEndTag(Element element)
element
- element to be checked.true
if Element
has its end tag.
Otherwise, false.void keepUnknownElements(boolean keep)
<!ELEMENT anonymous - - ANY>
,
where anonymous is an unknown element.keep
- true
if parser keeps. Otherwise
false
void pushBackNode(Node node)
node
- node to be pushed back.getNode()
void reopenContext(int i) throws SAXException
i
- depthSAXException
void setAttrNameCase(int attrCase)
attrCase
- this must be UPPER_CASE
, LOWER_CASE
or
ORIGINAL_CASE
. If otherwise, ignore.void setContext(Element element) throws SAXException
element
- new context.SAXException
getContext()
void setCurrentNode(Node node)
node
- new current node.void setDefaultTagCase(int tagCase)
tagCase
- this must be UPPER_CASE
or
LOWER_CASE
. If otherwise, ignore.void setHasEndTag(Element element)
void setTagCase(int tagCase)
tagCase
- this must be UPPER_CASE
,
LOWER_CASE
or ORIGINAL_CASE
.
If otherwise, ignore.void setDocumentHandler(DocumentHandler handler)