public abstract class AbstractMergeableElementList extends AbstractMergeableElement
TODO Refactor and make this extend AbstractMergeableElement
which is what
this actually is, but with added bits for merging child element lists.
element
Constructor and Description |
---|
AbstractMergeableElementList(org.jdom2.Element element) |
Modifier and Type | Method and 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 an
DescriptorTag instance for the
specified tag name. |
protected void |
merge(org.jdom2.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.
|
isRecessiveElementInConflict, isRecessiveElementInConflict, merge, mergeableElementComesFromRecessive
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
finalize, getClass, notify, notifyAll, wait, wait, wait
getAllowedTags
public AbstractMergeableElementList(org.jdom2.Element element)
protected java.util.Map parseRecurringMergeables(java.lang.String tagName, java.util.List compositeKeyList, Mergeable parentElement) throws java.lang.Exception
tagName
- Name of the tag that appears multiple timescompositeKeyList
- List of element/tag names to be used as composite keys to register recurring
Mergeable
instances.parentElement
- Mergeable
.Mergeable
instances keyed on the composite key obtained from
getElementNamesForConflictResolution(java.util.List)
java.lang.Exception
- if there was an error parsing and registering Mergeable
instancesprivate DescriptorTag lookupTagInstanceByName(java.lang.String name, DescriptorTag[] values)
DescriptorTag
instance for the
specified tag name.name
- key to look up the DescriptorTag
instance on.DescriptorTag
instance whose name matches the name specified.
Returns null
if no match is found.public void merge(Mergeable me) throws MergeException
AbstractMergeableSupport
merge
in interface Mergeable
merge
in class AbstractMergeableElement
me
- Another entity that is mergeable.MergeException
- if there was an error merging the mergeables.protected void merge(org.jdom2.Element parent, java.util.Map dMap, java.util.Map rMap) throws java.lang.Exception
Map
instance and merges as required.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)
java.lang.Exception
- if there was an error merging both the maps.private boolean isMergeRequired(java.util.Set dKeySet, java.util.Set rKeySet)
dKeySet
- the dominant set of elements.rKeySet
- the recessive set of elements.true
if a merge operation was required.protected abstract java.lang.String getTagNameForRecurringMergeable()
Mergeable
element that occurs multiple times.protected abstract java.util.List getElementNamesForConflictResolution(java.util.List defaultList)
AbstractMergeableSupport
getElementNamesForConflictResolution
in class AbstractMergeableSupport
defaultList
- the default list.