messif.objects.util
Class AggregationFunction

java.lang.Object
  extended by messif.objects.util.AggregationFunction
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AggregationFunctionEvaluator, ThresholdFunctionSimpleEvaluator

public abstract class AggregationFunction
extends java.lang.Object
implements java.io.Serializable

The predecessor class of the similarity aggregate functions.

See Also:
Serialized Form

Constructor Summary
AggregationFunction()
           
 
Method Summary
abstract  float compute(float... distances)
          Computes the value of the aggregate distance from the provided sub-distances.
 float getDistance(MetaObject object1, MetaObject object2)
          Computes distance of two meta objects using this combination function.
 float getDistance(MetaObject object1, MetaObject object2, float[] descriptorDistances)
          Computes distance of two meta objects using this combination function.
static java.lang.Class<? extends AggregationFunction> getFactoryClass()
          Returns the class currently set for the factory method valueOf(java.lang.String).
 float getParameterMaximalDistance(int parameterIndex)
          Returns the maximal distance for the specified parameter of the compute(float...) function.
abstract  java.lang.String[] getParameterNames()
          Returns the names of distance parameters (i.e. the descriptor names) for the compute(float...) function.
static void setFactoryClass(java.lang.Class<? extends AggregationFunction> factoryClass)
          Sets the class created by factory method valueOf(java.lang.String).
static AggregationFunction valueOf(java.lang.String string)
          Factory method for creating threshold functions from strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AggregationFunction

public AggregationFunction()
Method Detail

getParameterNames

public abstract java.lang.String[] getParameterNames()
Returns the names of distance parameters (i.e. the descriptor names) for the compute(float...) function.

Returns:
the list of parameter (descriptor) names of the compute(float...) function

getParameterMaximalDistance

public float getParameterMaximalDistance(int parameterIndex)
                                  throws java.lang.IndexOutOfBoundsException
Returns the maximal distance for the specified parameter of the compute(float...) function. This method returns the LocalAbstractObject.MAX_DISTANCE by default.

Parameters:
parameterIndex - the index of a parameter (corresponds to the index of the parameter name as given by getParameterNames())
Returns:
the maximal distances for the parameters of the compute(float...) function
Throws:
java.lang.IndexOutOfBoundsException - if the specified parameter index is not valid

compute

public abstract float compute(float... distances)
Computes the value of the aggregate distance from the provided sub-distances. The distances array items must correspond with the parameter names as returned by getParameterNames().

Parameters:
distances - the distances in respective descriptors
Returns:
the aggregate distance

getDistance

public float getDistance(MetaObject object1,
                         MetaObject object2,
                         float[] descriptorDistances)
Computes distance of two meta objects using this combination function.

Parameters:
descriptorDistances - array that will be filled with distances of the respective sub-distances; i.e. the distance between object1.getObject(parameterName[0]) and object2.getObject(parameterName[0]) will be stored in the first array component, etc.
object1 - the one meta object to compute distance for
object2 - the other meta object to compute distance for
Returns:
the distance between object1 and object1 using this combination function

getDistance

public float getDistance(MetaObject object1,
                         MetaObject object2)
Computes distance of two meta objects using this combination function.

Parameters:
object1 - the one meta object to compute distance for
object2 - the other meta object to compute distance for
Returns:
the distance between object1 and object1 using this combination function

valueOf

public static AggregationFunction valueOf(java.lang.String string)
                                   throws java.lang.NoSuchMethodException,
                                          java.lang.reflect.InvocationTargetException
Factory method for creating threshold functions from strings.

Parameters:
string - the theshold function (using standard expression syntax)
Returns:
a new instance of AggregationFunction
Throws:
java.lang.NoSuchMethodException - if there is no threshold function class set by setFactoryClass(java.lang.Class) yet
java.lang.reflect.InvocationTargetException - if the parsing of the threshold function has thrown an exception

setFactoryClass

public static void setFactoryClass(java.lang.Class<? extends AggregationFunction> factoryClass)
                            throws java.lang.NoSuchMethodException
Sets the class created by factory method valueOf(java.lang.String).

Parameters:
factoryClass - the new class for factory method
Throws:
java.lang.NoSuchMethodException - if the specified class is abstract or lacks a public constructor with one String argument

getFactoryClass

public static java.lang.Class<? extends AggregationFunction> getFactoryClass()
Returns the class currently set for the factory method valueOf(java.lang.String).

Returns:
the class currently set for the factory method valueOf(java.lang.String)