Class MonthDurationValue
java.lang.Object
net.sf.saxon.value.Value
net.sf.saxon.value.AtomicValue
net.sf.saxon.value.DurationValue
net.sf.saxon.value.MonthDurationValue
- All Implemented Interfaces:
Serializable, Comparable, Expression, Item, ValueRepresentation
A value of type xsd:yearMonthDuration
- See Also:
-
Field Summary
Fields inherited from class DurationValue
days, hours, microseconds, minutes, months, negative, normalized, seconds, yearsFields inherited from class Value
EMPTY_CLASS_ARRAYFields inherited from interface Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHODFields inherited from interface ValueRepresentation
EMPTY_VALUE_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionConstructor: create a duration value from a supplied string, in ISO 8601 format [+|-]PnYnM -
Method Summary
Modifier and TypeMethodDescriptionadd(DurationValue other) Add two year-month-durationsintCompare the value to another duration valueconvertToJava(Class target, XPathContext context) Convert to Java object (for passing to external functions)divide(DurationValue other) Find the ratio between two durationsstatic MonthDurationValuefromMonths(int months) Construct a duration value as a number of months.Determine the data type of the exprssionintGet the number of months in the durationConvert to stringmultiply(double n) Multiply duration by a number.negate()Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)voidNormalize the value, for example 90M becomes 1H30Msubtract(DurationValue other) Subtract two year-month-durationsMethods inherited from class DurationValue
badDuration, convertPrimitive, equals, getComponent, getLengthInSeconds, getStringValue, hashCode, normalizeDuration, normalizeZeroDuration, signumMethods inherited from class AtomicValue
checkPermittedContents, convert, convert, display, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getImplementationMethod, getLength, getPrimitiveValue, getTypedValue, hasBuiltInType, iterate, process, toStringMethods inherited from class Value
asItem, asIterator, asValue, convert, convertJavaObjectToXPath, getDependencies, getIterator, getParentExpression, getSpecialProperties, itemAt, iterateSubExpressions, makeQNameValue, optimize, promote, reduce, simplify, stringToNumber, typeCheck
-
Constructor Details
-
MonthDurationValue
Constructor: create a duration value from a supplied string, in ISO 8601 format [+|-]PnYnM- Throws:
XPathException
-
-
Method Details
-
getStringValueCS
Convert to string- Specified by:
getStringValueCSin interfaceItem- Specified by:
getStringValueCSin interfaceValueRepresentation- Overrides:
getStringValueCSin classDurationValue- Returns:
- ISO 8601 representation.
- See Also:
-
normalize
public void normalize()Normalize the value, for example 90M becomes 1H30M -
getLengthInMonths
public int getLengthInMonths()Get the number of months in the duration -
fromMonths
Construct a duration value as a number of months. -
multiply
Multiply duration by a number. Also used when dividing a duration by a number- Overrides:
multiplyin classDurationValue- Throws:
XPathException
-
divide
Find the ratio between two durations- Overrides:
dividein classDurationValue- Parameters:
other- the dividend- Returns:
- the ratio, as a decimal
- Throws:
XPathException
-
add
Add two year-month-durations- Overrides:
addin classDurationValue- Throws:
XPathException
-
subtract
Subtract two year-month-durations- Overrides:
subtractin classDurationValue- Throws:
XPathException
-
negate
Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)- Overrides:
negatein classDurationValue
-
getItemType
Determine the data type of the exprssion- Specified by:
getItemTypein interfaceExpression- Overrides:
getItemTypein classDurationValue- Parameters:
th-- Returns:
- Type.YEAR_MONTH_DURATION,
-
convertToJava
Convert to Java object (for passing to external functions)- Overrides:
convertToJavain classDurationValue- Throws:
XPathException
-
compareTo
Compare the value to another duration value- Specified by:
compareToin interfaceComparable- Parameters:
other- The other dateTime value- Returns:
- negative value if this one is the earler, 0 if they are chronologically equal, positive value if this one is the later. For this purpose, dateTime values with an unknown timezone are considered to be UTC values (the Comparable interface requires a total ordering).
- Throws:
ClassCastException- if the other value is not a DateTimeValue (the parameter is declared as Object to satisfy the Comparable interface)
-