edu.UCL.xmiddle.lib.reconciliation
Class Resolutor

java.lang.Object
  |
  +--edu.UCL.xmiddle.lib.reconciliation.Resolutor
Direct Known Subclasses:
Arithmetic, Comparison, Replacement, Strings

public abstract class Resolutor
extends java.lang.Object

This defines an abstract class which Resolutor subclasses extend. Resolutors define which Resolutor types they can handle, and the priority of the handled types. For example, the Replace Resolutor can handle both 'keepSelf' and 'keepOther'. In the event of a conflict between resolutor types, the priorities of each can be checked, and the one with the greater priority kept.


Field Summary
protected  java.lang.String NAME
           
protected  double PRIORITY
           
protected  java.util.Hashtable types
           
 
Constructor Summary
Resolutor()
          Constructor.
 
Method Summary
protected  void addType(java.lang.String name)
           
 int compareTo(Resolutor compare)
          Compares the priority with a given one.
 int compareTypes(java.lang.String one, java.lang.String two)
          Compares the priorities of two given resolutors.
 java.lang.String getName()
          Returns the name of this Resolutor.
 double getPriority()
          Returns the relative priority of this Resolutor.
 java.util.Set getTypes()
          Returns the types handled by this Resolutor.
abstract  java.lang.String reconcile(java.lang.String local, java.lang.String remote, java.lang.String common, java.lang.String type)
          Reconciles the differences between the first String and the second String, using the given type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

protected java.lang.String NAME

PRIORITY

protected double PRIORITY

types

protected java.util.Hashtable types
Constructor Detail

Resolutor

public Resolutor()
Constructor. Extending sub-classes should set the NAME and PRIORITY fields here, and can use the addType() method to help create the list of resolutor types.

Method Detail

getName

public java.lang.String getName()
Returns the name of this Resolutor.

Returns:
a String holding the name of the Resolutor.

getPriority

public double getPriority()
Returns the relative priority of this Resolutor. 0 has the highest priority.

Returns:
a double holding the priority.

getTypes

public java.util.Set getTypes()
Returns the types handled by this Resolutor. The returned Set will contain Strings.

Returns:
a Hashtable with the resolutor types, and their priorites.

compareTo

public int compareTo(Resolutor compare)
Compares the priority with a given one. 'Less than' means 'has a higher priority'.

Parameters:
compare - The Resolutor against which to compare.
Returns:
an int set to '-1' if this < other, '0' if this == other, or '1' if this > other.

compareTypes

public int compareTypes(java.lang.String one,
                        java.lang.String two)
Compares the priorities of two given resolutors.

Parameters:
one - The first resolutor type.
two - The second resolutor type.
Returns:
an int set to '-1' if one < two, '0' if one == two, or '1' if one > two.

addType

protected void addType(java.lang.String name)

reconcile

public abstract java.lang.String reconcile(java.lang.String local,
                                           java.lang.String remote,
                                           java.lang.String common,
                                           java.lang.String type)
Reconciles the differences between the first String and the second String, using the given type. If some error occurs during resolution, this method will return null.

Parameters:
type - The resolutor type to be applied.
Returns:
The reconciled String.