org.codehaus.plexus.cdc.merge.support
Class AbstractMergeableElementList

java.lang.Object
  extended by org.codehaus.plexus.cdc.merge.support.AbstractMergeableSupport
      extended by org.codehaus.plexus.cdc.merge.support.AbstractMergeableElement
          extended by org.codehaus.plexus.cdc.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.

Version:
$Id: AbstractMergeableElementList.java 3522 2006-07-12 15:06:21Z brett $
Author:
Rahul Thakur

Field Summary
 
Fields inherited from class org.codehaus.plexus.cdc.merge.support.AbstractMergeableSupport
element
 
Constructor Summary
AbstractMergeableElementList(org.jdom.Element element)
           
 
Method Summary
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.
protected  void merge(org.jdom.Element parent, java.util.Map dMap, java.util.Map rMap)
          Identifies the conflicting elements in the dominant and recessive Map instance and merges as required.
 void merge(Mergeable me)
          Merges an element of same type.
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.cdc.merge.support.AbstractMergeableElement
isRecessiveElementInConflict, isRecessiveElementInConflict, merge, mergeableElementComesFromRecessive
 
Methods inherited from class org.codehaus.plexus.cdc.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.cdc.merge.support.Mergeable
getAllowedTags
 

Constructor Detail

AbstractMergeableElementList

public AbstractMergeableElementList(org.jdom.Element element)
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 times
compositeKeyList - List of element/tag names to be used as composite keys to register recurring Mergeable instances.
Returns:
Map of Mergeable instances keyed on the composite key obtained from getElementNamesForConflictResolution(java.util.List)
Throws:
java.lang.Exception - if there was an error parsing and registering Mergeable instances

merge

public void merge(Mergeable me)
           throws MergeException
Description copied from interface: Mergeable
Merges an element of same type.

Specified by:
merge in interface Mergeable
Overrides:
merge in class AbstractMergeableElement
Parameters:
me - Another entity that is mergeable.
Throws:
MergeException - if there was an error merging the mergeables.

merge

protected void merge(org.jdom.Element parent,
                     java.util.Map dMap,
                     java.util.Map rMap)
              throws java.lang.Exception
Identifies the conflicting elements in the dominant and recessive Map 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 from getElementNamesForConflictResolution(List)
rMap - Recessive Map keyed by the composite key obtained from getElementNamesForConflictResolution(List)
Throws:
java.lang.Exception - if there was an error merging both the maps.

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:

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 class AbstractMergeableSupport


Copyright © 2001-2011 Codehaus. All Rights Reserved.