Class Anchor

All Implemented Interfaces:
Serializable, Cloneable, org.jdom2.NamespaceAware, org.jdom2.Parent

@ProviderType public final class Anchor extends AbstractNonSelfClosingHtmlElement
Html anchor (a) element.
See Also:
  • Constructor Details

    • Anchor

      public Anchor()
      Initializes html element.
    • Anchor

      public Anchor(String href)
      Initializes html element.
      Parameters:
      href - Html "href" attribute.
    • Anchor

      public Anchor(String href, String target)
      Initializes html element.
      Parameters:
      href - Html "href" attribute.
      target - Html "target" attribute.
  • Method Details

    • getRel

      public String getRel()
      Html "rel" attribute.
      Returns:
      Value of attribute
    • setRel

      public Anchor setRel(String value)
      Html "rel" attribute.
      Parameters:
      value - Value of attribute
      Returns:
      Self reference
    • getHRef

      public String getHRef()
      Html "href" attribute.
      Returns:
      Value of attribute
    • setHRef

      public Anchor setHRef(String value)
      Html "href" attribute.
      Parameters:
      value - Value of attribute
      Returns:
      Self reference
    • getTarget

      public String getTarget()
      Html "target" attribute.
      Returns:
      Value of attribute
    • setTarget

      public Anchor setTarget(String value)
      Html "target" attribute.
      Parameters:
      value - Value of attribute
      Returns:
      Self reference
    • getTabIndex

      public int getTabIndex()
      Html "tabindex" attribute.
      Returns:
      Value of attribute
    • setTabIndex

      public Anchor setTabIndex(int value)
      Html "tabindex" attribute.
      Parameters:
      value - Value of attribute
      Returns:
      Self reference
    • getAccessKey

      public String getAccessKey()
      Html "accesskey" attribute.
      Returns:
      Value of attribute
    • setAccessKey

      public Anchor setAccessKey(String value)
      Html "accesskey" attribute.
      Parameters:
      value - Value of attribute
      Returns:
      Self reference
    • setEmptyAttributeValueAsBoolean

      protected Anchor setEmptyAttributeValueAsBoolean(String attributeName, boolean value)
      Description copied from class: HtmlElement
      Sets "empty" attribute value as boolean (i.e. for "checked" attribute).
      Overrides:
      setEmptyAttributeValueAsBoolean in class HtmlElement
      Parameters:
      attributeName - Attribute name
      value - Attribute value as boolean
      Returns:
      Self reference
    • setId

      public Anchor setId(String value)
      Description copied from class: HtmlElement
      Html "id" attribute.
      Overrides:
      setId in class HtmlElement
      Parameters:
      value - Value of attribute
      Returns:
      Self reference
    • setCssClass

      public Anchor setCssClass(String value)
      Description copied from class: HtmlElement
      Sets Html "class" attribute - unless you're really sure that you want to replace existing classes, you probably should call HtmlElement.addCssClass(String) instead.
      Overrides:
      setCssClass in class HtmlElement
      Parameters:
      value - Value of attribute
      Returns:
      Self reference
    • addCssClass

      public Anchor addCssClass(String value)
      Description copied from class: HtmlElement
      Html "class" attribute. Adds a single, space-separated value while preserving existing ones.
      Overrides:
      addCssClass in class HtmlElement
      Parameters:
      value - Value of attribute
      Returns:
      Self reference
    • setStyleString

      public Anchor setStyleString(String value)
      Description copied from class: HtmlElement
      Html "style" attribute.
      Overrides:
      setStyleString in class HtmlElement
      Parameters:
      value - Value of attribute with style key/value pairs
      Returns:
      Self reference
    • setStyle

      public Anchor setStyle(String styleAttribute, String styleValue)
      Description copied from class: HtmlElement
      Html "style" attribute. Sets single style attribute value.
      Overrides:
      setStyle in class HtmlElement
      Parameters:
      styleAttribute - Style attribute name
      styleValue - Style attribute value
      Returns:
      Self reference
    • setTitle

      public Anchor setTitle(String value)
      Description copied from class: HtmlElement
      Html "title" attribute.
      Overrides:
      setTitle in class HtmlElement
      Parameters:
      value - Value of attribute
      Returns:
      Self reference
    • setData

      public Anchor setData(String attributeName, String value)
      Description copied from class: HtmlElement
      Custom Html5 "data-*" attribute.
      Overrides:
      setData in class HtmlElement
      Parameters:
      attributeName - Name of HTML5 data attribute (without the 'data-' prefix).
      value - Value of attribute
      Returns:
      Self reference
    • setAttributeValueAsLong

      public Anchor setAttributeValueAsLong(String name, long value)
      Description copied from class: AbstractElement
      Sets attribute value as long.
      Overrides:
      setAttributeValueAsLong in class AbstractElement
      Parameters:
      name - Attribute name
      value - Attribute value as long
      Returns:
      Self reference
    • setText

      public Anchor setText(String text)
      Description copied from class: AbstractElement
      Sets the content of the element to be the text given. All existing text content and non-text context is removed. If this element should have both textual content and nested elements, use Element.setContent(java.util.Collection<? extends org.jdom2.Content>) instead. Setting a null text value is equivalent to setting an empty string value.
      Overrides:
      setText in class AbstractElement
      Parameters:
      text - new text content for the element
      Returns:
      the target element