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:
java.io.Serializable,java.lang.Comparable,Expression,Item,ValueRepresentation
public final class SecondsDurationValue extends DurationValue implements java.lang.Comparable
A value of type xsd:dayTimeDuration- See Also:
- Serialized Form
-
-
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
Constructors Constructor Description SecondsDurationValue(int sign, int days, int hours, int minutes, int seconds, int microseconds)Create a dayTimeDuration given the number of days, hours, minutes, and secondsSecondsDurationValue(java.lang.CharSequence s)Constructor: create a duration value from a supplied string, in ISO 8601 format [-]PnDTnHnMnS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DurationValueadd(DurationValue other)Add two dayTimeDurationsintcompareTo(java.lang.Object other)Compare the value to another duration valuejava.lang.ObjectconvertToJava(java.lang.Class target, XPathContext context)Convert to Java object (for passing to external functions)DecimalValuedivide(DurationValue other)Find the ratio between two durationsstatic SecondsDurationValuefromMicroseconds(long microseconds)Construct a duration value as a number of microseconds.static SecondsDurationValuefromMilliseconds(long milliseconds)Construct a duration value as a number of milliseconds.static SecondsDurationValuefromSeconds(java.math.BigDecimal seconds)Construct a duration value as a number of seconds.ItemTypegetItemType(TypeHierarchy th)Determine the data type of the exprssionlonggetLengthInMicroseconds()Get length of duration in microseconds, as a longlonggetLengthInMilliseconds()Get length of duration in milliseconds, as a longdoublegetLengthInSeconds()Get length of duration in secondsjava.lang.CharSequencegetStringValueCS()Convert to stringDurationValuemultiply(double n)Multiply duration by a number.DurationValuenegate()Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)voidnormalize()Normalize the value, for example 90M becomes 1H30MDurationValuesubtract(DurationValue other)Subtract two dayTime-durations-
Methods 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 Detail
-
SecondsDurationValue
public SecondsDurationValue(java.lang.CharSequence s) throws XPathExceptionConstructor: 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 ValidationExceptionCreate a dayTimeDuration given the number of days, hours, minutes, and seconds- Throws:
ValidationException
-
-
Method Detail
-
getStringValueCS
public java.lang.CharSequence getStringValueCS()
Convert to string- Specified by:
getStringValueCSin interfaceItem- Specified by:
getStringValueCSin interfaceValueRepresentation- Overrides:
getStringValueCSin classDurationValue- Returns:
- ISO 8601 representation.
- See Also:
Item.getStringValue()
-
normalize
public void normalize() throws ValidationExceptionNormalize the value, for example 90M becomes 1H30M- Throws:
ValidationException
-
getLengthInSeconds
public double getLengthInSeconds()
Get length of duration in seconds- Overrides:
getLengthInSecondsin 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
public static SecondsDurationValue fromSeconds(java.math.BigDecimal seconds) throws XPathException
Construct a duration value as a number of seconds.- Throws:
XPathException
-
fromMilliseconds
public static SecondsDurationValue fromMilliseconds(long milliseconds) throws XPathException
Construct a duration value as a number of milliseconds.- Throws:
XPathException
-
fromMicroseconds
public static SecondsDurationValue fromMicroseconds(long microseconds) throws XPathException
Construct a duration value as a number of microseconds.- Throws:
XPathException
-
multiply
public DurationValue multiply(double n) throws XPathException
Multiply duration by a number. This is also used when dividing a duration by a number.- Overrides:
multiplyin classDurationValue- Throws:
XPathException
-
divide
public DecimalValue divide(DurationValue other) throws XPathException
Find the ratio between two durations- Overrides:
dividein classDurationValue- Parameters:
other- the dividend- Returns:
- the ratio, as a decimal
- Throws:
XPathException
-
add
public DurationValue add(DurationValue other) throws XPathException
Add two dayTimeDurations- Overrides:
addin classDurationValue- Throws:
XPathException
-
subtract
public DurationValue subtract(DurationValue other) throws XPathException
Subtract two dayTime-durations- Overrides:
subtractin classDurationValue- Throws:
XPathException
-
negate
public DurationValue negate()
Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)- Overrides:
negatein classDurationValue
-
compareTo
public int compareTo(java.lang.Object other)
Compare the value to another duration value- Specified by:
compareToin interfacejava.lang.Comparable- 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:
java.lang.ClassCastException- if the other value is not a DateTimeValue (the parameter is declared as Object to satisfy the Comparable interface)
-
getItemType
public ItemType getItemType(TypeHierarchy th)
Determine the data type of the exprssion- Specified by:
getItemTypein interfaceExpression- Overrides:
getItemTypein classDurationValue- Parameters:
th-- Returns:
- Type.DAY_TIME_DURATION,
-
convertToJava
public java.lang.Object convertToJava(java.lang.Class target, XPathContext context) throws XPathExceptionConvert to Java object (for passing to external functions)- Overrides:
convertToJavain classDurationValue- Throws:
XPathException
-
-