ezvcard.io.html
Class HCardElement

java.lang.Object
  extended by ezvcard.io.html.HCardElement

public class HCardElement
extends Object

Wraps hCard functionality around an HTML Element object.

Author:
Michael Angstadt

Constructor Summary
HCardElement(Element element)
          Creates an hCard element.
 
Method Summary
 String absUrl(String name)
          Gets the absolute URL of an attribute that has a URL.
 List<String> allValues(String cssClass)
          Gets the hCard values of all descendant elements that have the given CSS class name.
 void append(String text)
          Appends text to the element, replacing newlines with <br> tags.
 String attr(String name)
          Gets an attribute value.
 Set<String> classNames()
          Gets the element's CSS classes.
 String firstValue(String cssClass)
          Gets the hCard value of the first descendant element that has the given CSS class name.
 Element getElement()
          Gets the wrapped HTML element.
 String tagName()
          Gets the name of the HTML element.
 List<String> types()
          Gets all type values (for example, "home" and "cell" for the "tel" type).
 String value()
          Gets the hCard value of this element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HCardElement

public HCardElement(Element element)
Creates an hCard element.

Parameters:
element - the HTML element to wrap
Method Detail

tagName

public String tagName()
Gets the name of the HTML element.

Returns:
the tag name

attr

public String attr(String name)
Gets an attribute value.

Parameters:
name - the attribute name
Returns:
the attribute value or empty string if it doesn't exist

absUrl

public String absUrl(String name)
Gets the absolute URL of an attribute that has a URL.

Parameters:
name - the attribute name
Returns:
the absolute URL or empty string if it doesn't exist

classNames

public Set<String> classNames()
Gets the element's CSS classes.

Returns:
the CSS classes

value

public String value()
Gets the hCard value of this element. The value is determined based on the following:
  1. If the element is <abbr> and contains a title attribute, then the value of the title attribute is returned.
  2. Else, if the element contains one or more child elements that have a CSS class of value, then append together the text contents of these elements.
  3. Else, use the text content of the element itself.
All <br> tags are converted to newlines. All text within <del> tags are ignored.

Returns:
the element's hCard value

firstValue

public String firstValue(String cssClass)
Gets the hCard value of the first descendant element that has the given CSS class name.

Parameters:
cssClass - the CSS class name
Returns:
the hCard value or null if not found

allValues

public List<String> allValues(String cssClass)
Gets the hCard values of all descendant elements that have the given CSS class name.

Parameters:
cssClass - the CSS class name
Returns:
the hCard values

types

public List<String> types()
Gets all type values (for example, "home" and "cell" for the "tel" type).

Returns:
the type values (in lower-case)

append

public void append(String text)
Appends text to the element, replacing newlines with <br> tags.

Parameters:
text - the text to append

getElement

public Element getElement()
Gets the wrapped HTML element.

Returns:
the wrapped HTML element


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.