Package com.oss.asn1
Class ISO8601Duration
java.lang.Object
com.oss.asn1.AbstractData
com.oss.asn1.AbstractISO8601Time
com.oss.asn1.ISO8601Duration
- All Implemented Interfaces:
com.oss.asn1.Comparable
,ISO8601TimeInterface
,Serializable
,Cloneable
The ISO8601Duration class represents the ASN.1 DURATION type.
- Since:
- ASN.1/Java 4.0 Beta A
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Class Fractional_part represents a duration's fractional part. -
Field Summary
Fields inherited from class com.oss.asn1.AbstractData
EQUALS, GREATER_THAN, LESS_THAN
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor.ISO8601Duration
(int years, int months, int days, int hours, int minutes, int seconds, ISO8601Duration.Fractional_part fractional_part) Constructs duration value from years, months, days, hour, minutes, seconds and fractional part components.ISO8601Duration
(int weeks, ISO8601Duration.Fractional_part fractional_part) Constructs duration value weeks and fractional part components.ISO8601Duration
(String value) Constructs duration value from a string. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all the fields so they are set to UNDEFINED value.clone()
Clone 'this' object.final boolean
equalTo
(ISO8601Duration that) Compare 'this' object to another ISO8601Duration object to see if their contents are the same.int
get
(int field) Get a field's value.final int
getDays()
Get the days component of 'this' object.Get the fractional part component of 'this' object.final int
getHours()
Get the hours component of 'this' object.final int
Get the minutes component of 'this' object.final int
Get the months component of 'this' object.final int
Get the seconds component of 'this' object.final int
getWeeks()
Get the weeks component of 'this' object.final int
getYears()
Get the years component of 'this' object.void
set
(int field, int value) Set a field's value.final void
setDays
(int days) Set the days component of 'this' object.final void
setFractional_part
(ISO8601Duration.Fractional_part fractional_part) Set the fractional part component of 'this' object.final void
setHours
(int hours) Set the hours component of 'this' object.final void
setMinutes
(int minutes) Set the minutes component of 'this' object.final void
setMonths
(int months) Set the months component of 'this' object.final void
setSeconds
(int seconds) Set the seconds component of 'this' object.void
Set an instance of this class from a String containing value notation of the DURATION.final void
setWeeks
(int weeks) Set the weeks component of 'this' object.final void
setYears
(int years) Set the years component of 'this' object.Methods inherited from class com.oss.asn1.AbstractISO8601Time
compareTo, compareTo, toDate, toDate
Methods inherited from class com.oss.asn1.AbstractData
delete, equals, hashCode, isEncodable, isPDU, isValid, toString, toString
-
Constructor Details
-
ISO8601Duration
public ISO8601Duration()The default constructor. -
ISO8601Duration
Constructs duration value from a string. String should be in the following basic format, "PnnYnnMnnDTnnHnnMnnS" or "PnnW" wherenn
is a one or more digit integer, which specifies an amount of years, months, weeks, days, hours, minutes or seconds depending on a designator which follows the "nn": Y,M,W,D,H,M or S. For reduced accuracy or decimal fraction representation any of the lowest order components may be omitted, decimal point with fractional value can be included into the lowest order component and zero valued components may be omitted. For example: "PT1.5H" represents one and a half an hour duration.- Parameters:
value
- a string containing time of day value.- Throws:
BadTimeFormatException
- ifvalue
has invalid format.
-
ISO8601Duration
public ISO8601Duration(int years, int months, int days, int hours, int minutes, int seconds, ISO8601Duration.Fractional_part fractional_part) Constructs duration value from years, months, days, hour, minutes, seconds and fractional part components.- Parameters:
years
- years valuemonths
- months valuedays
- days valuehours
- hours valueminutes
- minutes valueseconds
- seconds valuefractional_part
- fractional part value
-
ISO8601Duration
Constructs duration value weeks and fractional part components.- Parameters:
weeks
- weeks valuefractional_part
- fractional part value
-
-
Method Details
-
setValue
Set an instance of this class from a String containing value notation of the DURATION.- Specified by:
setValue
in classAbstractISO8601Time
- Parameters:
value
- a string containing duration value.- Throws:
BadTimeFormatException
- ifvalue
has invalid format
-
getYears
public final int getYears()Get the years component of 'this' object.- Returns:
- int value indicating the years.
-
getMonths
public final int getMonths()Get the months component of 'this' object.- Returns:
- int value indicating the months.
-
getWeeks
public final int getWeeks()Get the weeks component of 'this' object.- Returns:
- int value indicating the weeks.
-
getDays
public final int getDays()Get the days component of 'this' object.- Returns:
- int value indicating the days.
-
getHours
public final int getHours()Get the hours component of 'this' object.- Returns:
- int value indicating the hours.
-
getMinutes
public final int getMinutes()Get the minutes component of 'this' object.- Returns:
- int value indicating the minutes.
-
getSeconds
public final int getSeconds()Get the seconds component of 'this' object.- Returns:
- int value indicating the seconds.
-
getFractional_part
Get the fractional part component of 'this' object.- Returns:
- fractional part.
-
setYears
public final void setYears(int years) Set the years component of 'this' object.- Parameters:
years
- the years to set.
-
setMonths
public final void setMonths(int months) Set the months component of 'this' object.- Parameters:
months
- the months to set.
-
setWeeks
public final void setWeeks(int weeks) Set the weeks component of 'this' object.- Parameters:
weeks
- the weeks to set.
-
setDays
public final void setDays(int days) Set the days component of 'this' object.- Parameters:
days
- the days to set.
-
setHours
public final void setHours(int hours) Set the hours component of 'this' object.- Parameters:
hours
- the hours to set.
-
setMinutes
public final void setMinutes(int minutes) Set the minutes component of 'this' object.- Parameters:
minutes
- the minutes to set.
-
setSeconds
public final void setSeconds(int seconds) Set the seconds component of 'this' object.- Parameters:
seconds
- the seconds to set.
-
setFractional_part
Set the fractional part component of 'this' object.- Parameters:
fractional_part
- the fractional part to set.
-
get
public int get(int field) Get a field's value.- Parameters:
field
- field designator.- Returns:
- field's value.
-
set
public void set(int field, int value) Set a field's value.- Parameters:
field
- field designator.value
- field value.
-
clear
public void clear()Clears all the fields so they are set to UNDEFINED value. -
equalTo
Compare 'this' object to another ISO8601Duration object to see if their contents are the same.- Parameters:
that
- the ISO8601Duration object to compare 'this' object to.- Returns:
- true if contents of both objects are the same.
-
clone
Clone 'this' object.- Overrides:
clone
in classAbstractData
- Returns:
- deep copy of 'this' object.
-