Class DomUtil
java.lang.Object
org.camunda.bpm.model.xml.impl.util.DomUtil
Helper methods which abstract some gruesome DOM specifics.
It does not provide synchronization when invoked in parallel with
the same objects.
- Author:
- Daniel Meyer, Sebastian Menski
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classFiltersElementsby their nodeName + namespaceUristatic classstatic classFilter retaining only Nodes of typeNode.ELEMENT_NODEstatic interfaceADomUtil.NodeListFilterallows to filter aNodeList, retaining only elements in the list which match the filter. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<DomElement>filterNodeList(NodeList nodeList, DomUtil.NodeListFilter filter) Allows to apply aDomUtil.NodeListFilterto aNodeList.static List<DomElement>filterNodeListByName(NodeList nodeList, String namespaceUri, String localName) Filter aNodeListretaining all elements with a specific namestatic List<DomElement>filterNodeListByType(NodeList nodeList, ModelInstanceImpl modelInstance, Class<?> type) Filter aNodeListretaining all elements with a specific typestatic List<DomElement>filterNodeListForElements(NodeList nodeList) Filters aNodeListretaining all elementsstatic DomDocumentgetEmptyDocument(DocumentBuilderFactory documentBuilderFactory) Get an empty DOM documentstatic DomDocumentparseInputStream(DocumentBuilderFactory documentBuilderFactory, InputStream inputStream) Create a new DOM document from the input stream
-
Constructor Details
-
DomUtil
public DomUtil()
-
-
Method Details
-
filterNodeList
Allows to apply aDomUtil.NodeListFilterto aNodeList. This allows to remove all elements from a node list which do not match the Filter.- Parameters:
nodeList- theNodeListto filterfilter- theDomUtil.NodeListFilterto apply to theNodeList- Returns:
- the List of all Nodes which match the filter
-
filterNodeListForElements
Filters aNodeListretaining all elements- Parameters:
nodeList- the theNodeListto filter- Returns:
- the list of all elements
-
filterNodeListByName
public static List<DomElement> filterNodeListByName(NodeList nodeList, String namespaceUri, String localName) Filter aNodeListretaining all elements with a specific name- Parameters:
nodeList- theNodeListto filternamespaceUri- the namespace for the elementslocalName- the local element name to filter for- Returns:
- the List of all Elements which match the filter
-
filterNodeListByType
public static List<DomElement> filterNodeListByType(NodeList nodeList, ModelInstanceImpl modelInstance, Class<?> type) Filter aNodeListretaining all elements with a specific type- Parameters:
nodeList- theNodeListto filtermodelInstance- the model instancetype- the type class to filter for- Returns:
- the list of all Elements which match the filter
-
getEmptyDocument
Get an empty DOM document- Parameters:
documentBuilderFactory- the factory to build to DOM document- Returns:
- the new empty document
- Throws:
ModelParseException- if unable to create a new document
-
parseInputStream
public static DomDocument parseInputStream(DocumentBuilderFactory documentBuilderFactory, InputStream inputStream) Create a new DOM document from the input stream- Parameters:
documentBuilderFactory- the factory to build to DOM documentinputStream- the input stream to parse- Returns:
- the new DOM document
- Throws:
ModelParseException- if a parsing or IO error is triggered
-