|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.value.Value net.sf.saxon.value.AtomicValue net.sf.saxon.value.DurationValue
public class DurationValue
A value of type xs:duration
Field Summary |
---|
Fields inherited from class net.sf.saxon.value.Value |
---|
EMPTY_CLASS_ARRAY, INDETERMINATE_ORDERING |
Fields inherited from interface net.sf.saxon.om.ValueRepresentation |
---|
EMPTY_VALUE_ARRAY |
Fields inherited from interface net.sf.saxon.om.ValueRepresentation |
---|
EMPTY_VALUE_ARRAY |
Constructor Summary | |
---|---|
DurationValue(boolean positive,
int years,
int months,
int days,
int hours,
int minutes,
long seconds,
int microseconds)
Constructor for xs:duration taking the components of the duration. |
|
DurationValue(boolean positive,
int years,
int months,
int days,
int hours,
int minutes,
long seconds,
int microseconds,
AtomicType type)
Constructor for xs:duration taking the components of the duration, plus a user-specified type which must be a subtype of xs:duration. |
Method Summary | |
---|---|
DurationValue |
add(DurationValue other)
Add two durations |
ConversionResult |
convertPrimitive(BuiltInAtomicType requiredType,
boolean validate,
XPathContext context)
Convert to target data type |
Object |
convertToJava(Class target,
XPathContext context)
Convert to Java object (for passing to external functions) |
AtomicValue |
copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value, with a different type label |
DecimalValue |
divide(DurationValue other)
Divide a duration by a another duration |
boolean |
equals(Object other)
Test if the two durations are of equal length. |
AtomicValue |
getComponent(int component)
Get a component of the normalized value |
int |
getDays()
Get the days component |
int |
getHours()
Get the hours component |
double |
getLengthInSeconds()
Get length of duration in seconds, assuming an average length of month. |
int |
getMicroseconds()
Get the microseconds component |
int |
getMinutes()
Get the minutes component |
int |
getMonths()
Get the months component |
BuiltInAtomicType |
getPrimitiveType()
Determine the primitive type of the value. |
Comparable |
getSchemaComparable()
Get a Comparable value that implements the XML Schema ordering comparison semantics for this value. |
static Comparable |
getSchemaComparable(DurationValue value)
Get a Comparable value that implements the XML Schema ordering comparison semantics for this value. |
int |
getSeconds()
Get the seconds component |
String |
getStringValue()
Convert the value to a string, using the serialization rules. |
CharSequence |
getStringValueCS()
Convert to string |
Object |
getXPathComparable(boolean ordered,
StringCollator collator,
XPathContext context)
Get an object value that implements the XPath equality and ordering comparison semantics for this value. |
int |
getYears()
Get the year component |
int |
hashCode()
|
static ConversionResult |
makeDuration(CharSequence s)
Static factory method: create a duration value from a supplied string, in ISO 8601 format [-]PnYnMnDTnHnMnS |
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()
Deprecated. since 9.0 - the method does nothing |
int |
signum()
Return the signum of the value |
DurationValue |
subtract(DurationValue other)
Subtract two durations |
Methods inherited from class net.sf.saxon.value.AtomicValue |
---|
asAtomic, checkPermittedContents, convert, convert, effectiveBooleanValue, getCardinality, getItemType, getLength, getTypedValue, getTypeLabel, isNaN, itemAt, iterate, process, setTypeLabel, subsequence, toString |
Methods inherited from class net.sf.saxon.value.Value |
---|
asItem, asItem, asIterator, asValue, convertJavaObjectToXPath, convertToJava, fromItem, getCanonicalLexicalRepresentation, getIterator, iterate, makeQNameValue, reduce, stringToNumber |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DurationValue(boolean positive, int years, int months, int days, int hours, int minutes, long seconds, int microseconds) throws IllegalArgumentException
positive
- true if the duration is positive, false if negative. For a negative duration
the components are all supplied as positive integers (or zero).years
- the number of yearsmonths
- the number of monthsdays
- the number of dayshours
- the number of hoursminutes
- the number of minutesseconds
- the number of secondsmicroseconds
- the number of microseconds
IllegalArgumentException
- if the size of the duration exceeds implementation-defined
limits: specifically, if the total number of months exceeds 2^31, or if the total number
of seconds exceeds 2^63.public DurationValue(boolean positive, int years, int months, int days, int hours, int minutes, long seconds, int microseconds, AtomicType type)
positive
- true if the duration is positive, false if negative. For a negative duration
the components are all supplied as positive integers (or zero).years
- the number of yearsmonths
- the number of monthsdays
- the number of dayshours
- the number of hoursminutes
- the number of minutesseconds
- the number of seconds (long to allow copying)microseconds
- the number of microsecondstype
- the user-defined subtype of xs:duration. Note that this constructor cannot
be used to create an instance of xs:dayTimeDuration or xs:yearMonthDuration.
IllegalArgumentException
- if the size of the duration exceeds implementation-defined
limits: specifically, if the total number of months exceeds 2^31, or if the total number
of seconds exceeds 2^63.Method Detail |
---|
public static ConversionResult makeDuration(CharSequence s)
s
- a string in the lexical space of xs:duration
ValidationFailure
if the
supplied string is lexically invalid.public AtomicValue copyAsSubType(AtomicType typeLabel)
copyAsSubType
in class AtomicValue
typeLabel
- the type label of the new copy. The caller is responsible for checking that
the value actually conforms to this type.
public BuiltInAtomicType getPrimitiveType()
getPrimitiveType
in class AtomicValue
public ConversionResult convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
requiredType
- an integer identifying the required atomic typevalidate
- if set to false, the caller asserts that the value is known to be validcontext
- the XPath dynamic context
ValidationFailure
if
the value cannot be converted.public DurationValue normalizeDuration()
public int signum()
public int getYears()
public int getMonths()
public int getDays()
public int getHours()
public int getMinutes()
public int getSeconds()
public int getMicroseconds()
public String getStringValue()
getStringValue
in interface Item
getStringValue
in interface ValueRepresentation
getStringValue
in class AtomicValue
Item.getStringValueCS()
public CharSequence getStringValueCS()
getStringValueCS
in interface Item
getStringValueCS
in interface ValueRepresentation
getStringValueCS
in class AtomicValue
Item.getStringValue()
public double getLengthInSeconds()
public Object convertToJava(Class target, XPathContext context) throws XPathException
convertToJava
in class Value
target
- the required target classcontext
- the XPath dynamic evaluation context
XPathException
public AtomicValue getComponent(int component) throws XPathException
getComponent
in class AtomicValue
component
- identifies the required component, as a constant defined in class
Component
, for example Component.HOURS
XPathException
public Object getXPathComparable(boolean ordered, StringCollator collator, XPathContext context)
getXPathComparable
in class AtomicValue
ordered
- true if an ordered comparison is required. In this case the result is null if the
type is unordered; in other cases the returned value will be a Comparable.collator
- collation used for comparing string valuescontext
- the XPath dynamic evaluation context, used in cases where the comparison is context
sensitive @return an Object whose equals() and hashCode() methods implement the XPath comparison semantics
with respect to this atomic value. If ordered is specified, the result will either be null if
no ordering is defined, or will be a Comparable
public boolean equals(Object other)
equals
in class AtomicValue
other
- the other value
ClassCastException
- if the other value is not an xs:duration or subtype thereofpublic int hashCode()
hashCode
in class Object
public DurationValue add(DurationValue other) throws XPathException
other
- the duration to be added to this one
XPathException
public DurationValue subtract(DurationValue other) throws XPathException
other
- the duration to be subtracted from this one
XPathException
public DurationValue negate()
public DurationValue multiply(double factor) throws XPathException
factor
- the number to multiply by
XPathException
public DecimalValue divide(DurationValue other) throws XPathException
other
- the duration to divide by
XPathException
public Comparable getSchemaComparable()
getSchemaComparable
in class AtomicValue
public static Comparable getSchemaComparable(DurationValue value)
value
- the duration for which a comparison key is required
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |