com.alachisoft.ncache.runtime.util
Class TimeSpan

java.lang.Object
  extended by com.alachisoft.ncache.runtime.util.TimeSpan

public class TimeSpan
extends java.lang.Object

TimeSpan class is similiar to .Net System.TimeSpan. Though this class delivers minimal funcitonality that is required to specify "TimeSpan" value. It is used in giving SlidingExpiration value while adding data in NCache.


Constructor Summary
TimeSpan()
          Default Constructor: Initializes a new TimeSpan with zero time span.
TimeSpan(int miliseconds)
          Summary: Initializes a new TimeSpan to the specified number of miliseconds.
TimeSpan(int minutes, int seconds)
          Summary: Initializes a new System.TimeSpan to a specified number of minutes and seconds.
TimeSpan(int hours, int minutes, int seconds)
          Summary: Initializes a new System.TimeSpan to a specified number of hours, minutes and seconds.
TimeSpan(long ticks)
          Summary: Initializes a new System.TimeSpan to a specified number of ticks..
 
Method Summary
 boolean equals(java.lang.Object object)
           
 long getTotalMiliSeconds()
          Summary: This method calculated total miliseconds for this instance of TimeSpan.This includes hours + minutes + seconds + miliseconds computed in miliseconds.
 long getTotalTicks()
          Summary: This method calculates total ticks for this instance of TimeSpan.This includes hours + minutes + seconds + miliseconds computed in ticks.
 int hashCode()
           
 void setHours(int hours)
          Summary: Sets value of hours for this instance of TimeSpan.
 void setMiliSeconds(int miliseconds)
          Summary: Sets value of miliseconds for this instance of TimeSpan.
 void setMinutes(int minutes)
          Summary: Sets value of minutes for this instance of TimeSpan.
 void setSeconds(int seconds)
          Summary: Sets value of seconds for this instance of TimeSpan.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeSpan

public TimeSpan()
Default Constructor: Initializes a new TimeSpan with zero time span.


TimeSpan

public TimeSpan(int miliseconds)
Summary: Initializes a new TimeSpan to the specified number of miliseconds.

Parameters:
miliseconds - A time period expressed in miliseconds units.

TimeSpan

public TimeSpan(int minutes,
                int seconds)
Summary: Initializes a new System.TimeSpan to a specified number of minutes and seconds.

Parameters:
minutes - Number of minutes.
seconds - Number of seconds.

TimeSpan

public TimeSpan(int hours,
                int minutes,
                int seconds)
Summary: Initializes a new System.TimeSpan to a specified number of hours, minutes and seconds.

Parameters:
hours - Number of hours.
minutes - Number of minutes.
seconds - Number of seconds.

TimeSpan

public TimeSpan(long ticks)
Summary: Initializes a new System.TimeSpan to a specified number of ticks..

Parameters:
ticks - A time period expressed in 100-nanosecond units. If ticks value is passed, it overrides other values specified through hours,minutes,seconds,miliseconds
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.
Method Detail

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

getTotalMiliSeconds

public long getTotalMiliSeconds()
Summary: This method calculated total miliseconds for this instance of TimeSpan.This includes hours + minutes + seconds + miliseconds computed in miliseconds. Ticks are not used in computing this value.

Returns:
Total number of miliseconds represented by this instance of TimeSpan. If negative value is calculated, zero is returned.

getTotalTicks

public long getTotalTicks()
Summary: This method calculates total ticks for this instance of TimeSpan.This includes hours + minutes + seconds + miliseconds computed in ticks. In case ticks value is explicitly set, value is not computed instead original ticks value is returned.

Returns:
Total number of ticks represented by this instance of TimeSpan. If negative value is calculated, zero is returned.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

setHours

public void setHours(int hours)
Summary: Sets value of hours for this instance of TimeSpan.

Parameters:
hours - A time period expressed in hours.
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.

setMiliSeconds

public void setMiliSeconds(int miliseconds)
Summary: Sets value of miliseconds for this instance of TimeSpan.

Parameters:
muiliseconds - A time period expressed in miliseconds.
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.

setMinutes

public void setMinutes(int minutes)
Summary: Sets value of minutes for this instance of TimeSpan.

Parameters:
minutes - A time period expressed in minutes.
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.

setSeconds

public void setSeconds(int seconds)
Summary: Sets value of seconds for this instance of TimeSpan.

Parameters:
seconds - A time period expressed in seconds.
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.