org.exolab.castor.types

Class RecurringDuration

Implemented Interfaces:
java.io.Serializable
Known Direct Subclasses:
TimeInstant, TimePeriod

public class RecurringDuration
extends RecurringDurationBase

Represents recurringDuration utterly a recurringDuration must contain all the fields :

(+|-)CCYY-MM-DDThh:mm:ss.sss(Z|(+|-)hh:mm)

The validation of the date fields is done in the set methods and follows the ISO8601 Date and Time Format

It is possible to omit higher components by using '-'.

Version:
$Revision: 1.1.1.1 $
Author:
Arnaud Blandin
See Also:
Serialized Form

Constructor Summary

RecurringDuration()
RecurringDuration(String duration, String period)
returns a recurringDuration with the facets duration and period set up
RecurringDuration(String duration, String period, short[] values)
returns a recurringDuration with the facets duration and period set up but also the fields
RecurringDuration(TimeDuration duration, TimeDuration period)
returns a recurringDuration with the facets duration and period set up

Method Summary

boolean
equal(RecurringDuration reccD)
Returns true if the present instance of Recurring Duration is equal to the parameter.
boolean
equals(Object object)
Override the java.lang.equals method
short
getCentury()
short
getDay()
short
getMonth()
short[]
getValues()
returns an array of short with all the fields which describe a RecurringDuration
short
getYear()
boolean
isGreater(RecurringDuration reccD)
Returns true if the present instance of RecurringDuration is greater than the parameter

Note : the order relation follows the W3C XML Schema draft i.e rd1 <32rd2 iff rd2-rd1>0

boolean
isLeap()
return true if the year field represents a leap year A specific year is a leap year if it is either evenly divisible by 400 OR evenly divisible by 4 and not evenly divisible by 100
static Object
parse(String str)
static RecurringDuration
parseRecurringDuration(String str)
parse a String and convert it into a recurringDuration
void
setCentury(short century)
set the century field
void
setDay(short day)
set the Day Field
void
setMonth(short month)
set the Month Field
void
setValues(short[] values)
set all the fields by reading the values in an array
void
setYear(short year)
set the Year field Note: 0000 is not allowed
Date
toDate()
convert this recurringDuration into a local Date

Note : Be aware a the 'local' property of the date i.e toDate() will de the conversion between a UTC date and your computer date format.

String
toString()
Convert this recurringDuration to a string

The format is defined by W3C XML Schema draft and ISO8601 i.e (+|-)CCYY-MM-DDThh:mm:ss.sss(Z|(+|-)hh:mm)

Methods inherited from class org.exolab.castor.types.RecurringDurationBase

equal, equals, getDuration, getHour, getMilli, getMinute, getPeriod, getSeconds, getValues, getZoneHour, getZoneMinute, isGreater, isNegative, isUTC, isZoneNegative, setDuration, setDuration, setHour, setMinute, setNegative, setPeriod, setPeriod, setSecond, setUTC, setValues, setZone, setZoneNegative

Constructor Details

RecurringDuration

public RecurringDuration()

RecurringDuration

public RecurringDuration(String duration,
                         String period)
returns a recurringDuration with the facets duration and period set up
Parameters:
duration - the String representing the duration facet
period - the String reprensenting the period facet

RecurringDuration

public RecurringDuration(String duration,
                         String period,
                         short[] values)
            throws OperationNotSupportedException
returns a recurringDuration with the facets duration and period set up but also the fields
Parameters:
duration - the String representing the duration facet
period - the String reprensenting the period facet
values - an array of shorts which contains the values of the fields

RecurringDuration

public RecurringDuration(TimeDuration duration,
                         TimeDuration period)
returns a recurringDuration with the facets duration and period set up
Parameters:
duration - the TimeDuration representing the duration facet
period - the TimeDuration reprensenting the period facet

Method Details

equal

public boolean equal(RecurringDuration reccD)
            throws ValidationException
Returns true if the present instance of Recurring Duration is equal to the parameter.

The equals relation is the following :

rd1 equals rd2 iff each field of rd1 is equal to the corresponding field of rd2

Parameters:
reccD - the recurring duration to compare with the present instance
Returns:
true if the present instance is equal to the parameter false if not

equals

public boolean equals(Object object)
Override the java.lang.equals method
Overrides:
equals in interface RecurringDurationBase

getCentury

public short getCentury()

getDay

public short getDay()

getMonth

public short getMonth()

getValues

public short[] getValues()
returns an array of short with all the fields which describe a RecurringDuration
Overrides:
getValues in interface RecurringDurationBase
Returns:
an array of short with all the fields which describe a RecurringDuration

getYear

public short getYear()

isGreater

public boolean isGreater(RecurringDuration reccD)
            throws ValidationException
Returns true if the present instance of RecurringDuration is greater than the parameter

Note : the order relation follows the W3C XML Schema draft i.e rd1 <32rd2 iff rd2-rd1>0

Parameters:
reccD - the recurring duration to compare with the present instance
Returns:
true if the present instance is the greatest, false if not

isLeap

public boolean isLeap()
return true if the year field represents a leap year A specific year is a leap year if it is either evenly divisible by 400 OR evenly divisible by 4 and not evenly divisible by 100
Returns:
true if the year field represents a leap year

parse

public static Object parse(String str)
            throws ParseException

parseRecurringDuration

public static RecurringDuration parseRecurringDuration(String str)
            throws ParseException
parse a String and convert it into a recurringDuration
Parameters:
str - the string to parse
Returns:
the recurringDuration represented by the string

setCentury

public void setCentury(short century)
set the century field
Parameters:
century - the value to set up

setDay

public void setDay(short day)
            throws OperationNotSupportedException
set the Day Field
Parameters:
day - the value to set up Note a validation is done on the day field

setMonth

public void setMonth(short month)
            throws OperationNotSupportedException
set the Month Field
Parameters:
month - the value to set up Note 1<12>

setValues

public void setValues(short[] values)
            throws OperationNotSupportedException
set all the fields by reading the values in an array
Overrides:
setValues in interface RecurringDurationBase
Parameters:
values - an array of shorts with the values the array is supposed to be of length 10 and ordered like that:
  • century
  • year
  • month
  • day
  • hour
  • minute
  • second
  • millisecond
  • zoneHour
  • zoneMinute
Throws:
OperationNotSupportedException - this exception is thrown if changing the value of one field os not allowed

setYear

public void setYear(short year)
            throws OperationNotSupportedException
set the Year field Note: 0000 is not allowed
Parameters:

toDate

public Date toDate()
            throws ParseException
convert this recurringDuration into a local Date

Note : Be aware a the 'local' property of the date i.e toDate() will de the conversion between a UTC date and your computer date format. For instance if you have set up your computer time zone on the Pacific Day Time the conversion of 2000-10-20T00:00:00.000 into a java.util.Date will return Thu Oct 19 17:00:00 PDT 2000

Returns:
a local date representing this recurringDuration

toString

public String toString()
Convert this recurringDuration to a string

The format is defined by W3C XML Schema draft and ISO8601 i.e (+|-)CCYY-MM-DDThh:mm:ss.sss(Z|(+|-)hh:mm)

Returns:
a string representing this recurringDuration

Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com