ezvcard.io.xml
Class XCardElement

java.lang.Object
  extended by ezvcard.io.xml.XCardElement

public class XCardElement
extends Object

Wraps xCard functionality around an XML Element.

Author:
Michael Angstadt

Constructor Summary
XCardElement(Element element)
          Wraps an existing XML element.
XCardElement(Element element, VCardVersion version)
          Wraps an existing XML element.
XCardElement(String propertyName)
          Creates a new XML element under its own XML document.
XCardElement(String propertyName, VCardVersion version)
          Creates a new XML element under its own XML document.
 
Method Summary
 List<String> all(String localName)
          Gets the value of all non-empty child elements that have the given name.
 List<String> all(VCardDataType dataType)
          Gets all the values of a given data type.
 List<Element> append(String name, Collection<String> values)
          Adds multiple child elements, each with the same name.
 Element append(String name, String value)
          Adds a child element.
 Element append(VCardDataType dataType, String value)
          Adds a value.
 Document document()
          Gets the owner document.
 Element element()
          Gets the wrapped XML element.
 String first(String... names)
          Gets the value of the first child element with one of the given names.
 String first(VCardDataType... dataTypes)
          Gets the first value with one of the given data types.
 VCardVersion version()
          Gets the vCard version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XCardElement

public XCardElement(String propertyName)
Creates a new XML element under its own XML document.

Parameters:
propertyName - the property name (e.g. "adr")

XCardElement

public XCardElement(String propertyName,
                    VCardVersion version)
Creates a new XML element under its own XML document.

Parameters:
propertyName - the property name (e.g. "adr")
version - the vCard version

XCardElement

public XCardElement(Element element)
Wraps an existing XML element.

Parameters:
element - the XML element

XCardElement

public XCardElement(Element element,
                    VCardVersion version)
Wraps an existing XML element.

Parameters:
element - the XML element
version - the vCard version
Method Detail

first

public String first(VCardDataType... dataTypes)
Gets the first value with one of the given data types.

Parameters:
dataTypes - the data type(s) to look for (null signifies the "unknown" data type)
Returns:
the value or null if not found

first

public String first(String... names)
Gets the value of the first child element with one of the given names.

Parameters:
names - the possible names of the element
Returns:
the element's text or null if not found

all

public List<String> all(VCardDataType dataType)
Gets all the values of a given data type.

Parameters:
dataType - the data type to look for
Returns:
the values

all

public List<String> all(String localName)
Gets the value of all non-empty child elements that have the given name.

Parameters:
localName - the element name
Returns:
the values of the child elements

append

public Element append(VCardDataType dataType,
                      String value)
Adds a value.

Parameters:
dataType - the data type or null for the "unknown" data type
value - the value
Returns:
the created element

append

public Element append(String name,
                      String value)
Adds a child element.

Parameters:
name - the name of the child element
value - the value of the child element.
Returns:
the created element

append

public List<Element> append(String name,
                            Collection<String> values)
Adds multiple child elements, each with the same name.

Parameters:
name - the name for all the child elements
values - the values of each child element
Returns:
the created elements

document

public Document document()
Gets the owner document.

Returns:
the owner document

element

public Element element()
Gets the wrapped XML element.

Returns:
the wrapped XML element

version

public VCardVersion version()
Gets the vCard version.

Returns:
the vCard version


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