Class AbstractMergeableElementList
- java.lang.Object
-
- org.codehaus.plexus.metadata.merge.support.AbstractMergeableSupport
-
- org.codehaus.plexus.metadata.merge.support.AbstractMergeableElement
-
- org.codehaus.plexus.metadata.merge.support.AbstractMergeableElementList
-
- All Implemented Interfaces:
Mergeable
- Direct Known Subclasses:
ComponentsElement
,RequirementsElement
public abstract class AbstractMergeableElementList extends AbstractMergeableElement
Base class that allows for handling merging two element lists.TODO Refactor and make this extend
AbstractMergeableElement
which is what this actually is, but with added bits for merging child element lists.
-
-
Field Summary
-
Fields inherited from class org.codehaus.plexus.metadata.merge.support.AbstractMergeableSupport
element
-
-
Constructor Summary
Constructors Constructor Description AbstractMergeableElementList(org.jdom2.Element element)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.util.List
getElementNamesForConflictResolution(java.util.List defaultList)
Sub classes should override if they wish to provide a different combination of composite keys for determining conflicts.protected abstract java.lang.String
getTagNameForRecurringMergeable()
Allows the sub classes to provided a tag name that they expect to recurr within them.private boolean
isMergeRequired(java.util.Set dKeySet, java.util.Set rKeySet)
Determines if a merge operation is required for the two sets (dominant and recessive) specified.private DescriptorTag
lookupTagInstanceByName(java.lang.String name, DescriptorTag[] values)
Looks up and returns anDescriptorTag
instance for the specified tag name.void
merge(Mergeable me)
Merges an element of same type.protected void
merge(org.jdom2.Element parent, java.util.Map dMap, java.util.Map rMap)
Identifies the conflicting elements in the dominant and recessiveMap
instance and merges as required.protected java.util.Map
parseRecurringMergeables(java.lang.String tagName, java.util.List compositeKeyList, Mergeable parentElement)
Parses <component> elements and builds a map keyed basd on the list of composite keys specified.-
Methods inherited from class org.codehaus.plexus.metadata.merge.support.AbstractMergeableElement
isRecessiveElementInConflict, isRecessiveElementInConflict, merge, mergeableElementComesFromRecessive
-
Methods inherited from class org.codehaus.plexus.metadata.merge.support.AbstractMergeableSupport
addContent, addContent, addContent, addContent, addContent, addNamespaceDeclaration, clone, cloneContent, detach, equals, getAdditionalNamespaces, getAttribute, getAttribute, getAttributes, getAttributeValue, getAttributeValue, getAttributeValue, getAttributeValue, getChild, getChild, getChildren, getChildren, getChildren, getChildText, getChildText, getChildTextNormalize, getChildTextNormalize, getChildTextTrim, getChildTextTrim, getContent, getContent, getContent, getContentSize, getDefaultMergeStrategy, getDescendants, getDescendants, getDocument, getElement, getName, getNamespace, getNamespace, getNamespacePrefix, getNamespaceURI, getParent, getParentElement, getQualifiedName, getText, getTextNormalize, getTextTrim, getValue, hashCode, indexOf, isAncestor, isExpectedElementType, isRootElement, removeAttribute, removeAttribute, removeAttribute, removeChild, removeChild, removeChildren, removeChildren, removeContent, removeContent, removeContent, removeContent, removeNamespaceDeclaration, setAttribute, setAttribute, setAttribute, setAttributes, setContent, setContent, setContent, setContent, setName, setNamespace, setText, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.codehaus.plexus.metadata.merge.support.Mergeable
getAllowedTags
-
-
-
-
Method Detail
-
parseRecurringMergeables
protected java.util.Map parseRecurringMergeables(java.lang.String tagName, java.util.List compositeKeyList, Mergeable parentElement) throws java.lang.Exception
Parses <component> elements and builds a map keyed basd on the list of composite keys specified.- Parameters:
tagName
- Name of the tag that appears multiple timescompositeKeyList
- List of element/tag names to be used as composite keys to register recurringMergeable
instances.parentElement
-Mergeable
.- Returns:
- Map of
Mergeable
instances keyed on the composite key obtained fromgetElementNamesForConflictResolution(java.util.List)
- Throws:
java.lang.Exception
- if there was an error parsing and registeringMergeable
instances
-
lookupTagInstanceByName
private DescriptorTag lookupTagInstanceByName(java.lang.String name, DescriptorTag[] values)
Looks up and returns anDescriptorTag
instance for the specified tag name.- Parameters:
name
- key to look up theDescriptorTag
instance on.- Returns:
DescriptorTag
instance whose name matches the name specified. Returnsnull
if no match is found.
-
merge
public void merge(Mergeable me) throws MergeException
Description copied from class:AbstractMergeableSupport
Merges an element of same type.- Specified by:
merge
in interfaceMergeable
- Overrides:
merge
in classAbstractMergeableElement
- Parameters:
me
- Another entity that is mergeable.- Throws:
MergeException
- if there was an error merging the mergeables.
-
merge
protected void merge(org.jdom2.Element parent, java.util.Map dMap, java.util.Map rMap) throws java.lang.Exception
Identifies the conflicting elements in the dominant and recessiveMap
instance and merges as required.- Parameters:
parent
-Element
that is parent for the children in the dominant Map instance. Merged content is added to this element.dMap
- Dominant Map keyed by the composite key obtained fromgetElementNamesForConflictResolution(List)
rMap
- Recessive Map keyed by the composite key obtained fromgetElementNamesForConflictResolution(List)
- Throws:
java.lang.Exception
- if there was an error merging both the maps.
-
isMergeRequired
private boolean isMergeRequired(java.util.Set dKeySet, java.util.Set rKeySet)
Determines if a merge operation is required for the two sets (dominant and recessive) specified.- Parameters:
dKeySet
- the dominant set of elements.rKeySet
- the recessive set of elements.- Returns:
true
if a merge operation was required.
-
getTagNameForRecurringMergeable
protected abstract java.lang.String getTagNameForRecurringMergeable()
Allows the sub classes to provided a tag name that they expect to recurr within them. For instance:- <components> expects <component> to recurr within itself.
- <requirements> expects <requirement> to recurr within itself.
- Returns:
- tag name of the
Mergeable
element that occurs multiple times.
-
getElementNamesForConflictResolution
protected abstract java.util.List getElementNamesForConflictResolution(java.util.List defaultList)
Description copied from class:AbstractMergeableSupport
Sub classes should override if they wish to provide a different combination of composite keys for determining conflicts.- Overrides:
getElementNamesForConflictResolution
in classAbstractMergeableSupport
- Parameters:
defaultList
- the default list.- Returns:
- the default list.
-
-