Class URIDistance
- java.lang.Object
-
- org.eclipse.emf.compare.match.eobject.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 Summary
Constructors Constructor Description URIDistance()
Create a newURIDistance
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterable<String>
apply(EObject input)
int
getUpperBoundDistance()
return the maximum value we can get for this distance.int
proximity(Iterable<String> aPath, Iterable<String> bPath)
Return a metric result URI similarities.int
proximity(EObject a, EObject b)
Return a metric result URI similarities.String
retrieveFragment(EObject input)
the containing fragment for a givenEObject
.void
setComparison(Comparison comparison)
Set an optional comparison used to retrieve matches already computed.
-
-
-
Constructor Detail
-
URIDistance
public URIDistance()
Create a newURIDistance
.
-
-
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".
-
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".
-
retrieveFragment
public String retrieveFragment(EObject input)
the containing fragment for a givenEObject
.- 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.
-
-