org.infai.emo.matcher.util
Class Matching

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Tuple,java.lang.Double>
          extended by org.infai.emo.matcher.util.Matching
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<Tuple,java.lang.Double>

public class Matching
extends java.util.Hashtable<Tuple,java.lang.Double>

Class saves a matching between two models by extending the Hashtable class.
the keys of that hash are tuples and the values for that keys are the matching-values between the elements of the tuples saved as double values in the range from 0 to 1.0.

Version:
1.1.0
Author:
Stanley Hillner
See Also:
Tuple, Serialized Form

Field Summary
private  Comparator comparator
          The comparator that was used to build up the actual matching.
private  Mapping map
          The mapping between both models.
 
Constructor Summary
Matching()
          Constructor for an empty matching without a mapping or comparator.
Matching(Mapping map, ElementComparator comparator)
          Creates a new Matching with the specified mapping.
Matching(StructureComparator comparator)
          New Matching with the specified comparator of type StructureComparator.
 
Method Summary
 Matching addValues(Matching m)
          Add all the matching-values of m to the matching on which this method was called.
 Matching copy()
          Creates a copy of the on which the method was called.
 Matching divValues(double factor)
          Divides all the matching-values by the given factor.
 Comparator getComparator()
           
 Matching getInvertedMacthing()
          Inverts the matching by inverting all the tuples of the underlying mapping of both models.
 Mapping getMap()
           
 Matching getMatchingByFirstElement(java.lang.Object o)
          Get a new matching that only contains entries theirs first elements (of the tuples) equal o.
 Matching getMatchingBySecondElement(java.lang.Object o)
          Get a new matching that only contains entries theirs second elements (of the tuples) equal o.
 double getValue(Tuple tuple)
          This method returns the matching value for a tuple.
 boolean hasMultipleMaximumValues()
          Checks whether this matching has more than one tuples that are matched with the maximum matching entry.
 java.util.Map.Entry<Tuple,java.lang.Double> maximumMatchingEntry()
          Searches for the matching entry with the maximum matching value.
 java.util.Vector<java.util.Map.Entry<Tuple,java.lang.Double>> maximumMatchingEntryList()
          Searches for the matching entries with the maximum matching value.
 Matching multValues(double factor)
          Multiplies all the matching-values with the given factor.
 Matching normalize(double referenceValue)
          Normalize the matching values to the reference-value.
private  void setMap(Mapping map)
          Set a new mapping to this matching.
 java.lang.String toString()
          
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

comparator

private Comparator comparator
The comparator that was used to build up the actual matching.

See Also:
Comparator

map

private Mapping map
The mapping between both models.
This mapping contains the tuples which have to be matched.

See Also:
Mapping, Tuple
Constructor Detail

Matching

public Matching()
Constructor for an empty matching without a mapping or comparator.


Matching

public Matching(Mapping map,
                ElementComparator comparator)
Creates a new Matching with the specified mapping.
The matching compares the elements of each tuple of the mapping using the given comparator.

Parameters:
map - the mapping for the matching which includes the tuples to compare.
comparator - the comparator of type ElementComparator for comparing elements of the models.
See Also:
map, comparator

Matching

public Matching(StructureComparator comparator)
New Matching with the specified comparator of type StructureComparator.
The mapping is used from the previous matching which is included in the comparator.
The matching compares the elements of each tuple of the mapping using the given comparator.

Parameters:
comparator - the comparator of that matching.
See Also:
Comparator
Method Detail

copy

public Matching copy()
Creates a copy of the on which the method was called.

Returns:
the copied matching.

getValue

public double getValue(Tuple tuple)
This method returns the matching value for a tuple.

Parameters:
tuple - the tuple that describes the key of the HashTable in which the matching is saved.
Returns:
a value between 0 and 1.0.

addValues

public Matching addValues(Matching m)
Add all the matching-values of m to the matching on which this method was called.

Parameters:
m - the matching of which the values shall be added to the actual one.
Returns:
a matching thats values are the addition of both previous matchings.

multValues

public Matching multValues(double factor)
Multiplies all the matching-values with the given factor.

Parameters:
factor - the factor to multiply with.
Returns:
the matching with the multiplied values.

divValues

public Matching divValues(double factor)
Divides all the matching-values by the given factor.

Parameters:
factor - the factor to divide with.
Factor must be different from 0!
Returns:
the matching with the divided values.

normalize

public Matching normalize(double referenceValue)
Normalize the matching values to the reference-value.
Example: If reference-value = 3.0 then the maximum entry maxvalue will become the reference-value and all the other matching-entries will be updated to (value * 3.0)/maxvalue.

Returns:
the normalized matching with the maximum value = reference-value.

maximumMatchingEntry

public java.util.Map.Entry<Tuple,java.lang.Double> maximumMatchingEntry()
Searches for the matching entry with the maximum matching value.
If there are found more than one entries that have the maximum value, only one will be returned (the first one).

Returns:
the first entry of the matching that has the maximum matching value.
See Also:
Map.Entry

maximumMatchingEntryList

public java.util.Vector<java.util.Map.Entry<Tuple,java.lang.Double>> maximumMatchingEntryList()
Searches for the matching entries with the maximum matching value.

Returns:
a Vector that contains all entries that have the same maximum matching-entry.
See Also:
Vector, Map.Entry

hasMultipleMaximumValues

public boolean hasMultipleMaximumValues()
Checks whether this matching has more than one tuples that are matched with the maximum matching entry.

Returns:
true if there are more than one tuples with the same maximum matching entry.

getMatchingByFirstElement

public Matching getMatchingByFirstElement(java.lang.Object o)
Get a new matching that only contains entries theirs first elements (of the tuples) equal o.

Parameters:
o - the element that shall be the first element of the matching entries.
Returns:
the new matching that contains all matches to the searched element.

getMatchingBySecondElement

public Matching getMatchingBySecondElement(java.lang.Object o)
Get a new matching that only contains entries theirs second elements (of the tuples) equal o.

Parameters:
o - the element that shall be the second element of the matching entries.
Returns:
the new matching that contains all matches to the searched element.

getInvertedMacthing

public Matching getInvertedMacthing()
Inverts the matching by inverting all the tuples of the underlying mapping of both models.

Returns:
an inverted matching of the actual matching on which this method was called.

toString

public java.lang.String toString()

Overrides:
toString in class java.util.Hashtable<Tuple,java.lang.Double>

getComparator

public Comparator getComparator()
Returns:
the actual Comparator of this Matching.
See Also:
comparator

getMap

public Mapping getMap()
Returns:
the mapping of the matching.
See Also:
map

setMap

private void setMap(Mapping map)
Set a new mapping to this matching.

Parameters:
map - the new map.
See Also:
map