Package org.camunda.spin.xml
Class SpinXmlElement
- Direct Known Subclasses:
DomXmlElement
An element in a tree-oriented XML data format.
- Author:
- Sebastian Menski, Daniel Meyer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract SpinXmlElement
append
(Collection<SpinXmlElement> childElements) Appends child elements to thiselement
.abstract SpinXmlElement
append
(SpinXmlElement... childElements) Appends child elements to thiselement
.abstract SpinXmlElement
appendAfter
(SpinXmlElement childElement, SpinXmlElement existingChildElement) abstract SpinXmlElement
appendBefore
(SpinXmlElement childElement, SpinXmlElement existingChildElement) Appends a child element to this element before the existing child element.abstract SpinXmlAttribute
Returns the wrapped attribute for an empty namespace and the given name.abstract SpinXmlElement
Sets the attribute value in the local namespace of this element.Returns all names of the attributes of this element.Returns all names of the attributes in the given namespace.abstract SpinXmlAttribute
Returns the wrapped attribute for the given namespace and name.abstract SpinXmlElement
Sets the attribute value in the given namespace.abstract SpinList<SpinXmlAttribute>
attrs()
Returns all wrapped attributes of this element.abstract SpinList<SpinXmlAttribute>
Returns all wrapped attributes for the given namespace.abstract SpinXmlElement
childElement
(String elementName) Returns a single wrapped child element for the given name in the local namespace of this element.abstract SpinXmlElement
childElement
(String namespace, String elementName) Returns a single wrapped childelement
for the given namespace and name.abstract SpinList<SpinXmlElement>
Returns all child elements of thiselements
.abstract SpinList<SpinXmlElement>
childElements
(String elementName) Returns all childelements
with a given name in the local namespace of this element.abstract SpinList<SpinXmlElement>
childElements
(String namespace, String elementName) Returns all childelements
with a given namespace and name.abstract boolean
Checks whether this element has a attribute with an empty namespace and the given name.abstract boolean
Checks whether this element has a attribute with the given namespace and name.abstract SpinXmlElement
remove
(Collection<SpinXmlElement> childElements) Removes all child elements from this element.abstract SpinXmlElement
remove
(SpinXmlElement... childElements) Removes all child elements from this element.abstract SpinXmlElement
removeAttr
(String attributeName) Removes the attribute with an empty namespace.abstract SpinXmlElement
removeAttrNs
(String namespace, String attributeName) Removes the attribute under the given namespace.abstract SpinXmlElement
replace
(SpinXmlElement newChildElement) Replaces this element by an new one.abstract SpinXmlElement
replaceChild
(SpinXmlElement existingChildElement, SpinXmlElement newChildElement) Replaces an existing child element with a new one.abstract String
Returns the text content of an element.abstract SpinXmlElement
textContent
(String textContent) Sets the text content of an element.abstract String
toString()
Returns the wrapped XML element as string representation.abstract void
writeToWriter
(Writer writer) Writes the wrapped XML element to a existing writer.abstract SpinXPathQuery
Creates a XPath query on this element.Methods inherited from class org.camunda.spin.xml.SpinXmlNode
hasNamespace, hasPrefix, mapTo, mapTo, name, namespace, prefix
-
Constructor Details
-
SpinXmlElement
public SpinXmlElement()
-
-
Method Details
-
hasAttr
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:
IllegalArgumentException
- if the attributeName is null
-
attr
Returns the wrapped attribute for an empty namespace and the given name.- Parameters:
attributeName
- the name of the attribute- Returns:
- the wrapped
attribute
- Throws:
IllegalArgumentException
- if the attributeName is nullSpinXmlAttributeException
- if the attribute is not found
-
attr
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:
IllegalArgumentException
- if the attributeName or value is null
-
removeAttr
Removes the attribute with an empty namespace.- Parameters:
attributeName
- the name of the attribute- Returns:
- the wrapped
element
- Throws:
IllegalArgumentException
- if the attributeName is null
-
hasAttrNs
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:
IllegalArgumentException
- if the attributeName is null
-
attrNs
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:
IllegalArgumentException
- if attributeName or value is nullSpinXmlElementImplementationException
- if the attribute cannot be set in the underlying implementation
-
attrNs
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:
IllegalArgumentException
- if attributeName or value is nullSpinXmlElementImplementationException
- if the attribute cannot be set in the underlying implementation
-
removeAttrNs
Removes the attribute under the given namespace.- Parameters:
namespace
- the namespace of the attributeattributeName
- the name of the attribute- Returns:
- the wrapped
element
- Throws:
IllegalArgumentException
- if the attributeName is null
-
attrs
Returns all wrapped attributes of this element.- Returns:
- the wrapped attributes or an empty list of no attributes are found
-
attrs
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
Returns all names of the attributes of this element.- Returns:
- the names of the attributes
-
attrNames
Returns all names of the attributes in the given namespace.- Returns:
- the names of the attributes
-
textContent
Returns the text content of an element.- Returns:
- the text content or an empty string if non exists
-
textContent
Sets the text content of an element.- Parameters:
textContent
- the text content to set- Returns:
- the wrapped
element
- Throws:
IllegalArgumentException
- if the textContent is null
-
childElement
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:
IllegalArgumentException
- if the elementName is nullSpinXmlElementException
- if none or more than one child element is found
-
childElement
Returns a single wrapped childelement
for the given namespace and name.- Parameters:
namespace
- the namespace of the elementelementName
- the element name- Returns:
- the wrapped child
element
- Throws:
IllegalArgumentException
- if the elementName is nullSpinXmlElementException
- if none or more than one child element is found
-
childElements
Returns all child elements of thiselements
.- Returns:
- list of wrapped child
elements
-
childElements
Returns all childelements
with a given name in the local namespace of this element.- Parameters:
elementName
- the element name- Returns:
- a collection of wrapped
elements
- Throws:
IllegalArgumentException
- if the element name is nullSpinXmlElementException
- if no child element was found
-
childElements
Returns all childelements
with a given namespace and name.- Parameters:
namespace
- the namespace of the elementelementName
- the element name- Returns:
- a collection of wrapped
elements
- Throws:
IllegalArgumentException
- if the element name is nullSpinXmlElementException
- if no child element was found
-
append
Appends child elements to thiselement
.- Parameters:
childElements
- the child elements to append- Returns:
- the wrapped
element
- Throws:
IllegalArgumentException
- if the childElements is null or one of themSpinXmlElementImplementationException
- if a child element cannot be appended in the underlying implementation
-
append
Appends child elements to thiselement
.- Parameters:
childElements
- the child elements to append- Returns:
- the wrapped
element
- Throws:
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:
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:
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
Removes all child elements from this element.- Parameters:
childElements
- the child elements to remove- Returns:
- the wrapped
element
- Throws:
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
Removes all child elements from this element.- Parameters:
childElements
- the child elements to remove- Returns:
- the wrapped
element
- Throws:
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
Replaces this element by an new one.- Parameters:
newChildElement
- the new element- Returns:
- the new wrapped
element
- Throws:
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:
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
Creates a XPath query on this element.- Parameters:
expression
- the XPath expression- Returns:
- the XPath query
-
toString
Returns the wrapped XML element as string representation.- Specified by:
toString
in classSpin<SpinXmlElement>
- Returns:
- the string representation
- Throws:
SpinXmlElementException
- if the element cannot be transformed or no new transformer can be created
-
writeToWriter
Writes the wrapped XML element to a existing writer.- Specified by:
writeToWriter
in classSpin<SpinXmlElement>
- Parameters:
writer
- the writer to write to- Throws:
SpinXmlElementException
- if the element cannot be transformed or no new transformer can be created
-