org.openmrs.logic
Class Duration

java.lang.Object
  extended by org.openmrs.logic.Duration
All Implemented Interfaces:
Operand

public class Duration
extends java.lang.Object
implements Operand

Represents a duration of time — e.g., one year, two weeks, or 18 months. Used within criteria. Use the Duration duration = Duration.days(5.0); to get a duration object

See Also:
LogicCriteria

Nested Class Summary
static class Duration.Units
           
 
Method Summary
static Duration days(java.lang.Double duration)
          Returns a duration for the given number of days
static Duration days(int duration)
          Returns a duration for the given number of days
 java.lang.Double getDuration()
           
 java.lang.Double getDurationInDays()
          Returns the equivalent duration in days
 long getDurationInMillis()
          Returns the equivalent duration in milliseconds
 Duration.Units getUnits()
           
static Duration hours(java.lang.Double duration)
          Returns a duration for the given number of hours
static Duration hours(int duration)
          Returns a duration for the given number of hours
static Duration minutes(java.lang.Double duration)
          Returns a duration for the given number of minutes
static Duration minutes(int duration)
          Returns a duration for the given number of minutes
static Duration months(java.lang.Double duration)
          Returns a duration for the given number of months
static Duration months(int duration)
          Returns a duration for the given number of months
static Duration seconds(java.lang.Double duration)
          Returns a duration for the given number of seconds
static Duration seconds(int duration)
          Returns a duration for the given number of seconds
 boolean supports(ComparisonOperator operator)
          Sanity check for this Operand vs a given operator.
static Duration weeks(java.lang.Double duration)
          Returns a duration for the given number of weeks
static Duration weeks(int duration)
          Returns a duration for the given number of weeks
static Duration years(java.lang.Double duration)
          Returns a duration for the given number of years
static Duration years(int duration)
          Returns a duration for the given number of years
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDuration

public java.lang.Double getDuration()

getUnits

public Duration.Units getUnits()

getDurationInDays

public java.lang.Double getDurationInDays()
Returns the equivalent duration in days

Returns:
the equivalent duration in days

getDurationInMillis

public long getDurationInMillis()
Returns the equivalent duration in milliseconds

Returns:
the equivalent duration in milliseconds

seconds

public static Duration seconds(java.lang.Double duration)
Returns a duration for the given number of seconds

Parameters:
duration - number of seconds for duration
Returns:
Duration object for given number of seconds

seconds

public static Duration seconds(int duration)
Returns a duration for the given number of seconds

Parameters:
duration - number of seconds for duration
Returns:
Duration object for given number of seconds

minutes

public static Duration minutes(java.lang.Double duration)
Returns a duration for the given number of minutes

Parameters:
duration - number of minutes for duration
Returns:
Duration object for given number of minutes

minutes

public static Duration minutes(int duration)
Returns a duration for the given number of minutes

Parameters:
duration - number of minutes for duration
Returns:
Duration object for given number of minutes

hours

public static Duration hours(java.lang.Double duration)
Returns a duration for the given number of hours

Parameters:
duration - number of hours for duration
Returns:
Duration object for given number of hours

hours

public static Duration hours(int duration)
Returns a duration for the given number of hours

Parameters:
duration - number of hours for duration
Returns:
Duration object for given number of hours

days

public static Duration days(java.lang.Double duration)
Returns a duration for the given number of days

Parameters:
duration - number of days for duration
Returns:
Duration object with specified number of days

days

public static Duration days(int duration)
Returns a duration for the given number of days

Parameters:
duration - number of days for duration
Returns:
Duration object with specified number of days

weeks

public static Duration weeks(java.lang.Double duration)
Returns a duration for the given number of weeks

Parameters:
duration - number of weeks for duration
Returns:
Duration object with specified number of weeks

weeks

public static Duration weeks(int duration)
Returns a duration for the given number of weeks

Parameters:
duration - number of weeks for duration
Returns:
Duration object with specified number of weeks

months

public static Duration months(java.lang.Double duration)
Returns a duration for the given number of months

Parameters:
duration - number of months for duration
Returns:
Duration object with specified number of months

months

public static Duration months(int duration)
Returns a duration for the given number of months

Parameters:
duration - number of months for duration
Returns:
Duration object with specified number of months

years

public static Duration years(java.lang.Double duration)
Returns a duration for the given number of years

Parameters:
duration - number of years for duration
Returns:
Duration object with specified number of years

years

public static Duration years(int duration)
Returns a duration for the given number of years

Parameters:
duration - number of years for duration
Returns:
Duration object with specified number of years

supports

public boolean supports(ComparisonOperator operator)
Description copied from interface: Operand
Sanity check for this Operand vs a given operator. Would return true for OperandDate.supports("BEFORE") but OperandConcept.supports("BEFORE") returns false

Specified by:
supports in interface Operand
Parameters:
operator - The operator to test against this Operand
Returns:
true/false about whether this Operand supports this ComparisonOperator
See Also:
Operand.supports(org.openmrs.logic.op.ComparisonOperator)

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change