Class URIDistance
java.lang.Object
org.eclipse.emf.compare.match.eobject.URIDistance
- All Implemented Interfaces:
com.google.common.base.Function<EObject,java.lang.Iterable<java.lang.String>>,java.util.function.Function<EObject,java.lang.Iterable<java.lang.String>>
public class URIDistance extends java.lang.Object implements com.google.common.base.Function<EObject,java.lang.Iterable<java.lang.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
Modifier and Type Method Description java.lang.Iterable<java.lang.String>apply(EObject input)intgetUpperBoundDistance()return the maximum value we can get for this distance.intproximity(java.lang.Iterable<java.lang.String> aPath, java.lang.Iterable<java.lang.String> bPath)Return a metric result URI similarities.intproximity(EObject a, EObject b)Return a metric result URI similarities.java.lang.StringretrieveFragment(EObject input)the containing fragment for a givenEObject.voidsetComparison(Comparison comparison)Set an optional comparison used to retrieve matches already computed.
-
Constructor Details
-
URIDistance
public URIDistance()Create a newURIDistance.
-
-
Method Details
-
setComparison
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
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(java.lang.Iterable<java.lang.String> aPath, java.lang.Iterable<java.lang.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 ofStrings to compare.bPath- Second of the two list ofStrings to compare.- Returns:
- The number of changes to transform one uri to another one.
-
apply
-
retrieveFragment
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.
-