ca.uhn.cache.impl
Class DateParam

java.lang.Object
  extended byca.uhn.cache.impl.CommonsLangObject
      extended byca.uhn.cache.impl.AbstractQueryParam
          extended byca.uhn.cache.impl.DateParam
All Implemented Interfaces:
java.lang.Comparable, IPointQueryParam, IQueryParam, java.io.Serializable

public class DateParam
extends AbstractQueryParam
implements IPointQueryParam

A IPointQueryParam that selects data items with values along a certain dimension exactly equal to a certain Date value.

Version:
$Revision: 1.1 $ updated on $Date: 2005/01/24 22:52:33 $ by $Author: bryan_tripp $
Author:
Bryan Tripp, Alexei Guevara
See Also:
Serialized Form

Constructor Summary
DateParam(IDimension theDimension, java.util.Date theValue)
          Creates a new DateParam.
 
Method Summary
protected static void checkCompatibility(IQueryParam theParam, IDimension theDimension)
           
 float getDistance(IQueryParam theParam, IQueryParam theSaturationPoint)
           
protected static float getDistance(long theDifference, long theSaturation)
           
 java.util.Date getValue()
           
 boolean intersects(IQueryParam theParam)
          
 IQueryParam merge(IQueryParam theParam)
           
 
Methods inherited from class ca.uhn.cache.impl.AbstractQueryParam
compareTo, compatibleWith, getDimension, getPointParamClass
 
Methods inherited from class ca.uhn.cache.impl.CommonsLangObject
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ca.uhn.cache.IQueryParam
getDimension
 

Constructor Detail

DateParam

public DateParam(IDimension theDimension,
                 java.util.Date theValue)
Creates a new DateParam.

Parameters:
theDimension - The dimension where this parameter is difined.
theValue - The value of this parameter.
Method Detail

intersects

public boolean intersects(IQueryParam theParam)

Specified by:
intersects in interface IQueryParam
Overrides:
intersects in class AbstractQueryParam

getValue

public java.util.Date getValue()
Returns:
Returns the value.

getDistance

public float getDistance(IQueryParam theParam,
                         IQueryParam theSaturationPoint)
Specified by:
getDistance in interface IQueryParam
Parameters:
theParam - another IQueryParam
theSaturationPoint - distances are normalized (see below) to between zero and 1. This arg is an IQueryParam that indicates what corresponds to a distance of 1 from the origin. For example consider a date-related dimension in which dates over the last week are relevant. The origin would be now, and the saturation point would be one week ago. This parameter can be ignored, and is allowed to be null, for dimensions that are not ordered.
Returns:
the distance between this IQueryParam and the other. The distance is a number between 0 and 1. It is zero if the two IQueryParam intersect, and 1 if they are at opposite ends of an ordered dimension. For dimensions that correspond to some natural ordering, the distance should increase monotonically with the difference in the ordering property (e.g. with an alphabetical dimension, there should be a greater distance between the A chunk and the C chunk than between A and B chunks). For non-ordered dimensions, the distance between any two non-intersecting IQueryParam may be the same. X.getDistance(Y) == Y.getDistance(X).
See Also:
IQueryParam.getDistance(ca.uhn.cache.IQueryParam, ca.uhn.cache.IQueryParam)

getDistance

protected static float getDistance(long theDifference,
                                   long theSaturation)
Parameters:
theDifference - a difference (ms) between two times
theSaturation - the difference that defines the distance 1
Returns:
a monotonically increasing function of the difference, which is near-linear below the saturation, and approaches 1 for higher values

merge

public IQueryParam merge(IQueryParam theParam)
Specified by:
merge in interface IQueryParam
Parameters:
theParam - another IQueryParam
Returns:
the result of merging this IQueryParam with the other. This is not necessarily a union. If the dimension has an ordering then the result must encompass all points in both IQueryParam as well as points in between.
See Also:
IQueryParam.merge(ca.uhn.cache.IQueryParam)

checkCompatibility

protected static void checkCompatibility(IQueryParam theParam,
                                         IDimension theDimension)
Parameters:
theParam - another IQueryParam with which to check compatibility for merge() and distance()
theDimension - the dimension the param is expected to belong to
Throws:
java.lang.IllegalArgumentException - if the given param is not of the given dimension or is not either a DateParam or DateRangeParam


Copyright © 2004-2005 University Health Network. All Rights Reserved.