com.gargoylesoftware.htmlunit.html
Class HtmlAnchor

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.html.DomNode
      extended by com.gargoylesoftware.htmlunit.html.DomNamespaceNode
          extended by com.gargoylesoftware.htmlunit.html.DomElement
              extended by com.gargoylesoftware.htmlunit.html.HtmlElement
                  extended by com.gargoylesoftware.htmlunit.html.StyledElement
                      extended by com.gargoylesoftware.htmlunit.html.ClickableElement
                          extended by com.gargoylesoftware.htmlunit.html.FocusableElement
                              extended by com.gargoylesoftware.htmlunit.html.HtmlAnchor
All Implemented Interfaces:
Serializable, Cloneable

public class HtmlAnchor
extends FocusableElement

Wrapper for the html element "a"

Version:
$Revision: 2132 $
Author:
Mike Bowler, David K. Taylor, Christian Sell, Ahmed Ashour
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
HtmlElement.ChildElementsIterator, HtmlElement.MapEntryWrappingIterator
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.DomNode
DomNode.ChildIterator, DomNode.DescendantElementsIterator
 
Field Summary
static String TAG_NAME
          the HTML tag represented by this element
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
ATTRIBUTE_NOT_DEFINED, ATTRIBUTE_VALUE_EMPTY, TAB_INDEX_OUT_OF_BOUNDS
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.DomNode
ATTRIBUTE_NODE, COMMENT_NODE, DOCUMENT_NODE, ELEMENT_NODE, PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED, TEXT_NODE
 
Constructor Summary
HtmlAnchor(HtmlPage page, Map attributes)
          Deprecated. You should not directly construct HtmlAnchor.
 
Method Summary
protected  Page doClickAction(Page defaultPage)
          This method will be called if there either wasn't an onclick handler or there was but the result of that handler was true.
protected  Page doClickAction(Page defaultPage, String hrefSuffix)
          Same as doClickAction(Page) except that it accepts an href suffix needed when a click is performed on an image map to pass information on the click position.
 String getAccessKeyAttribute()
          Return the value of the attribute "accesskey".
 String getCharsetAttribute()
          Return the value of the attribute "charset".
 String getCoordsAttribute()
          Return the value of the attribute "coords".
 String getHrefAttribute()
          Return the value of the attribute "href".
 String getHrefLangAttribute()
          Return the value of the attribute "hreflang".
 String getNameAttribute()
          Return the value of the attribute "name".
 String getOnBlurAttribute()
          Return the value of the attribute "onblur".
 String getOnFocusAttribute()
          Return the value of the attribute "onfocus".
 String getRelAttribute()
          Return the value of the attribute "rel".
 String getRevAttribute()
          Return the value of the attribute "rev".
 String getShapeAttribute()
          Return the value of the attribute "shape".
 String getTabIndexAttribute()
          Return the value of the attribute "tabindex".
 String getTargetAttribute()
          Return the value of the attribute "target".
 String getTypeAttribute()
          Return the value of the attribute "type".
 Page openLinkInNewWindow()
          Open this link in a new window, much as web browsers do when you shift-click a link or use the context menu to open in a new window.
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.ClickableElement
click, click, click, dblClick, dblClick, getLangAttribute, getOnClickAttribute, getOnDblClickAttribute, getOnKeyDownAttribute, getOnKeyPressAttribute, getOnKeyUpAttribute, getOnMouseDownAttribute, getOnMouseMoveAttribute, getOnMouseOutAttribute, getOnMouseOverAttribute, getOnMouseUpAttribute, getTextDirectionAttribute, getXmlLangAttribute, isStateUpdateFirst
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.StyledElement
getClassAttribute, getIdAttribute, getStyleAttribute, getTitleAttribute, isRenderedVisible
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
addHtmlAttributeChangeListener, appendChildIfNoneExists, assertNotEmpty, blur, cloneDomNode, cloneNode, fireEvent, fireEvent, fireHtmlAttributeAdded, fireHtmlAttributeRemoved, fireHtmlAttributeReplaced, focus, getAttribute, getAttributeEntriesIterator, getAttributeNS, getAttributeValue, getChildElementsIterator, getEnclosingElement, getEnclosingForm, getEnclosingFormOrDie, getEventHandler, getHtmlElementById, getHtmlElementsByAttribute, getHtmlElementsByTagName, getHtmlElementsByTagNames, getId, getNodeName, getNodeType, getOneHtmlElementByAttribute, getTabIndex, getTagName, hasAttribute, hasAttributeNS, hasAttributes, hasHtmlElementWithId, isAttributeDefined, isEmptyXmlTagExpanded, isSubmittableByEnter, keyDown, keyDown, mouseDown, mouseDown, mouseMove, mouseMove, mouseOut, mouseOut, mouseOver, mouseOver, mouseUp, mouseUp, notImplemented, preventDefault, printOpeningTagContentAsXml, printXml, removeAttribute, removeAttributeNS, removeChild, removeEventHandler, removeHtmlAttributeChangeListener, rightClick, rightClick, setAttribute, setAttributeNS, setAttributeValue, setAttributeValue, setEventHandler, setEventHandler, setId, toString, type, type, type, type
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNamespaceNode
getLocalName, getNamespaceURI, getPrefix, getQualifiedName, setPrefix
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNode
addDomChangeListener, addPropertyChangeListener, appendChild, appendDomChild, asText, asXml, fireNodeAdded, fireNodeDeleted, firePropertyChange, getAllHtmlChildElements, getByXPath, getChildIterator, getChildrenAsText, getEndColumnNumber, getEndLineNumber, getFirstByXPath, getFirstChild, getFirstDomChild, getLastChild, getLastDomChild, getLog, getNativePage, getNextDomSibling, getNextSibling, getNodeValue, getPage, getParentDomNode, getParentNode, getPreviousDomSibling, getPreviousSibling, getReadyState, getScriptObject, getStartColumnNumber, getStartLineNumber, insertBefore, isAncestorOf, isTrimmedText, notifyIncorrectness, onAddedToPage, onAllChildrenAddedToPage, printChildrenAsXml, reduceWhitespace, remove, removeAllChildren, removeDomChangeListener, removePropertyChangeListener, replace, setNextSibling, setNodeValue, setParentNode, setPreviousSibling, setReadyState, setScriptObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_NAME

public static final String TAG_NAME
the HTML tag represented by this element

See Also:
Constant Field Values
Constructor Detail

HtmlAnchor

public HtmlAnchor(HtmlPage page,
                  Map attributes)
Deprecated. You should not directly construct HtmlAnchor.

Create an instance

Parameters:
page - The page that contains this element
attributes - the initial attributes
Method Detail

doClickAction

protected Page doClickAction(Page defaultPage,
                             String hrefSuffix)
                      throws IOException
Same as doClickAction(Page) except that it accepts an href suffix needed when a click is performed on an image map to pass information on the click position.

Parameters:
defaultPage - The default page to return if the action does not load a new page.
hrefSuffix - the suffix to add to the anchor's href attribute (for instance coordinates from an image map)
Returns:
The page that is currently loaded after execution of this method
Throws:
IOException - If an IO error occurred

doClickAction

protected Page doClickAction(Page defaultPage)
                      throws IOException
This method will be called if there either wasn't an onclick handler or there was but the result of that handler was true. This is the default behavior of clicking the element. For this anchor element, the default behavior is to open the HREF page, or execute the HREF if it is a javascript: URL.

Overrides:
doClickAction in class ClickableElement
Parameters:
defaultPage - The default page to return if the action does not load a new page.
Returns:
The page that is currently loaded after execution of this method
Throws:
IOException - If an IO error occurred

getCharsetAttribute

public final String getCharsetAttribute()
Return the value of the attribute "charset". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "charset" or an empty string if that attribute isn't defined.

getTypeAttribute

public final String getTypeAttribute()
Return the value of the attribute "type". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "type" or an empty string if that attribute isn't defined.

getNameAttribute

public final String getNameAttribute()
Return the value of the attribute "name". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "name" or an empty string if that attribute isn't defined.

getHrefAttribute

public final String getHrefAttribute()
Return the value of the attribute "href". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "href" or an empty string if that attribute isn't defined.

getHrefLangAttribute

public final String getHrefLangAttribute()
Return the value of the attribute "hreflang". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "hreflang" or an empty string if that attribute isn't defined.

getRelAttribute

public final String getRelAttribute()
Return the value of the attribute "rel". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "rel" or an empty string if that attribute isn't defined.

getRevAttribute

public final String getRevAttribute()
Return the value of the attribute "rev". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "rev" or an empty string if that attribute isn't defined.

getAccessKeyAttribute

public final String getAccessKeyAttribute()
Return the value of the attribute "accesskey". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "accesskey" or an empty string if that attribute isn't defined.

getShapeAttribute

public final String getShapeAttribute()
Return the value of the attribute "shape". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "shape" or an empty string if that attribute isn't defined.

getCoordsAttribute

public final String getCoordsAttribute()
Return the value of the attribute "coords". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "coords" or an empty string if that attribute isn't defined.

getTabIndexAttribute

public final String getTabIndexAttribute()
Return the value of the attribute "tabindex". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "tabindex" or an empty string if that attribute isn't defined.

getOnFocusAttribute

public final String getOnFocusAttribute()
Return the value of the attribute "onfocus". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "onfocus" or an empty string if that attribute isn't defined.

getOnBlurAttribute

public final String getOnBlurAttribute()
Return the value of the attribute "onblur". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "onblur" or an empty string if that attribute isn't defined.

getTargetAttribute

public final String getTargetAttribute()
Return the value of the attribute "target". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "target" or an empty string if that attribute isn't defined.

openLinkInNewWindow

public final Page openLinkInNewWindow()
                               throws MalformedURLException
Open this link in a new window, much as web browsers do when you shift-click a link or use the context menu to open in a new window. It should be noted that even web browsers will sometimes not give the expected result when using this method of following links. Links that have no real href and rely on javascript to do their work will fail.

Returns:
The Page opened by this link, nested in a new TopLevelWindow
Throws:
MalformedURLException - if the href could not be converted to a valid URL


Copyright © 2002-2010 Gargoyle Software Inc.. All Rights Reserved.