Class DefaultXmlService
java.lang.Object
org.apache.maven.api.xml.XmlService
org.apache.maven.internal.xml.DefaultXmlService
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.maven.api.xml.XmlService
XmlService.InputLocationBuilder
-
Field Summary
Fields inherited from class org.apache.maven.api.xml.XmlService
CHILDREN_COMBINATION_APPEND, CHILDREN_COMBINATION_MERGE, CHILDREN_COMBINATION_MODE_ATTRIBUTE, DEFAULT_CHILDREN_COMBINATION_MODE, DEFAULT_SELF_COMBINATION_MODE, ID_COMBINATION_MODE_ATTRIBUTE, KEYS_COMBINATION_MODE_ATTRIBUTE, SELF_COMBINATION_MERGE, SELF_COMBINATION_MODE_ATTRIBUTE, SELF_COMBINATION_OVERRIDE, SELF_COMBINATION_REMOVE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMerges one DOM into another, given a specific algorithm and possible override points for that algorithm.doRead
(InputStream input, XmlService.InputLocationBuilder locationBuilder) Implementation method for reading an XML node from an input stream.doRead
(Reader reader, XmlService.InputLocationBuilder locationBuilder) Implementation method for reading an XML node from a reader.doRead
(XMLStreamReader parser, XmlService.InputLocationBuilder locationBuilder) Implementation method for reading an XML node from an XMLStreamReader.void
Implementation method for writing an XML node to a writer.
-
Constructor Details
-
DefaultXmlService
public DefaultXmlService()
-
-
Method Details
-
doRead
@Nonnull public XmlNode doRead(InputStream input, @Nullable XmlService.InputLocationBuilder locationBuilder) throws XMLStreamException Description copied from class:XmlService
Implementation method for reading an XML node from an input stream.- Specified by:
doRead
in classXmlService
- Parameters:
input
- the input stream to read fromlocationBuilder
- optional builder for creating input location objects- Returns:
- the parsed XML node
- Throws:
XMLStreamException
- if there is an error parsing the XML
-
doRead
@Nonnull public XmlNode doRead(Reader reader, @Nullable XmlService.InputLocationBuilder locationBuilder) throws XMLStreamException Description copied from class:XmlService
Implementation method for reading an XML node from a reader.- Specified by:
doRead
in classXmlService
- Parameters:
reader
- the reader to read fromlocationBuilder
- optional builder for creating input location objects- Returns:
- the parsed XML node
- Throws:
XMLStreamException
- if there is an error parsing the XML
-
doRead
@Nonnull public XmlNode doRead(XMLStreamReader parser, @Nullable XmlService.InputLocationBuilder locationBuilder) throws XMLStreamException Description copied from class:XmlService
Implementation method for reading an XML node from an XMLStreamReader.- Specified by:
doRead
in classXmlService
- Parameters:
parser
- the XML stream reader to read fromlocationBuilder
- optional builder for creating input location objects- Returns:
- the parsed XML node
- Throws:
XMLStreamException
- if there is an error parsing the XML
-
doWrite
Description copied from class:XmlService
Implementation method for writing an XML node to a writer.- Specified by:
doWrite
in classXmlService
- Parameters:
node
- the XML node to writewriter
- the writer to write to- Throws:
IOException
- if there is an error writing the XML
-
doMerge
Merges one DOM into another, given a specific algorithm and possible override points for that algorithm.The algorithm is as follows:
- if the recessive DOM is null, there is nothing to do... return.
- Determine whether the dominant node will suppress the recessive one (flag=mergeSelf).
- retrieve the 'combine.self' attribute on the dominant node, and try to match against 'override'... if it matches 'override', then set mergeSelf == false...the dominant node suppresses the recessive one completely.
- otherwise, use the default value for mergeSelf, which is true...this is the same as specifying 'combine.self' == 'merge' as an attribute of the dominant root node.
- If mergeSelf == true
- Determine whether children from the recessive DOM will be merged or appended to the dominant DOM as
siblings (flag=mergeChildren).
- if childMergeOverride is set (non-null), use that value (true/false)
- retrieve the 'combine.children' attribute on the dominant node, and try to match against 'append'...
- if it matches 'append', then set mergeChildren == false...the recessive children will be appended as siblings of the dominant children.
- otherwise, use the default value for mergeChildren, which is true...this is the same as specifying 'combine.children' == 'merge' as an attribute on the dominant root node.
- Iterate through the recessive children, and:
- if mergeChildren == true and there is a corresponding dominant child (matched by element name), merge the two.
- otherwise, add the recessive child as a new child on the dominant root node.
- Determine whether children from the recessive DOM will be merged or appended to the dominant DOM as
siblings (flag=mergeChildren).
- Specified by:
doMerge
in classXmlService
- Parameters:
dominant
- the dominant (higher priority) XML noderecessive
- the recessive (lower priority) XML nodechildMergeOverride
- optional override for the child merge mode- Returns:
- the merged XML node, or null if both inputs are null
-