Package net.sf.saxon.value
Class SecondsDurationValue
java.lang.Object
net.sf.saxon.value.Value
net.sf.saxon.value.AtomicValue
net.sf.saxon.value.DurationValue
net.sf.saxon.value.SecondsDurationValue
- All Implemented Interfaces:
Serializable
,Comparable
,Expression
,Item
,ValueRepresentation
A value of type xsd:dayTimeDuration
- See Also:
-
Field Summary
Fields inherited from class net.sf.saxon.value.DurationValue
days, hours, microseconds, minutes, months, negative, normalized, seconds, years
Fields inherited from class net.sf.saxon.value.Value
EMPTY_CLASS_ARRAY
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
Constructor Summary
ConstructorsConstructorDescriptionSecondsDurationValue
(int sign, int days, int hours, int minutes, int seconds, int microseconds) Create a dayTimeDuration given the number of days, hours, minutes, and secondsConstructor: create a duration value from a supplied string, in ISO 8601 format [-]PnDTnHnMnS -
Method Summary
Modifier and TypeMethodDescriptionadd
(DurationValue other) Add two dayTimeDurationsint
Compare 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 SecondsDurationValue
fromMicroseconds
(long microseconds) Construct a duration value as a number of microseconds.static SecondsDurationValue
fromMilliseconds
(long milliseconds) Construct a duration value as a number of milliseconds.static SecondsDurationValue
fromSeconds
(BigDecimal seconds) Construct a duration value as a number of seconds.Determine the data type of the exprssionlong
Get length of duration in microseconds, as a longlong
Get length of duration in milliseconds, as a longdouble
Get length of duration in secondsConvert 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)void
Normalize the value, for example 90M becomes 1H30Msubtract
(DurationValue other) Subtract two dayTime-durationsMethods inherited from class net.sf.saxon.value.DurationValue
badDuration, convertPrimitive, equals, getComponent, getStringValue, hashCode, normalizeDuration, normalizeZeroDuration, signum
Methods inherited from class net.sf.saxon.value.AtomicValue
checkPermittedContents, convert, convert, display, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getImplementationMethod, getLength, getPrimitiveValue, getTypedValue, hasBuiltInType, iterate, process, toString
Methods inherited from class net.sf.saxon.value.Value
asItem, asIterator, asValue, convert, convertJavaObjectToXPath, getDependencies, getIterator, getParentExpression, getSpecialProperties, itemAt, iterateSubExpressions, makeQNameValue, optimize, promote, reduce, simplify, stringToNumber, typeCheck
-
Constructor Details
-
SecondsDurationValue
Constructor: create a duration value from a supplied string, in ISO 8601 format [-]PnDTnHnMnS- Throws:
XPathException
-
SecondsDurationValue
public SecondsDurationValue(int sign, int days, int hours, int minutes, int seconds, int microseconds) throws ValidationException Create a dayTimeDuration given the number of days, hours, minutes, and seconds- Throws:
ValidationException
-
-
Method Details
-
getStringValueCS
Convert to string- Specified by:
getStringValueCS
in interfaceItem
- Specified by:
getStringValueCS
in interfaceValueRepresentation
- Overrides:
getStringValueCS
in classDurationValue
- Returns:
- ISO 8601 representation.
- See Also:
-
normalize
Normalize the value, for example 90M becomes 1H30M- Throws:
ValidationException
-
getLengthInSeconds
public double getLengthInSeconds()Get length of duration in seconds- Overrides:
getLengthInSeconds
in classDurationValue
-
getLengthInMilliseconds
public long getLengthInMilliseconds()Get length of duration in milliseconds, as a long -
getLengthInMicroseconds
public long getLengthInMicroseconds()Get length of duration in microseconds, as a long -
fromSeconds
Construct a duration value as a number of seconds.- Throws:
XPathException
-
fromMilliseconds
Construct a duration value as a number of milliseconds.- Throws:
XPathException
-
fromMicroseconds
Construct a duration value as a number of microseconds.- Throws:
XPathException
-
multiply
Multiply duration by a number. This is also used when dividing a duration by a number.- Overrides:
multiply
in classDurationValue
- Throws:
XPathException
-
divide
Find the ratio between two durations- Overrides:
divide
in classDurationValue
- Parameters:
other
- the dividend- Returns:
- the ratio, as a decimal
- Throws:
XPathException
-
add
Add two dayTimeDurations- Overrides:
add
in classDurationValue
- Throws:
XPathException
-
subtract
Subtract two dayTime-durations- Overrides:
subtract
in classDurationValue
- Throws:
XPathException
-
negate
Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)- Overrides:
negate
in classDurationValue
-
compareTo
Compare the value to another duration value- Specified by:
compareTo
in 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)
-
getItemType
Determine the data type of the exprssion- Specified by:
getItemType
in interfaceExpression
- Overrides:
getItemType
in classDurationValue
- Parameters:
th
-- Returns:
- Type.DAY_TIME_DURATION,
-
convertToJava
Convert to Java object (for passing to external functions)- Overrides:
convertToJava
in classDurationValue
- Throws:
XPathException
-