示例#1
0
 /**
  * Tests to see if the specified metric name is known for the given attribute data type.
  *
  * @param type the attribute type
  * @param s the name of the distance metric to look for
  * @return true if <code>s</code> is the name of a known metric for the type
  * @throws UnknownDistanceException if the type is unknown. XXX: shouldn't this be the other way
  *     around?
  */
 public static final boolean isDistanceFor(Measurable type, String s)
     throws UnknownDistanceException {
   Map<String, Distance> values = distanceMap.get(type.getType());
   if (values != null) {
     return values.containsKey(s.toLowerCase());
   } else {
     throw new UnknownDistanceException(type, s);
   }
 }
示例#2
0
 /**
  * Gets the distance functor for the given type.
  *
  * @param type the attribute data type
  * @param metric the metric name
  * @return the metric
  * @throws UnknownDistanceException if the metric isn't found
  */
 public static final Distance getDistanceFunctor(Measurable type, String metric)
     throws UnknownDistanceException {
   return Distances.getDistanceFunctor(type.getType(), metric);
 }