public class DurationUnit
extends java.lang.Object
Duration
and provides tool
methods to extract the count/value for such parts from given a
Duration
.Modifier and Type | Field and Description |
---|---|
static DurationUnit |
defaultUnit |
static DurationUnit[] |
units |
Constructor and Description |
---|
DurationUnit(java.lang.String _l10nKey)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.Integer |
getCount(javax.xml.datatype.Duration _dur)
Assumes the given
Duration contains only one "unit part" with a
count ! |
static java.lang.Integer |
getCount(int _val,
java.lang.Integer _c,
java.lang.String _tip)
Helper method for the other
getCount() method. |
static javax.xml.datatype.DatatypeFactory |
getDatatypeFactory()
Internal helper method to get a static
DatatypeFactory instance;
creates one if it does not already exist. |
javax.xml.datatype.Duration |
getDuration(int _c)
Creates and returns a new
Duration with the count/value for the
time unit/part which corresponds to this DurationUnit set to the
given value. |
static DurationUnit |
getInstance(javax.xml.datatype.Duration _dur)
Assumes the given
Duration contains only one "unit part" with a
count ! |
static DurationUnit |
getInstance(javax.xml.datatype.Duration _dur,
DurationUnit _defaultUnit) |
static DurationUnit |
getInstance(int _val,
int _idx,
DurationUnit _du)
Helper method for the other
getInstance() method. |
java.lang.String |
getL10nKey() |
void |
setL10nKey(java.lang.String $2) |
java.lang.String |
toString() |
public static final DurationUnit[] units
public static final DurationUnit defaultUnit
public static javax.xml.datatype.DatatypeFactory getDatatypeFactory()
DatatypeFactory
instance;
creates one if it does not already exist.DatatypeFactory
instancepublic java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.Integer getCount(javax.xml.datatype.Duration _dur)
Duration
contains only one "unit part" with a
count != 0 and extracts and returns that._dur
- the Duration
to extract the one count/value from{@code
- IRuntimeException} if more than one "unit part" has a
count/value != 0 (since this class can't handle durations with values
for more than exactly one unit; like "1Y4M" for example)public static java.lang.Integer getCount(int _val, java.lang.Integer _c, java.lang.String _tip)
getCount()
method._val
- the value of the current field_c
- the value of count which has been "extracted" so far_tip
- a textual description of the "field" (Years, Months, etc.)
that is currently handled; only used in the exception message in case
of an error_c
if _val == 0
; the Integer
value of
_val
if _c
is still 0{@code
- IRuntimeException} if _c
as well as _val
are != 0 (since this class can't handle durations with values for more
than exactly one unit; like "1Y4M" for example)public static DurationUnit getInstance(javax.xml.datatype.Duration _dur)
Duration
contains only one "unit part" with a
count != 0 and determines and returns a matching DurationUnit
for
that._dur
- the Duration
to determine a matching unit for_defaultUnit
- the default unit to return if no useful unit could
be determined (_dur == null
or all counts/values == 0); may be
null and will then default to "days"DurationUnit
{@code
- IRuntimeException} if more than one "unit part" has a
count/value != 0 (since this class can't handle durations with values
for more than exactly one unit; like "1Y4M" for example)public static DurationUnit getInstance(javax.xml.datatype.Duration _dur, DurationUnit _defaultUnit)
public static DurationUnit getInstance(int _val, int _idx, DurationUnit _du)
getInstance()
method.public javax.xml.datatype.Duration getDuration(int _c)
Duration
with the count/value for the
time unit/part which corresponds to this DurationUnit
set to the
given value._c
- the value to set the corresponding time unit/part toDuration
with the count/value for the time
unit/part which corresponds to this DurationUnit
set to the
given valuepublic java.lang.String getL10nKey()
public void setL10nKey(java.lang.String $2)
Copyright © 2000-2024 OAshi S.à r.l. All Rights Reserved.