org.eclipse.actf.visualization.eval.html

## Class HtmlEvalUtil

- java.lang.Object
- - org.eclipse.actf.visualization.eval.html.HtmlTagUtil
  - - org.eclipse.actf.visualization.eval.html.HtmlEvalUtil

All Implemented Interfaces:
  IHtmlEventHandlerAttributes

    public class HtmlEvalUtil
    extends HtmlTagUtil

Utility class for HTML evaluation

### Field Summary

Fields
`static String[]` `EVENT_FOCUS`
`static String[]` `EVENT_LOAD`
`static String[]` `EVENT_MOUSE_BUTTON`
`static String[]` `EVENT_MOUSE_FOCUS`
`static String[]` `EVENT_ON_KEY`
`static String[]` `EVENT_WINDOW`

### Fields inherited from class org.eclipse.actf.visualization.eval.html.HtmlTagUtil

`ATTR_ALT, ATTR_HREF, ATTR_SRC, ATTR_TITLE, FLASH_CODEBASE, FLASH_OBJECT, FLASH_PLUGINSPAGE, FLASH_TYPE`

### Fields inherited from interface org.eclipse.actf.visualization.eval.html.IHtmlEventHandlerAttributes

`ATTR_ONABORT, ATTR_ONBLUR, ATTR_ONCLICK, ATTR_ONDBLCLICK, ATTR_ONDRAGDROP, ATTR_ONERROR, ATTR_ONFOCUS, ATTR_ONKEYDOWN, ATTR_ONKEYPRESS, ATTR_ONKEYUP, ATTR_ONLOAD, ATTR_ONMOUSEDOWN, ATTR_ONMOUSEMOVE, ATTR_ONMOUSEOUT, ATTR_ONMOUSEOVER, ATTR_ONMOUSEUP, ATTR_ONMOVE, ATTR_ONRESIZE, ATTR_ONSELECT, ATTR_ONUNLOAD`

### Constructor Summary

Constructors
Constructor and Description
`HtmlEvalUtil(Document target, Document resultDoc, String url, Map<Node,Integer> document2IdMap, Document srcDom, Document liveDom, PageData pageData, boolean isDBCS, boolean isLive)` Constructor of the class.

### Method Summary

Methods
`boolean` `appendErrorIcon(IProblemItem pitem, Element original)` Append an error icon to an element in the blind view.
`List<Element>` `getAccessKeyElements()` Get all elements that has accessKey.
`List<Element>` `getAppletElements()` Get all applet elements.
`List<Element>` `getAreaElements()` Get all area elements.
`Element[]` `getAWithHref_elements()` Get array of anchor `Element` who has href attribute
`String[]` `getAWithHref_hrefs()` Get target hrefs of anchor Elements
`String[]` `getAWithHref_strings()` Get text descendant of anchor `Element` who has href attribute
`URL` `getBaseUrl()` Get base URL of the target page
`Element[]` `getBody_elements()` Get body `Element`
`Element[]` `getBottom_1row1col_tables()` Get tables who has 1 row and 1 column
`Element[]` `getBottom_data_tables()` Get bottom data tables in the nested table
`Element[]` `getBottom_notdata_tables()` Get bottom tables (not data table) in the nested table
`Map<Node,Integer>` `getDocument2IdMap()` Get map between `Node` and ACTF_ID
`List<Element>` `getElementsList(Node node, String tagName, String... tagNames)` Utility function similar to getElementsByTagName() that returns a List instance instead of a NodeList instance.
`List<Element>` `getElementsWithId()` Get all elements that has id attribute.
`List<Element>` `getElementsWithStyle()` Get all elements that has style attribute.
`Element[]` `getEmbed_elements()` Get all embed `Element` in the page
`Element[]` `getEventFocusElements()` Get array of `Element` that has focus event handler (onfocus, onblur or onselect)
`Element[]` `getEventLoadElements()` Get array of `Element` that has event handler (onload, onunload, onabort or onerror)
`Element[]` `getEventMouseButtonElements()` Get array of `Element` that has mouse event handler (onclick, ondblclick, onmouseup or onmousedown)
`Element[]` `getEventOnKeyElements()` Get array of `Element` that has onkey event handler (onkeydown, onkeyup or onkeypress)
`Element[]` `getEventOnMouseElements()` Get array of `Element` that has onmouse event handler (onmouseover, onmouseout or onmousemove)
`Element[]` `getEventWindowElements()` Get array of `Element` that has window event handler (onresize, onmove or ondragdrop)
`Element[]` `getFrame_elements()` Get frame `Element` in the page
`int` `getHeadingLevel(String strNodeName)` Get heading level as int
`Element[]` `getHeadings()` Get all heading `Element` in the page
`Element[]` `getIframe_elements()` Get all iframe `Element` in the page
`List<Element>` `getImageButtons()` Get all image button (input elements whose type is "image").
`org.w3c.dom.html.HTMLImageElement[]` `getImg_elements()` Get all img `Element` in the page
`double` `getInvalidLinkRatio()` Get invalid link ratio of the page.
`int` `getInvisibleElementCount()` Deprecated.
`String[]` `getInvisibleLinkStrings()` Deprecated.
`Element[]` `getJavascriptHref_elements()` Get all <a href="javascript:...
`String[]` `getJavascriptHref_hrefs()` Get all href Strings of <a href="javascript:...
`String[]` `getJavascriptHref_strings()` Get text descendant of anchor `Element` for JavaScript
`Document` `getLiveDom()` Get live DOM
`File` `getLiveFile()` Get HTML file that represents live DOM
`HashSet<String>` `getNotExistHrefSet()` Deprecated.
`Element[]` `getObject_elements()` Get all object `Element` in the page
`PageData` `getPageData()` Get target page information as `PageData`
`Element[]` `getParent_table_elements()` Get array of parent table elements of nested tables.
`Document` `getResult()` Get visualization result `Document`
`Element[]` `getScript_elements()` Get all script `Element`
`Document` `getSrcDom()` Get source DOM
`File` `getSrcFile()` Get source HTML file
`List<Element>` `getStyleElements()` Get all style elements.
`Element[]` `getTable_elements()` Get all table `Element` in the page
`Document` `getTarget()` Get target `Document`
`File` `getTargetFile()` Get evaluation target HTML file
`List<Element>` `getTextButtons()` Get all text-based button.
`String` `getUrl()` Get URL of the page
`boolean` `isDBCS()` Check if the target page uses DBCS
`boolean` `isHasAwithHref()` Check if the page has <a href="">
`boolean` `isHasJavascript()` Check if the page uses JavaScript
`boolean` `isLiveDom()` Check if the target DOM is live DOM
`void` `setLiveFile(File liveFile)` Set HTML file that represents live DOM
`void` `setSrcFile(File srcFile)` Set source HTML file
`void` `setTargetFile(File targetFile)` Set evaluation target HTML file

### Methods inherited from class org.eclipse.actf.visualization.eval.html.HtmlTagUtil

`getAncestor, getBlockElementSet, getImgElementsFromMap, getNoScriptText, getTextAltDescendant, getTextDescendant, hasAncestor, hasTextDescendant, isBlankString, isButtonControl, isTextControl`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### EVENT_MOUSE_BUTTON

    public static final String[] EVENT_MOUSE_BUTTON

#### EVENT_MOUSE_FOCUS

    public static final String[] EVENT_MOUSE_FOCUS

#### EVENT_ON_KEY

    public static final String[] EVENT_ON_KEY

#### EVENT_LOAD

    public static final String[] EVENT_LOAD

#### EVENT_WINDOW

    public static final String[] EVENT_WINDOW

#### EVENT_FOCUS

    public static final String[] EVENT_FOCUS

### Constructor Detail

#### HtmlEvalUtil

    public HtmlEvalUtil(Document target,
                Document resultDoc,
                String url,
                Map<Node,Integer> document2IdMap,
                Document srcDom,
                Document liveDom,
                PageData pageData,
                boolean isDBCS,
                boolean isLive)

Constructor of the class.

Parameters:
  `target` - target `Document`
  `resultDoc` - visualization result `Document`
  `url` - target URL
  `document2IdMap` - map between `Node` and ACTF_ID
  `srcDom` - the original source `Document`
  `liveDom` - the live `Document` obtained from browser
  `pageData` - the detailed page information as `PageData`
  `isDBCS` - true if target page uses DBCS
  `isLive` - true if target is live DOM

### Method Detail

#### getElementsList

    public List<Element> getElementsList(Node node,
                                String tagName,
                                String... tagNames)

Utility function similar to getElementsByTagName() that returns a List instance instead of a NodeList instance.

Parameters:
  `el` - an Element or Document instance
  `tagName` - the name of element which you want look for
  `tagNames` - optional list of element names which you want look for
Returns:
  `List` of elements with given tag name that are descendants of the node.

#### getHeadingLevel

    public int getHeadingLevel(String strNodeName)

Get heading level as int

Parameters:
  `strNodeName` - target Heading tag name (H1, H2,..., H6)
Returns:
  heading level as int (1, 2,..., 6)

#### getAccessKeyElements

    public List<Element> getAccessKeyElements()

Get all elements that has accessKey.

Returns:

#### getElementsWithStyle

    public List<Element> getElementsWithStyle()

Get all elements that has style attribute.

Returns:

#### getElementsWithId

    public List<Element> getElementsWithId()

Get all elements that has id attribute.

Returns:

#### getStyleElements

    public List<Element> getStyleElements()

Get all style elements.

Returns:

#### getAppletElements

    public List<Element> getAppletElements()

Get all applet elements.

Returns:

#### getAreaElements

    public List<Element> getAreaElements()

Get all area elements.

Returns:

#### getAWithHref_elements

    public Element[] getAWithHref_elements()

Get array of anchor `Element` who has href attribute

Returns:
  array of anchor `Element` who has href attribute

#### getAWithHref_hrefs

    public String[] getAWithHref_hrefs()

Get target hrefs of anchor Elements

Returns:
  target hrefs

#### getAWithHref_strings

    public String[] getAWithHref_strings()

Get text descendant of anchor `Element` who has href attribute

Returns:
  text descendant of anchor `Element` who has href attribute
See Also:
  `HtmlTagUtil.getTextAltDescendant(Node)`

#### getBaseUrl

    public URL getBaseUrl()

Get base URL of the target page

Returns:
  base URL

#### getBody_elements

    public Element[] getBody_elements()

Get body `Element`

Returns:
  body `Element`

#### getBottom_1row1col_tables

    public Element[] getBottom_1row1col_tables()

Get tables who has 1 row and 1 column

Returns:
  table `Element` who has 1 row and 1 column

#### getBottom_data_tables

    public Element[] getBottom_data_tables()

Get bottom data tables in the nested table

Returns:
  bottom data tables in the nested table

#### getBottom_notdata_tables

    public Element[] getBottom_notdata_tables()

Get bottom tables (not data table) in the nested table

Returns:
  bottom tables in the nested table

#### getUrl

    public String getUrl()

Get URL of the page

Returns:
  URL of the page

#### getDocument2IdMap

    public Map<Node,Integer> getDocument2IdMap()

Get map between `Node` and ACTF_ID

Returns:
  map between `Node` and ACTF_ID

#### getFrame_elements

    public Element[] getFrame_elements()

Get frame `Element` in the page

Returns:
  frame elements

#### isHasAwithHref

    public boolean isHasAwithHref()

Check if the page has

     <a href="">

Returns:
  true if the page has anchor with href attribute

#### isHasJavascript

    public boolean isHasJavascript()

Check if the page uses JavaScript

Returns:
  true if the page uses JavaScript

#### getHeadings

    public Element[] getHeadings()

Get all heading `Element` in the page

Returns:
  all heading elements

#### getLiveDom

    public Document getLiveDom()

Get live DOM

Returns:
  live DOM

#### getIframe_elements

    public Element[] getIframe_elements()

Get all iframe `Element` in the page

Returns:
  all iframe elements

#### getImg_elements

    public org.w3c.dom.html.HTMLImageElement[] getImg_elements()

Get all img `Element` in the page

Returns:
  all img elements

#### getImageButtons

    public List<Element> getImageButtons()

Get all image button (input elements whose type is "image").

Returns:

#### getTextButtons

    public List<Element> getTextButtons()

Get all text-based button.

Returns:

#### getInvalidLinkRatio

    public double getInvalidLinkRatio()

Get invalid link ratio of the page. (target URL number under invisible link/all target URL number)

Returns:
  invalid link ratio

#### getInvisibleElementCount

    public int getInvisibleElementCount()

Deprecated.
Get number of invisible `Element`

Returns:
  number of invisible elements

#### getInvisibleLinkStrings

    public String[] getInvisibleLinkStrings()

Deprecated.
Get array of link target urls of invisible anchor `Element`

Returns:
  array of link target urls of invisible anchor elements

#### isDBCS

    public boolean isDBCS()

Check if the target page uses DBCS

Returns:
  true if the target page uses DBCS

#### isLiveDom

    public boolean isLiveDom()

Check if the target DOM is live DOM

Returns:
  true if the target DOM is live DOM

#### getNotExistHrefSet

    public HashSet<String> getNotExistHrefSet()

Deprecated.
Get Set of target URL that are not included in source DOM but exist in live DOM. (might be inaccessible without JavaScript)

Returns:

#### getObject_elements

    public Element[] getObject_elements()

Get all object `Element` in the page

Returns:
  object elements

#### getSrcDom

    public Document getSrcDom()

Get source DOM

Returns:
  source DOM

#### getPageData

    public PageData getPageData()

Get target page information as `PageData`

Returns:
  target page information

#### getParent_table_elements

    public Element[] getParent_table_elements()

Get array of parent table elements of nested tables.

Returns:
  array of parent table elements of nested tables

#### getResult

    public Document getResult()

Get visualization result `Document`

Returns:
  result `Document`

#### getTable_elements

    public Element[] getTable_elements()

Get all table `Element` in the page

Returns:
  all table elements

#### getTarget

    public Document getTarget()

Get target `Document`

Returns:
  target `Document`

#### getEmbed_elements

    public Element[] getEmbed_elements()

Get all embed `Element` in the page

Returns:
  all embed elements

#### getJavascriptHref_elements

    public Element[] getJavascriptHref_elements()

Get all

     <a href="javascript:..."

elements

Returns:
  all anchor elements for JavaScript

#### getJavascriptHref_hrefs

    public String[] getJavascriptHref_hrefs()

Get all href Strings of

     <a href="javascript:..."

elements

Returns:
  all target arguments of anchor elements for JavaScript

#### getJavascriptHref_strings

    public String[] getJavascriptHref_strings()

Get text descendant of anchor `Element` for JavaScript

Returns:
  text descendant of anchor `Element` for JavaScript
See Also:
  `HtmlTagUtil.getTextAltDescendant(Node)`

#### getEventLoadElements

    public Element[] getEventLoadElements()

Get array of `Element` that has event handler (onload, onunload, onabort or onerror)

Returns:
  array of elements that have event handler for onload, onunload, onabort or onerror

#### getEventMouseButtonElements

    public Element[] getEventMouseButtonElements()

Get array of `Element` that has mouse event handler (onclick, ondblclick, onmouseup or onmousedown)

Returns:
  array of elements that have mouse event handler

#### getEventOnMouseElements

    public Element[] getEventOnMouseElements()

Get array of `Element` that has onmouse event handler (onmouseover, onmouseout or onmousemove)

Returns:
  array of elements that have onmouse event handler

#### getEventOnKeyElements

    public Element[] getEventOnKeyElements()

Get array of `Element` that has onkey event handler (onkeydown, onkeyup or onkeypress)

Returns:
  array of elements that have onkey event handler

#### getScript_elements

    public Element[] getScript_elements()

Get all script `Element`

Returns:
  all script elements

#### getEventWindowElements

    public Element[] getEventWindowElements()

Get array of `Element` that has window event handler (onresize, onmove or ondragdrop)

Returns:
  array of elements that have window event handler

#### getEventFocusElements

    public Element[] getEventFocusElements()

Get array of `Element` that has focus event handler (onfocus, onblur or onselect)

Returns:
  array of elements that have focus event handler

#### getTargetFile

    public File getTargetFile()

Get evaluation target HTML file

Returns:
  evaluation target HTML file

#### setTargetFile

    public void setTargetFile(File targetFile)

Set evaluation target HTML file

#### getSrcFile

    public File getSrcFile()

Get source HTML file

Returns:
  source HTML file

#### setSrcFile

    public void setSrcFile(File srcFile)

Set source HTML file

#### getLiveFile

    public File getLiveFile()

Get HTML file that represents live DOM

Returns:
  live DOM as HTML file

#### setLiveFile

    public void setLiveFile(File liveFile)

Set HTML file that represents live DOM

#### appendErrorIcon

    public boolean appendErrorIcon(IProblemItem pitem,
                          Element original)

Append an error icon to an element in the blind view. If it is already appended or it failed to append, returns false.

Parameters:
  `pitem` -
  `original` -
Returns: