com.plumtree.portalpages.common.helpers
Class PTDuration

java.lang.Object
  extended by com.plumtree.portalpages.common.helpers.PTDuration

public class PTDuration
extends java.lang.Object

Author:
adolfoc This is a simple class used to help translate between Durations used by the PTDuractionCombo construct and Milliseconds. Although this class uses a long for the internal representation of the duration, it is possible that certain methods will incorrectly handle durations that are more the int milliseconds long (roughly 22 days). This class does not check for overruns.

Field Summary
protected  long m_lMilliseconds
           
protected  int m_nMASK_PossibleUnits
           
 
Constructor Summary
PTDuration(long lMilliseconds, int nMASKPossibleUnits)
          Constructor.
PTDuration(long lDuration, int nDurationUnits, int nMASKPossibleUnits)
          Constructor.
 
Method Summary
 int GetBestDurationUnit()
          Returns the best duration unit possible from the MASK of available durations.
 int GetBestDurationUnit(int nDefaultUnits)
          Returns the best duration unit possible from the MASK of available durations.
 int GetDurationInBestUnits()
          Gets the duration in the longest supported units of time.
 int GetDurationInBestUnits(int nDefaultUnits)
          Gets the duration in the longest supported units of time or in nDefaultUnits if the duration does not equally divide into the supported units.
 int GetDurationInUnits(int nDurationUnits)
          Gets the duration in DurationUnits.
 int GetMilliseconds()
          Returns the duration in milliseconds.
static int GetShortestSupportedUnit(int nMASKSupportedUnits)
          Returns the shortest time unit described in nMASK
 int GetSupportedUnitsMask()
          Returns the mask of supported units.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_nMASK_PossibleUnits

protected int m_nMASK_PossibleUnits

m_lMilliseconds

protected long m_lMilliseconds
Constructor Detail

PTDuration

public PTDuration(long lDuration,
                  int nDurationUnits,
                  int nMASKPossibleUnits)
Constructor. Takes in a Duration and Duration Unit. The unit must be one of the UNITS defined in PTDurationCombo.

Parameters:
lDuration -
nDurationUnits -

PTDuration

public PTDuration(long lMilliseconds,
                  int nMASKPossibleUnits)
Constructor. Takes in the milliseconds.

Parameters:
lMilliseconds -
Method Detail

GetBestDurationUnit

public int GetBestDurationUnit(int nDefaultUnits)
Returns the best duration unit possible from the MASK of available durations. If the current duration is zero or does not match any available durations, this will return nDefaultDuration units.

Parameters:
nMASKSupportedUnits -
nDefaultUnits -
Returns:
int

GetBestDurationUnit

public int GetBestDurationUnit()
Returns the best duration unit possible from the MASK of available durations. If the current duration is zero or does not match any available durations, this will return the shortest supported Unit.

Parameters:
nMASKSupportedUnits -
nDefaultUnits -
Returns:
int

GetShortestSupportedUnit

public static int GetShortestSupportedUnit(int nMASKSupportedUnits)
Returns the shortest time unit described in nMASK

Parameters:
nDurationUnits -
Returns:
int

GetDurationInBestUnits

public int GetDurationInBestUnits()
Gets the duration in the longest supported units of time. (You can get this duration by calling GetBestDurationUnit). If the duration does not evenly divide into the supported units, this will return the duration in the shortest supported units. Notice that this returns an integer.

Parameters:
nDurationUnits -
Returns:
int

GetDurationInBestUnits

public int GetDurationInBestUnits(int nDefaultUnits)
Gets the duration in the longest supported units of time or in nDefaultUnits if the duration does not equally divide into the supported units. Notice that this returns an integer.

Parameters:
nDurationUnits -
Returns:
int

GetDurationInUnits

public int GetDurationInUnits(int nDurationUnits)
Gets the duration in DurationUnits. Returns the current duration in the units specified. If the units do not divide equally, the duration is integer divided (read floored) to the specified unit. Notice that this returns an integer.

Parameters:
nDurationUnits -
Returns:
int

GetMilliseconds

public int GetMilliseconds()
Returns the duration in milliseconds. Notice that this returns an integer.

Returns:
int

GetSupportedUnitsMask

public int GetSupportedUnitsMask()
Returns the mask of supported units.

Returns:
int



Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.