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 6.0
- 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
Fields inherited from interface com.oss.asn1.ISO8601TimeInterface
CENTURY, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_YEAR, FRACTIONAL_DIGITS, FRACTIONAL_VALUE, HOUR, MINUTE, MINUTE_DIFFERENTIAL, MONTH, SECOND, UNDEFINED, UTC, WEEK, YEAR, YEAR_DIGITS
-
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 field 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.Returns the name of ASN.1 type this java class represents.final int
getWeeks()
Get the weeks component of 'this' object.final int
getYears()
Get the years component of 'this' object.int
hashCode()
Returns a hash code for this objectTakes formatted string that contains the value of ISO8601Duration, splits the string to the components and initializes this instance of theISO8601Duration
class.void
set
(int field, int value) Set field 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.final String
toFormattedString
(boolean isBer) Converts this instance ofISO8601TimeInterface
to the formatted string, suitable for the encoding.Methods inherited from class com.oss.asn1.AbstractISO8601Time
compareTo, compareTo, toDate, toDate, validateTime
Methods inherited from class com.oss.asn1.AbstractData
delete, equals, 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
-
clone
Clone 'this' object.- Returns:
- deep copy of 'this' object.
-
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 field value.- Parameters:
field
- field designator.- Returns:
- field value.
-
set
public void set(int field, int value) Set field 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.
-
toFormattedString
Converts this instance ofISO8601TimeInterface
to the formatted string, suitable for the encoding.- Specified by:
toFormattedString
in classAbstractISO8601Time
- Parameters:
isBer
- set to true if the time value is to be BER format- Returns:
- string that contain the value, formatted accordingly to the ISO8601Duration format
- Throws:
com.oss.util.BadTimeValueException
- if the the value contains invalid components that make the formatting impossible
-
parseTime
Takes formatted string that contains the value of ISO8601Duration, splits the string to the components and initializes this instance of theISO8601Duration
class. If the string has invalid format, a BadTimeFormatException exception is thrown. The method expects that the string has the format, specified in the description of thetoFormattedString
method.- Specified by:
parseTime
in classAbstractISO8601Time
- Parameters:
str
- formatted string that contains the value of ISO8601DurationisBer
- set to true if the time value is to be BER format- Returns:
- reference to this object
- Throws:
BadTimeFormatException
- ifstr
has invalid format
-
hashCode
public int hashCode()Returns a hash code for this object- Overrides:
hashCode
in classAbstractData
- Returns:
- a hash code for this object
-
getTypeName
Returns the name of ASN.1 type this java class represents.- Overrides:
getTypeName
in classAbstractData
- Returns:
- the name of the ASN.1 type.
-