de.lmu.ifi.dbs.elki.distance.distancevalue
Class AbstractDistance<D extends AbstractDistance<D>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.distancevalue.AbstractDistance<D>
Type Parameters:
D - the (final) type of Distance used
All Implemented Interfaces:
Distance<D>, Externalizable, Serializable, Comparable<D>
Direct Known Subclasses:
CorrelationDistance, NumberDistance, SubspaceDistance

public abstract class AbstractDistance<D extends AbstractDistance<D>>
extends Object
implements Distance<D>

An abstract distance implements equals conveniently for any extending class. At the same time any extending class is to implement hashCode properly. See DistanceUtil for related utility functions such as min, max.

See Also:
DistanceUtil, Serialized Form

Field Summary
static Pattern DOUBLE_PATTERN
          Pattern for parsing and validating double values
static String INFINITY_PATTERN
          Indicates an infinity pattern.
static Pattern INTEGER_PATTERN
          Pattern for parsing and validating integer values
 
Constructor Summary
AbstractDistance()
           
 
Method Summary
 boolean equals(Object o)
          Returns true if this == o has the value true or o is not null and o is of the same class as this instance and this.compareTo(o) is 0, false otherwise.
abstract  Pattern getPattern()
          Get the pattern accepted by this distance
abstract  int hashCode()
          Any extending class should implement a proper hashCode method.
 boolean isInfiniteDistance()
          Returns true, if the distance is an infinite distance, false otherwise.
 boolean isNullDistance()
          Returns true, if the distance is a null distance, false otherwise.
 boolean isUndefinedDistance()
          Returns true, if the distance is an undefined distance, false otherwise.
 String requiredInputPattern()
          Returns a String as description of the required input format.
 boolean testInputPattern(String value)
          Test a string value against the input pattern.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.distancevalue.Distance
externalizableSize, infiniteDistance, minus, nullDistance, parseString, plus, toString, undefinedDistance
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Field Detail

INFINITY_PATTERN

public static final String INFINITY_PATTERN
Indicates an infinity pattern.

See Also:
Constant Field Values

DOUBLE_PATTERN

public static final Pattern DOUBLE_PATTERN
Pattern for parsing and validating double values


INTEGER_PATTERN

public static final Pattern INTEGER_PATTERN
Pattern for parsing and validating integer values

Constructor Detail

AbstractDistance

public AbstractDistance()
Method Detail

hashCode

public abstract int hashCode()
Any extending class should implement a proper hashCode method.

Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Returns true if this == o has the value true or o is not null and o is of the same class as this instance and this.compareTo(o) is 0, false otherwise.

Overrides:
equals in class Object

getPattern

public abstract Pattern getPattern()
Get the pattern accepted by this distance

Returns:
Pattern

requiredInputPattern

public final String requiredInputPattern()
Description copied from interface: Distance
Returns a String as description of the required input format.

Specified by:
requiredInputPattern in interface Distance<D extends AbstractDistance<D>>
Returns:
a String as description of the required input format

testInputPattern

public final boolean testInputPattern(String value)
Test a string value against the input pattern.

Parameters:
value - String value to test
Returns:
Match result

isInfiniteDistance

public boolean isInfiniteDistance()
Description copied from interface: Distance
Returns true, if the distance is an infinite distance, false otherwise.

Specified by:
isInfiniteDistance in interface Distance<D extends AbstractDistance<D>>
Returns:
true, if the distance is an infinite distance, false otherwise

isNullDistance

public boolean isNullDistance()
Description copied from interface: Distance
Returns true, if the distance is a null distance, false otherwise.

Specified by:
isNullDistance in interface Distance<D extends AbstractDistance<D>>
Returns:
true, if the distance is a null distance, false otherwise

isUndefinedDistance

public boolean isUndefinedDistance()
Description copied from interface: Distance
Returns true, if the distance is an undefined distance, false otherwise.

Specified by:
isUndefinedDistance in interface Distance<D extends AbstractDistance<D>>
Returns:
true, if the distance is an undefined distance, false otherwise

Release 0.4.0 (2011-09-20_1324)