public class DurationValue extends AtomicValue
| Modifier and Type | Field and Description |
|---|---|
protected int |
days |
protected int |
hours |
protected int |
microseconds |
protected int |
minutes |
protected int |
months |
protected boolean |
negative |
protected boolean |
normalized |
protected int |
seconds |
protected int |
years |
EMPTY_CLASS_ARRAYEMPTY_VALUE_ARRAYEVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD| Modifier | Constructor and Description |
|---|---|
protected |
DurationValue()
Private constructor for internal use
|
|
DurationValue(boolean positive,
int years,
int months,
int days,
int hours,
int minutes,
int seconds,
int microseconds) |
|
DurationValue(java.lang.CharSequence s)
Constructor: create a duration value from a supplied string, in
ISO 8601 format [-]PnYnMnDTnHnMnS
|
| Modifier and Type | Method and Description |
|---|---|
DurationValue |
add(DurationValue other)
Add two durations
|
protected void |
badDuration(java.lang.String msg,
java.lang.CharSequence s) |
AtomicValue |
convertPrimitive(BuiltInAtomicType requiredType,
boolean validate,
XPathContext context)
Convert to target data type
|
java.lang.Object |
convertToJava(java.lang.Class target,
XPathContext context)
Convert to Java object (for passing to external functions)
|
DecimalValue |
divide(DurationValue other)
Divide a duration by a another duration
|
boolean |
equals(java.lang.Object other)
Test if the two durations are of equal length.
|
AtomicValue |
getComponent(int component)
Get a component of the normalized value
|
ItemType |
getItemType(TypeHierarchy th)
Determine the data type of the exprssion
|
double |
getLengthInSeconds()
Get length of duration in seconds, assuming an average length of month.
|
java.lang.String |
getStringValue()
Convert the value to a string, using the serialization rules.
|
java.lang.CharSequence |
getStringValueCS()
Convert to string
|
int |
hashCode()
Return a hash code to support the equals() function
|
DurationValue |
multiply(double factor)
Multiply a duration by a number
|
DurationValue |
negate()
Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)
|
DurationValue |
normalizeDuration()
Normalize the duration, so that months<12, hours<24, minutes<60, seconds<60.
|
protected void |
normalizeZeroDuration() |
int |
signum()
Return the signum of the value
|
DurationValue |
subtract(DurationValue other)
Subtract two durations
|
checkPermittedContents, convert, convert, display, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getImplementationMethod, getLength, getPrimitiveValue, getTypedValue, hasBuiltInType, iterate, process, toStringasItem, asIterator, asValue, convert, convertJavaObjectToXPath, getDependencies, getIterator, getParentExpression, getSpecialProperties, itemAt, iterateSubExpressions, makeQNameValue, optimize, promote, reduce, simplify, stringToNumber, typeCheckprotected boolean negative
protected int years
protected int months
protected int days
protected int hours
protected int minutes
protected int seconds
protected int microseconds
protected boolean normalized
protected DurationValue()
public DurationValue(boolean positive,
int years,
int months,
int days,
int hours,
int minutes,
int seconds,
int microseconds)
public DurationValue(java.lang.CharSequence s)
throws XPathException
XPathExceptionprotected void normalizeZeroDuration()
protected void badDuration(java.lang.String msg,
java.lang.CharSequence s)
throws XPathException
XPathExceptionpublic AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
convertPrimitive in class AtomicValuerequiredType - an integer identifying the required atomic typevalidate - if set to false, the caller asserts that the value is known to be validcontext - ValidationErrorValue if
the value cannot be converted.public DurationValue normalizeDuration()
public int signum()
public java.lang.String getStringValue()
getStringValue in interface ItemgetStringValue in interface ValueRepresentationgetStringValue in class AtomicValueItem.getStringValueCS()public java.lang.CharSequence getStringValueCS()
getStringValueCS in interface ItemgetStringValueCS in interface ValueRepresentationgetStringValueCS in class AtomicValueItem.getStringValue()public double getLengthInSeconds()
public ItemType getItemType(TypeHierarchy th)
getItemType in interface ExpressiongetItemType in class Valueth - public java.lang.Object convertToJava(java.lang.Class target,
XPathContext context)
throws XPathException
convertToJava in class ValueXPathExceptionpublic AtomicValue getComponent(int component) throws XPathException
getComponent in class AtomicValueXPathExceptionpublic boolean equals(java.lang.Object other)
public int hashCode()
Valuepublic DurationValue add(DurationValue other) throws XPathException
XPathExceptionpublic DurationValue subtract(DurationValue other) throws XPathException
XPathExceptionpublic DurationValue negate()
public DurationValue multiply(double factor) throws XPathException
XPathExceptionpublic DecimalValue divide(DurationValue other) throws XPathException
XPathException