Class DomUtil
- java.lang.Object
-
- org.camunda.bpm.model.xml.impl.util.DomUtil
-
public final class DomUtil extends java.lang.Object
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 Classes Modifier and Type Class Description static class
DomUtil.DomErrorHandler
static class
DomUtil.ElementByNameListFilter
FiltersElements
by their nodeName + namespaceUristatic class
DomUtil.ElementByTypeListFilter
static class
DomUtil.ElementNodeListFilter
Filter retaining only Nodes of typeNode.ELEMENT_NODE
static interface
DomUtil.NodeListFilter
ADomUtil.NodeListFilter
allows to filter aNodeList
, retaining only elements in the list which match the filter.
-
Constructor Summary
Constructors Constructor Description DomUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<DomElement>
filterNodeList(org.w3c.dom.NodeList nodeList, DomUtil.NodeListFilter filter)
Allows to apply aDomUtil.NodeListFilter
to aNodeList
.static java.util.List<DomElement>
filterNodeListByName(org.w3c.dom.NodeList nodeList, java.lang.String namespaceUri, java.lang.String localName)
Filter aNodeList
retaining all elements with a specific namestatic java.util.List<DomElement>
filterNodeListByType(org.w3c.dom.NodeList nodeList, ModelInstanceImpl modelInstance, java.lang.Class<?> type)
Filter aNodeList
retaining all elements with a specific typestatic java.util.List<DomElement>
filterNodeListForElements(org.w3c.dom.NodeList nodeList)
Filters aNodeList
retaining all elementsstatic DomDocument
getEmptyDocument(javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)
Get an empty DOM documentstatic DomDocument
parseInputStream(javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory, java.io.InputStream inputStream)
Create a new DOM document from the input stream
-
-
-
Method Detail
-
filterNodeList
public static java.util.List<DomElement> filterNodeList(org.w3c.dom.NodeList nodeList, DomUtil.NodeListFilter filter)
Allows to apply aDomUtil.NodeListFilter
to aNodeList
. This allows to remove all elements from a node list which do not match the Filter.- Parameters:
nodeList
- theNodeList
to filterfilter
- theDomUtil.NodeListFilter
to apply to theNodeList
- Returns:
- the List of all Nodes which match the filter
-
filterNodeListForElements
public static java.util.List<DomElement> filterNodeListForElements(org.w3c.dom.NodeList nodeList)
Filters aNodeList
retaining all elements- Parameters:
nodeList
- the theNodeList
to filter- Returns:
- the list of all elements
-
filterNodeListByName
public static java.util.List<DomElement> filterNodeListByName(org.w3c.dom.NodeList nodeList, java.lang.String namespaceUri, java.lang.String localName)
Filter aNodeList
retaining all elements with a specific name- Parameters:
nodeList
- theNodeList
to 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 java.util.List<DomElement> filterNodeListByType(org.w3c.dom.NodeList nodeList, ModelInstanceImpl modelInstance, java.lang.Class<?> type)
Filter aNodeList
retaining all elements with a specific type- Parameters:
nodeList
- theNodeList
to filtermodelInstance
- the model instancetype
- the type class to filter for- Returns:
- the list of all Elements which match the filter
-
getEmptyDocument
public static DomDocument getEmptyDocument(javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)
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(javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory, java.io.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
-
-