APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xerces.internal.jaxp.datatype

pack-priv Class DurationYearMonthImpl

extends DurationImpl
Class Inheritance
Imports
java.math.BigInteger, javax.xml.datatype.DatatypeConstants

Represent a subtype xdt:yearMonthDuration of a Duration as specified in XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.

The DurationYearMonth object represents a period of Gregorian time, with a lexical representation, "PnYnM" that contains only year and month components.

Author
Vikram Aroskar
See Also
XMLGregorianCalendar#add(Duration)

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from com.sun.org.apache.xerces.internal.jaxp.datatype.DurationImpl:
dayshoursminutesmonthssecondssignumyears

Constructor Summary

AccessConstructor and Description
public
DurationYearMonthImpl(boolean
Set to false to create a negative duration. When the length of the duration is zero, this parameter will be ignored.
isPositive
,
BigInteger
of this Duration
years
,
BigInteger
of this Duration
months
)

Constructs a new Duration object by specifying each field individually.

protected
DurationYearMonthImpl(final boolean
Set to false to create a negative duration. When the length of the duration is zero, this parameter will be ignored.
isPositive
,
final int years, final int months)

Construct a Duration of type xdt:yearMonthDuration using the specified year and month as defined in XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.

protected
DurationYearMonthImpl(long
Milliseconds of Duration to create.
durationInMilliseconds
)

Construct a Duration of type xdt:yearMonthDuration using the specified milliseconds as defined in XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.

protected
DurationYearMonthImpl(String
Lexical representation of a duration.
lexicalRepresentation
)

Construct a Duration of type xdt:yearMonthDuration by parsing its String representation, "PnYnM", XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.

Method Summary

Modifier and TypeMethod and Description
private void
public int

Returns:

the value of yearMonthDuration
getValue
()

The value space of xs:yearMonthDuration is the set of xs:integer month values.

Inherited from com.sun.org.apache.xerces.internal.jaxp.datatype.DurationImpl:
addaddToaddTocalcSignumcomparegetDaysgetFieldgetHoursgetMinutesgetMonthsgetSecondsgetSigngetTimeInMillisgetTimeInMillisgetYearshashCodeisSetmultiplymultiplynegatenormalizeWithsanitizesignumsubtracttestNonNegativetestNonNegativetoStringwrap

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.sun.org.apache.xerces.internal.jaxp.datatype.DurationImpl.serialVersionUID.

Constructor Detail

DurationYearMonthImplback to summary
public DurationYearMonthImpl(boolean isPositive, BigInteger years, BigInteger months)

Constructs a new Duration object by specifying each field individually.

All the parameters are optional as long as at least one field is present. If specified, parameters have to be zero or positive.

Parameters
isPositive:boolean

Set to false to create a negative duration. When the length of the duration is zero, this parameter will be ignored.

years:BigInteger

of this Duration

months:BigInteger

of this Duration

Exceptions
IllegalArgumentException:
If years, months parameters are all null. Or if any of those parameters are negative.
DurationYearMonthImplback to summary
protected DurationYearMonthImpl(final boolean isPositive, final int years, final int months)

Construct a Duration of type xdt:yearMonthDuration using the specified year and month as defined in XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.

A DatatypeConstants#FIELD_UNDEFINED value indicates that field is not set.

Parameters
isPositive:boolean

Set to false to create a negative duration. When the length of the duration is zero, this parameter will be ignored.

Exceptions
IllegalArgumentException:
If the values are not a valid representation of a Duration: if any of the fields (year, month) is negative.
DurationYearMonthImplback to summary
protected DurationYearMonthImpl(long durationInMilliseconds)

Construct a Duration of type xdt:yearMonthDuration using the specified milliseconds as defined in XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.

The datatype xdt:yearMonthDuration is a subtype of xs:duration whose lexical representation contains only year and month components. This datatype resides in the namespace javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI.

Both values are set by computing their values from the specified milliseconds and are availabe using the get methods of the created Duration. The values conform to and are defined by:

The default start instance is defined by GregorianCalendar's use of the start of the epoch: i.e., java.util.Calendar#YEAR = 1970, java.util.Calendar#MONTH = java.util.Calendar#JANUARY, java.util.Calendar#DATE = 1, etc. This is important as there are variations in the Gregorian Calendar, e.g. leap years have different days in the month = java.util.Calendar#FEBRUARY so the result of Duration#getMonths() can be influenced.

Any remaining milliseconds after determining the year and month are discarded.

Parameters
durationInMilliseconds:long

Milliseconds of Duration to create.

DurationYearMonthImplback to summary
protected DurationYearMonthImpl(String lexicalRepresentation)

Construct a Duration of type xdt:yearMonthDuration by parsing its String representation, "PnYnM", XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration.

The datatype xdt:yearMonthDuration is a subtype of xs:duration whose lexical representation contains only year and month components. This datatype resides in the namespace javax.xml.XMLConstants#W3C_XPATH_DATATYPE_NS_URI.

Both values are set and availabe from the created Duration

The XML Schema specification states that values can be of an arbitrary size. Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values. An UnsupportedOperationException will be thrown with a message indicating implementation limits if implementation capacities are exceeded.

Parameters
lexicalRepresentation:String

Lexical representation of a duration.

Exceptions
IllegalArgumentException:
If lexicalRepresentation is not a valid representation of a Duration expressed only in terms of years and months.
UnsupportedOperationException:
If implementation cannot support requested values.
NullPointerException:
If lexicalRepresentation is null.

Method Detail

convertToCanonicalYearMonthback to summary
private void convertToCanonicalYearMonth()
getValueback to summary
public int getValue()

The value space of xs:yearMonthDuration is the set of xs:integer month values.

Returns:int

the value of yearMonthDuration