|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectumontreal.iro.lecuyer.xmlconfig.AbstractParam
umontreal.iro.lecuyer.xmlconfig.TimeParam
public class TimeParam
Represents a time duration or a rate parameter expressed in a time unit. This
parameter object can be constructed from a string, or a value with a
TimeUnit
instance representing its unit. The get(umontreal.iro.lecuyer.util.TimeUnit)
method can
be used to obtain the value of the parameter, converted into a user-specified
time unit. Usually, this parameter is used to represent a duration. Rates are
supported for distribution scale parameters.
The time parameter can also be used as an XML attribute type or as a nested
element when using ParamReader
to parse an XML document into a
parameter object.
Constructor Summary | |
---|---|
TimeParam()
Constructs a time parameter with value 0. |
|
TimeParam(double value)
Equivalent to TimeParam
(value, false, null). |
|
TimeParam(double value,
boolean rate,
TimeUnit unit)
Constructs a new time parameter with encoded value value, rate indicator rate, and time unit unit. |
|
TimeParam(double value,
TimeUnit unit)
Equivalent to TimeParam
(value, false, unit). |
|
TimeParam(String str)
Constructs a time parameter from the string str. |
Method Summary | |
---|---|
TimeParam |
clone()
|
boolean |
equals(Object other)
|
String |
formatHMS()
|
String |
formatSI()
|
static String |
formatSI(double time)
|
double |
get(boolean dstRate,
TimeUnit dstUnit)
Returns the rate or time extracted from this parameter, expressed in dstUnit. |
double |
get(TimeUnit dstUnit)
Equivalent to get (false,
dstUnit). |
boolean |
getRateIndicator()
Returns the rate indicator of this time parameter. |
TimeUnit |
getTimeUnit()
Returns the time unit of this parameter. |
double |
getValue()
Returns the value of this time parameter, without conversion. |
boolean |
isAttributeSupported(String a)
For internal use only. |
void |
nestedText(String str)
For internal use only. |
void |
setRateIndicator(boolean rate)
Sets the rate indicator of this time parameter to rate. |
void |
setTimeUnit(TimeUnit unit)
Sets the time unit of this parameter to unit. |
void |
setValue(double value)
Sets the value of this time parameter to value. |
String |
toString()
Formats this time parameter as a string. |
static TimeParam |
valueOf(String str)
Constructs a new time parameter from the string str, using TimeParam(String) and returns the constructed instance. |
Methods inherited from class umontreal.iro.lecuyer.xmlconfig.AbstractParam |
---|
check, createDocument, getId, getXref, setId, setXref, write, write, write, write, write, write, write, write |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TimeParam()
public TimeParam(double value)
TimeParam
(value, false, null).
value
- the encoded value.
IllegalArgumentException
- if value is negative.public TimeParam(double value, TimeUnit unit)
TimeParam
(value, false, unit).
value
- the encoded value.unit
- the time unit in which the value is assumed to be expressed.
IllegalArgumentException
- if value is negative.public TimeParam(double value, boolean rate, TimeUnit unit)
get(umontreal.iro.lecuyer.util.TimeUnit)
method performs no time conversion.
value
- the encoded value.rate
- the rate indicator.unit
- the time unit in which the value is assumed to be expressed.
IllegalArgumentException
- if value is negative.public TimeParam(String str)
get(umontreal.iro.lecuyer.util.TimeUnit)
. The time unit must be the short name of any
instance of TimeUnit
. For example, 12s represents 12
seconds and 12/m represents a rate of 12 units per minute.
str
- the string representation of the time parameter.
IllegalArgumentException
- if the string is invalid.Method Detail |
---|
public double getValue()
public void setValue(double value)
value
- the new time parameter's value.
IllegalArgumentException
- if value is negative or NaN.public boolean getRateIndicator()
public void setRateIndicator(boolean rate)
rate
- the new time parameter's rate indicator.public TimeUnit getTimeUnit()
public void setTimeUnit(TimeUnit unit)
unit
- the new time unit of this parameter.public double get(TimeUnit dstUnit)
get
(false,
dstUnit).
dstUnit
- the destination time unit.
public double get(boolean dstRate, TimeUnit dstUnit)
If getTimeUnit()
returns null, the method returns
getValue()
unchanged. Otherwise, if getRateIndicator()
returns true, 1/getValue()
is used instead of
getValue()
. The method uses TimeUnit.convert(double, umontreal.iro.lecuyer.util.TimeUnit, umontreal.iro.lecuyer.util.TimeUnit)
to convert
the value from source unit getTimeUnit()
to destination unit
dstUnit. If dstRate is true, one over the
converted value is returned. Otherwise, the converted value is returned.
dstRate
- determines if the returned value must be a rate.dstUnit
- the destination time unit.
public static TimeParam valueOf(String str)
TimeParam(String)
and returns the constructed instance.
str
- the string representation of the time parameter.
IllegalArgumentException
- if the string is invalid.public boolean equals(Object other)
equals
in class Object
public String toString()
TimeParam(String)
or valueOf(java.lang.String)
to construct a time
parameter.
toString
in class AbstractParam
public String formatHMS()
public String formatSI()
public static String formatSI(double time)
public boolean isAttributeSupported(String a)
public void nestedText(String str)
public TimeParam clone()
clone
in class Object
|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |