Class URIDistance

  • All Implemented Interfaces:
    com.google.common.base.Function<EObject,​Iterable<String>>, Function<EObject,​Iterable<String>>

    public class URIDistance
    extends Object
    implements com.google.common.base.Function<EObject,​Iterable<String>>
    This class is able to measure similarity between "URI like" strings, basically strings separated by "/". This is mainly intended to be used with EMF's fragments.
    • Constructor Detail

      • URIDistance

        public URIDistance()
        Create a new URIDistance.
    • Method Detail

      • setComparison

        public void setComparison​(Comparison comparison)
        Set an optional comparison used to retrieve matches already computed. This will impact the way the uri is computed by making sure two matching objects will have the same URI.
        Parameters:
        comparison - the comparison to use to retrieve the matches.
      • proximity

        public int proximity​(EObject a,
                             EObject b)
        Return a metric result URI similarities. It compares 2 strings splitting those by "/" and return an int representing the level of similarity. 0 - they are exactly the same to 10 - they are completely different. "adding a fragment", "removing a fragment".
        Parameters:
        a - First of the two EObjects to compare.
        b - Second of the two EObjects to compare.
        Returns:
        The number of changes to transform one uri to another one.
      • proximity

        public int proximity​(Iterable<String> aPath,
                             Iterable<String> bPath)
        Return a metric result URI similarities. It compares 2 lists of fragments and return an int representing the level of similarity. 0 - they are exactly the same to 10 - they are completely different. "adding a fragment", "removing a fragment".
        Parameters:
        aPath - First of the two list of Strings to compare.
        bPath - Second of the two list of Strings to compare.
        Returns:
        The number of changes to transform one uri to another one.
      • retrieveFragment

        public String retrieveFragment​(EObject input)
        the containing fragment for a given EObject.
        Parameters:
        input - an EObject.
        Returns:
        a String representation of its containing fragment.
      • getUpperBoundDistance

        public int getUpperBoundDistance()
        return the maximum value we can get for this distance.
        Returns:
        the maximum value we can get for this distance.