org.jboss.dna.connector.federation.merge.strategy
Class SimpleMergeStrategy

java.lang.Object
  extended by org.jboss.dna.connector.federation.merge.strategy.SimpleMergeStrategy
All Implemented Interfaces:
MergeStrategy

@ThreadSafe
public class SimpleMergeStrategy
extends Object
implements MergeStrategy

This merge strategy simply merges all of the contributions' properties and combines the children according to the order of the contributions. No children are merged, and all properties are used (except if they are deemed to be duplicates of the property in other contributions).

Author:
Randall Hauch

Nested Class Summary
protected static class SimpleMergeStrategy.DualIterator
           
 
Constructor Summary
SimpleMergeStrategy()
           
 
Method Summary
 boolean isRemoveDuplicateProperties()
           
 void merge(FederatedNode federatedNode, List<Contribution> contributions, org.jboss.dna.graph.ExecutionContext context)
          Merge the contributions into a single
protected  org.jboss.dna.graph.properties.Property merge(org.jboss.dna.graph.properties.Property property1, org.jboss.dna.graph.properties.Property property2, org.jboss.dna.graph.properties.PropertyFactory factory, boolean removeDuplicates)
          Merge the values from the two properties with the same name, returning a new property with the newly merged values.
 void setRemoveDuplicateProperties(boolean removeDuplicateProperties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleMergeStrategy

public SimpleMergeStrategy()
Method Detail

isRemoveDuplicateProperties

public boolean isRemoveDuplicateProperties()
Returns:
removeDuplicateProperties

setRemoveDuplicateProperties

public void setRemoveDuplicateProperties(boolean removeDuplicateProperties)
Parameters:
removeDuplicateProperties - Sets removeDuplicateProperties to the specified value.

merge

public void merge(FederatedNode federatedNode,
                  List<Contribution> contributions,
                  org.jboss.dna.graph.ExecutionContext context)
Merge the contributions into a single

Specified by:
merge in interface MergeStrategy
Parameters:
federatedNode - the federated node into which the contributions are to be merged; never null
contributions - the contributions to the node; never null, never empty, and never containing nulls
context - the context in which this operation is to be performed; never null
See Also:
MergeStrategy.merge(org.jboss.dna.connector.federation.merge.FederatedNode, java.util.List, org.jboss.dna.graph.ExecutionContext)

merge

protected org.jboss.dna.graph.properties.Property merge(org.jboss.dna.graph.properties.Property property1,
                                                        org.jboss.dna.graph.properties.Property property2,
                                                        org.jboss.dna.graph.properties.PropertyFactory factory,
                                                        boolean removeDuplicates)
Merge the values from the two properties with the same name, returning a new property with the newly merged values.

The current algorithm merges the values by concatenating the values from property1 and property2, and if removeDuplicates is true any values in property2 that are identical to values found in property1 are skipped.

Parameters:
property1 - the first property; may not be null, and must have the same name as property2
property2 - the second property; may not be null, and must have the same name as property1
factory - the property factory, used to create the result
removeDuplicates - true if this method removes any values in the second property that duplicate values found in the first property.
Returns:
the property that contains the same name as the input properties, but with values that are merged from both of the input properties


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.