biweekly.io.xml
Class XCalElement

java.lang.Object
  extended by biweekly.io.xml.XCalElement

public class XCalElement
extends Object

Wraps xCal functionality around an XML Element object.

Author:
Michael Angstadt

Constructor Summary
XCalElement(Element element)
          Creates a new xCal element.
 
Method Summary
 List<String> all(ICalDataType dataType)
          Gets all the values of a given data type.
 List<String> all(String localName)
          Gets the values of all child elements that have the given name.
 XCalElement append(ICalDataType dataType)
          Adds an empty value.
 Element append(ICalDataType dataType, String value)
          Adds a value.
 XCalElement append(String name)
          Adds a child element.
 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.
 XCalElement child(ICalDataType dataType)
          Gets the first child element with the given data type.
 List<XCalElement> children(ICalDataType dataType)
          Gets all child elements with the given data type.
 Document document()
          Gets the owner document.
 String first(ICalDataType dataType)
          Gets the first value of the given data type.
 String first(String localName)
          Gets the value of the first child element with the given name.
 Element getElement()
          Gets the wrapped XML element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XCalElement

public XCalElement(Element element)
Creates a new xCal element.

Parameters:
element - the XML element to wrap
Method Detail

first

public String first(ICalDataType dataType)
Gets the first value of the given data type.

Parameters:
dataType - the data type to look for or null for the "unknown" data type
Returns:
the value or null if not found

first

public String first(String localName)
Gets the value of the first child element with the given name.

Parameters:
localName - the name of the element
Returns:
the element's text or null if not found

all

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

Parameters:
dataType - the data type to look for or null for the "unknown" data type
Returns:
the values

all

public List<String> all(String localName)
Gets the values of all child elements that have the given name.

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

append

public Element append(ICalDataType 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 XCalElement append(String name)
Adds a child element.

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

append

public XCalElement append(ICalDataType dataType)
Adds an empty value.

Parameters:
dataType - the data type
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

getElement

public Element getElement()
Gets the wrapped XML element.

Returns:
the wrapped XML element

children

public List<XCalElement> children(ICalDataType dataType)
Gets all child elements with the given data type.

Parameters:
dataType - the data type
Returns:
the child elements

child

public XCalElement child(ICalDataType dataType)
Gets the first child element with the given data type.

Parameters:
dataType - the data type
Returns:
the child element or null if not found


Copyright © 2013 Michael Angstadt. All Rights Reserved.