Package org.camunda.spin.xml
Class SpinXmlElement
- java.lang.Object
-
- org.camunda.spin.Spin<T>
-
- org.camunda.spin.xml.SpinXmlNode<SpinXmlElement>
-
- org.camunda.spin.xml.SpinXmlElement
-
- Direct Known Subclasses:
DomXmlElement
public abstract class SpinXmlElement extends SpinXmlNode<SpinXmlElement>
An element in a tree-oriented XML data format.- Author:
- Sebastian Menski, Daniel Meyer
-
-
Constructor Summary
Constructors Constructor Description SpinXmlElement()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract SpinXmlElementappend(java.util.Collection<SpinXmlElement> childElements)Appends child elements to thiselement.abstract SpinXmlElementappend(SpinXmlElement... childElements)Appends child elements to thiselement.abstract SpinXmlElementappendAfter(SpinXmlElement childElement, SpinXmlElement existingChildElement)abstract SpinXmlElementappendBefore(SpinXmlElement childElement, SpinXmlElement existingChildElement)Appends a child element to this element before the existing child element.abstract SpinXmlAttributeattr(java.lang.String attributeName)Returns the wrapped attribute for an empty namespace and the given name.abstract SpinXmlElementattr(java.lang.String attributeName, java.lang.String value)Sets the attribute value in the local namespace of this element.abstract java.util.List<java.lang.String>attrNames()Returns all names of the attributes of this element.abstract java.util.List<java.lang.String>attrNames(java.lang.String namespace)Returns all names of the attributes in the given namespace.abstract SpinXmlAttributeattrNs(java.lang.String namespace, java.lang.String attributeName)Returns the wrapped attribute for the given namespace and name.abstract SpinXmlElementattrNs(java.lang.String namespace, java.lang.String attributeName, java.lang.String value)Sets the attribute value in the given namespace.abstract SpinList<SpinXmlAttribute>attrs()Returns all wrapped attributes of this element.abstract SpinList<SpinXmlAttribute>attrs(java.lang.String namespace)Returns all wrapped attributes for the given namespace.abstract SpinXmlElementchildElement(java.lang.String elementName)Returns a single wrapped child element for the given name in the local namespace of this element.abstract SpinXmlElementchildElement(java.lang.String namespace, java.lang.String elementName)Returns a single wrapped childelementfor the given namespace and name.abstract SpinList<SpinXmlElement>childElements()Returns all child elements of thiselements.abstract SpinList<SpinXmlElement>childElements(java.lang.String elementName)Returns all childelementswith a given name in the local namespace of this element.abstract SpinList<SpinXmlElement>childElements(java.lang.String namespace, java.lang.String elementName)Returns all childelementswith a given namespace and name.abstract booleanhasAttr(java.lang.String attributeName)Checks whether this element has a attribute with an empty namespace and the given name.abstract booleanhasAttrNs(java.lang.String namespace, java.lang.String attributeName)Checks whether this element has a attribute with the given namespace and name.abstract SpinXmlElementremove(java.util.Collection<SpinXmlElement> childElements)Removes all child elements from this element.abstract SpinXmlElementremove(SpinXmlElement... childElements)Removes all child elements from this element.abstract SpinXmlElementremoveAttr(java.lang.String attributeName)Removes the attribute with an empty namespace.abstract SpinXmlElementremoveAttrNs(java.lang.String namespace, java.lang.String attributeName)Removes the attribute under the given namespace.abstract SpinXmlElementreplace(SpinXmlElement newChildElement)Replaces this element by an new one.abstract SpinXmlElementreplaceChild(SpinXmlElement existingChildElement, SpinXmlElement newChildElement)Replaces an existing child element with a new one.abstract java.lang.StringtextContent()Returns the text content of an element.abstract SpinXmlElementtextContent(java.lang.String textContent)Sets the text content of an element.abstract java.lang.StringtoString()Returns the wrapped XML element as string representation.abstract voidwriteToWriter(java.io.Writer writer)Writes the wrapped XML element to a existing writer.abstract SpinXPathQueryxPath(java.lang.String expression)Creates a XPath query on this element.-
Methods inherited from class org.camunda.spin.xml.SpinXmlNode
hasNamespace, hasPrefix, mapTo, mapTo, name, namespace, prefix
-
-
-
-
Method Detail
-
hasAttr
public abstract boolean hasAttr(java.lang.String attributeName)
Checks whether this element has a attribute with an empty namespace and the given name.- Parameters:
attributeName- the name of the attribute- Returns:
- true if the element has an attribute with this name under the local namespace, false otherwise
- Throws:
java.lang.IllegalArgumentException- if the attributeName is null
-
attr
public abstract SpinXmlAttribute attr(java.lang.String attributeName)
Returns the wrapped attribute for an empty namespace and the given name.- Parameters:
attributeName- the name of the attribute- Returns:
- the wrapped
attribute - Throws:
java.lang.IllegalArgumentException- if the attributeName is nullSpinXmlAttributeException- if the attribute is not found
-
attr
public abstract SpinXmlElement attr(java.lang.String attributeName, java.lang.String value)
Sets the attribute value in the local namespace of this element.- Parameters:
attributeName- the name of the attributevalue- the value to set- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if the attributeName or value is null
-
removeAttr
public abstract SpinXmlElement removeAttr(java.lang.String attributeName)
Removes the attribute with an empty namespace.- Parameters:
attributeName- the name of the attribute- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if the attributeName is null
-
hasAttrNs
public abstract boolean hasAttrNs(java.lang.String namespace, java.lang.String attributeName)Checks whether this element has a attribute with the given namespace and name.- Parameters:
namespace- the namespace of the attributeattributeName- the name of the attribute- Returns:
- true if the element has an attribute with this name under given namespace, false otherwise
- Throws:
java.lang.IllegalArgumentException- if the attributeName is null
-
attrNs
public abstract SpinXmlAttribute attrNs(java.lang.String namespace, java.lang.String attributeName)
Returns the wrapped attribute for the given namespace and name.- Parameters:
namespace- the namespace of the attributeattributeName- the name of the attribute- Returns:
- the wrapped
attribute - Throws:
java.lang.IllegalArgumentException- if attributeName or value is nullSpinXmlElementImplementationException- if the attribute cannot be set in the underlying implementation
-
attrNs
public abstract SpinXmlElement attrNs(java.lang.String namespace, java.lang.String attributeName, java.lang.String value)
Sets the attribute value in the given namespace.- Parameters:
namespace- the namespace of the attributeattributeName- the name of the attributevalue- the value to set- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if attributeName or value is nullSpinXmlElementImplementationException- if the attribute cannot be set in the underlying implementation
-
removeAttrNs
public abstract SpinXmlElement removeAttrNs(java.lang.String namespace, java.lang.String attributeName)
Removes the attribute under the given namespace.- Parameters:
namespace- the namespace of the attributeattributeName- the name of the attribute- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if the attributeName is null
-
attrs
public abstract SpinList<SpinXmlAttribute> attrs()
Returns all wrapped attributes of this element.- Returns:
- the wrapped attributes or an empty list of no attributes are found
-
attrs
public abstract SpinList<SpinXmlAttribute> attrs(java.lang.String namespace)
Returns all wrapped attributes for the given namespace.- Parameters:
namespace- the namespace of the attributes- Returns:
- the wrapped attributes or an empty list of no attributes are found
-
attrNames
public abstract java.util.List<java.lang.String> attrNames()
Returns all names of the attributes of this element.- Returns:
- the names of the attributes
-
attrNames
public abstract java.util.List<java.lang.String> attrNames(java.lang.String namespace)
Returns all names of the attributes in the given namespace.- Returns:
- the names of the attributes
-
textContent
public abstract java.lang.String textContent()
Returns the text content of an element.- Returns:
- the text content or an empty string if non exists
-
textContent
public abstract SpinXmlElement textContent(java.lang.String textContent)
Sets the text content of an element.- Parameters:
textContent- the text content to set- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if the textContent is null
-
childElement
public abstract SpinXmlElement childElement(java.lang.String elementName)
Returns a single wrapped child element for the given name in the local namespace of this element.- Parameters:
elementName- the element name- Returns:
- the wrapped child
element - Throws:
java.lang.IllegalArgumentException- if the elementName is nullSpinXmlElementException- if none or more than one child element is found
-
childElement
public abstract SpinXmlElement childElement(java.lang.String namespace, java.lang.String elementName)
Returns a single wrapped childelementfor the given namespace and name.- Parameters:
namespace- the namespace of the elementelementName- the element name- Returns:
- the wrapped child
element - Throws:
java.lang.IllegalArgumentException- if the elementName is nullSpinXmlElementException- if none or more than one child element is found
-
childElements
public abstract SpinList<SpinXmlElement> childElements()
Returns all child elements of thiselements.- Returns:
- list of wrapped child
elements
-
childElements
public abstract SpinList<SpinXmlElement> childElements(java.lang.String elementName)
Returns all childelementswith a given name in the local namespace of this element.- Parameters:
elementName- the element name- Returns:
- a collection of wrapped
elements - Throws:
java.lang.IllegalArgumentException- if the element name is nullSpinXmlElementException- if no child element was found
-
childElements
public abstract SpinList<SpinXmlElement> childElements(java.lang.String namespace, java.lang.String elementName)
Returns all childelementswith a given namespace and name.- Parameters:
namespace- the namespace of the elementelementName- the element name- Returns:
- a collection of wrapped
elements - Throws:
java.lang.IllegalArgumentException- if the element name is nullSpinXmlElementException- if no child element was found
-
append
public abstract SpinXmlElement append(SpinXmlElement... childElements)
Appends child elements to thiselement.- Parameters:
childElements- the child elements to append- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if the childElements is null or one of themSpinXmlElementImplementationException- if a child element cannot be appended in the underlying implementation
-
append
public abstract SpinXmlElement append(java.util.Collection<SpinXmlElement> childElements)
Appends child elements to thiselement.- Parameters:
childElements- the child elements to append- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if the childElements is null or one of themSpinXmlElementImplementationException- if a child element cannot be appended in the underlying implementation
-
appendBefore
public abstract SpinXmlElement appendBefore(SpinXmlElement childElement, SpinXmlElement existingChildElement)
Appends a child element to this element before the existing child element.- Parameters:
childElement- the child element to appendexistingChildElement- the child element to append before- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if the child element or existing child element is nullSpinXmlElementException- if the existing child element is not a child of this elementSpinXmlElementImplementationException- if the new child element cannot be inserted in the underlying implementation
-
appendAfter
public abstract SpinXmlElement appendAfter(SpinXmlElement childElement, SpinXmlElement existingChildElement)
- Parameters:
childElement- the child element to appendexistingChildElement- the child element to append after- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if the child element or existing child element is nullSpinXmlElementException- if the existing child element is not a child of this elementSpinXmlElementImplementationException- if the new child element cannot be inserted in the underlying implementation
-
remove
public abstract SpinXmlElement remove(SpinXmlElement... childElements)
Removes all child elements from this element.- Parameters:
childElements- the child elements to remove- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if child elements is null or any of themSpinXmlElementException- if one of the child elements does not existSpinXmlElementImplementationException- if the child element cannot be removed in the underlying implementation
-
remove
public abstract SpinXmlElement remove(java.util.Collection<SpinXmlElement> childElements)
Removes all child elements from this element.- Parameters:
childElements- the child elements to remove- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if child elements is null or any of themSpinXmlElementException- if one of the child elements does not existSpinXmlElementImplementationException- if the child element cannot be removed in the underlying implementation
-
replace
public abstract SpinXmlElement replace(SpinXmlElement newChildElement)
Replaces this element by an new one.- Parameters:
newChildElement- the new element- Returns:
- the new wrapped
element - Throws:
java.lang.IllegalArgumentException- if the new element is null or has the wrong typeSpinXmlElementException- if this element has no parent elementSpinXmlElementImplementationException- if the element cannot be replaced in the underlying implementation
-
replaceChild
public abstract SpinXmlElement replaceChild(SpinXmlElement existingChildElement, SpinXmlElement newChildElement)
Replaces an existing child element with a new one.- Parameters:
existingChildElement- the existing child element to replacenewChildElement- the new child element- Returns:
- the wrapped
element - Throws:
java.lang.IllegalArgumentException- if any of the child elements is nullSpinXmlElementException- if the existing element is not a child element of thisSpinXmlElementImplementationException- if the child cannot be replaced in the underlying implementation
-
xPath
public abstract SpinXPathQuery xPath(java.lang.String expression)
Creates a XPath query on this element.- Parameters:
expression- the XPath expression- Returns:
- the XPath query
-
toString
public abstract java.lang.String toString()
Returns the wrapped XML element as string representation.- Specified by:
toStringin classSpin<SpinXmlElement>- Returns:
- the string representation
- Throws:
SpinXmlElementException- if the element cannot be transformed or no new transformer can be created
-
writeToWriter
public abstract void writeToWriter(java.io.Writer writer)
Writes the wrapped XML element to a existing writer.- Specified by:
writeToWriterin classSpin<SpinXmlElement>- Parameters:
writer- the writer to write to- Throws:
SpinXmlElementException- if the element cannot be transformed or no new transformer can be created
-
-