org.eclipse.actf.model.dom.html

## Interface IParser

All Known Subinterfaces:
  IHTMLParser

    public interface IParser

Base Interface for parser implementations.

### Field Summary

Fields
`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).

### Method Summary

Methods
`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.

### Field Detail

#### UPPER_CASE

    static final int UPPER_CASE

Constant for tag case (upper case). The value of this constant is 0.

See Also:
  Constant Field Values

#### LOWER_CASE

    static final int LOWER_CASE

Constant for tag case (lower case). The value of this constant is 1.

See Also:
  Constant Field Values

#### ORIGINAL_CASE

    static final int ORIGINAL_CASE

Constant for tag case (original). The value of this constant is 2.

See Also:
  Constant Field Values

### Method Detail

#### addErrorHandler

    void addErrorHandler(IErrorHandler errorHandler)

Adds an ErrorHandler instance. An errorHandler added later is invoked earlier by this parser instance than errorHandlers added earlier. If one errorHandler handles error (e.g. returns `true`), no more errorHandlers are invoked.

Parameters:
  `errorHandler` - errorHandler instance to be added to this parser

#### addErrorLogListener

    void addErrorLogListener(IErrorLogListener listener)

Adds an error log listener. Listener is invoked when error is occurred.

Parameters:
  `listener` - target listener

#### autoGenerated

    boolean autoGenerated(Element element)

Checks if the specified element is automatically generated by this parser or not. For example, `TBODY` under `TABLE` is automatically generated in following document.

     <TABLE> <TR><TD><TD> </TABLE>

Parameters:
  `element` - element node to be checked
Returns:
  true if `Element` is automatically generated by this. Otherwise false.

#### changeDefaultTagCase

    String changeDefaultTagCase(String tag)

Change a specified string to specified cased.

Parameters:
  `tag` - target tag case (`LOWER_CASE`, `ORIGINAL_CASE` or `UPPER_CASE`)
See Also:
  `setDefaultTagCase(int)`

#### elementHandle

    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`.`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`

Parameters:
  `logical` - if true, deal with tags as logical. Otherwise, as physical

#### error

    void error(int code,
             String msg)

Records an error. Does nothing by default. If it has ErrorLogListener instances, calls their `IErrorLogListener.errorLog(int,String)` method.

Parameters:
  `code` - error code.
  `msg` - message of the error.

#### getContext

    Element getContext()

Gets a current context element.

Returns:
  context element
See Also:
  `setContext(org.w3c.dom.Element)`

#### getContextElements

    Element[] getContextElements()

Returns:
  array of context element

#### getDocument

    Document getDocument()

Gets a document parsed by this instance.

Returns:
  parsed document instance.

#### getErrorHandlers

    IErrorHandler[] getErrorHandlers()

Gets node-level error handlers included in this parser

Returns:
  error handlers

#### getExtraErrInfo

    Object getExtraErrInfo()

Gets extra error information. A parser passes two error information (e.g. error code and error node) to node-level error handlers. However, it is now enough for some kind of error handlers to recover the error. If `IParserError.SUDDEN_ENDTAG` error occurs, parser set missed end tags between error node and future context to extra error information.

#### getNode

    Node getNode()
                 throws ParseException,
                        IOException,
                        SAXException

Gets a Node or `EndTag`from a currently reading stream as a result of tokenizing.

Returns:
  `Node` or `EndTag`
Throws:
  `ParseException`
  `IOException`
  `SAXException`
See Also:
  `pushBackNode(org.w3c.dom.Node)`

#### getPushbackBufferSize

    int getPushbackBufferSize()

#### hasEndTag

    boolean hasEndTag(Element element)

Checks if a specified element has its end tag or not.

Parameters:
  `element` - element to be checked.
Returns:
  `true` if `Element` has its end tag. Otherwise, false.

#### keepUnknownElements

    void keepUnknownElements(boolean keep)

Determines unknown elements are kept or not. The definition of the elements is `<!ELEMENT anonymous - - ANY>`, where anonymous is an unknown element.

Parameters:
  `keep` - `true` if parser keeps. Otherwise `false`

#### pushBackNode

    void pushBackNode(Node node)

Pushes back a node to this parser.

Parameters:
  `node` - node to be pushed back.
See Also:
  `getNode()`

#### reopenContext

    void reopenContext(int i)
                       throws SAXException

Parameters:
  `i` - depth
Throws:
  `SAXException`

#### setAttrNameCase

    void setAttrNameCase(int attrCase)

Specifies attribute names' case. Default behavior makes them original cased.

Parameters:
  `attrCase` - this must be `UPPER_CASE`, `LOWER_CASE` or `ORIGINAL_CASE`. If otherwise, ignore.

#### setContext

    void setContext(Element element)
                    throws SAXException

Sets current context element node.

Parameters:
  `element` - new context.
Throws:
  `SAXException`
See Also:
  `getContext()`

#### setCurrentNode

    void setCurrentNode(Node node)

Sets current node

Parameters:
  `node` - new current node.

#### setDefaultTagCase

    void setDefaultTagCase(int tagCase)

Specifies element names' case whose start tags are omitted. Default behavior makes them upper-cased.

Parameters:
  `tagCase` - this must be `UPPER_CASE` or `LOWER_CASE`. If otherwise, ignore.

#### setHasEndTag

    void setHasEndTag(Element element)

Determines that a specified element has its end tag.

#### setTagCase

    void setTagCase(int tagCase)

Specifies element names' case. Default behavior makes them original cased.

Parameters:
  `tagCase` - this must be `UPPER_CASE`, `LOWER_CASE` or `ORIGINAL_CASE`. If otherwise, ignore.

#### setDocumentHandler

    void setDocumentHandler(DocumentHandler handler)

Sets a DocumentHandler instance for this parser.