|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.value.Value<AtomicValue> net.sf.saxon.value.AtomicValue net.sf.saxon.value.DurationValue
public class DurationValue
A value of type xs:duration
Field Summary | |
---|---|
protected int |
microseconds
|
protected int |
months
|
protected boolean |
negative
|
protected long |
seconds
|
Fields inherited from class net.sf.saxon.value.AtomicValue |
---|
typeLabel |
Fields inherited from class net.sf.saxon.value.Value |
---|
INDETERMINATE_ORDERING |
Fields inherited from interface net.sf.saxon.om.ValueRepresentation |
---|
EMPTY_VALUE_ARRAY |
Constructor Summary | |
---|---|
protected |
DurationValue()
Private constructor for internal use |
|
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 |
protected static ValidationFailure |
badDuration(String msg,
CharSequence s)
|
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 |
CharSequence |
getPrimitiveStringValue()
Convert to string |
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 |
int |
getTotalMonths()
Get the total number of months (ignoring the days/hours/minutes/seconds) |
BigDecimal |
getTotalSeconds()
Get the total number of seconds (ignoring the years/months) |
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 |
protected static ConversionResult |
makeDuration(CharSequence s,
boolean allowYM,
boolean allowDT)
|
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 |
protected void |
normalizeZeroDuration()
Ensure that a zero duration is considered positive |
int |
signum()
Return the signum of the value |
protected static int |
simpleInteger(String s)
Parse a simple unsigned integer |
DurationValue |
subtract(DurationValue other)
Subtract two durations |
Methods inherited from class net.sf.saxon.value.AtomicValue |
---|
asAtomic, checkPermittedContents, effectiveBooleanValue, getCardinality, getItemType, getLength, getStringValue, getStringValueCS, getTypedValue, getTypeLabel, isIdentical, isNaN, itemAt, iterate, process, setTypeLabel, subsequence, toString |
Methods inherited from class net.sf.saxon.value.Value |
---|
asItem, asItem, asIterator, asValue, convertToJava, fromItem, getCanonicalLexicalRepresentation, getIterator, getSequenceLength, reduce |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean negative
protected int months
protected long seconds
protected int microseconds
Constructor Detail |
---|
protected DurationValue()
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 |
---|
protected void normalizeZeroDuration()
public static ConversionResult makeDuration(CharSequence s)
s
- a string in the lexical space of xs:duration
ValidationFailure
if the
supplied string is lexically invalid.protected static ConversionResult makeDuration(CharSequence s, boolean allowYM, boolean allowDT)
protected static ValidationFailure badDuration(String msg, CharSequence s)
protected static int simpleInteger(String s)
s
- the string containing the sequence of digits. No sign or whitespace is allowed.
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 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 int getTotalMonths()
public BigDecimal getTotalSeconds()
public CharSequence getPrimitiveStringValue()
getPrimitiveStringValue
in class AtomicValue
public double getLengthInSeconds()
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
- if a dynamic error occurspublic 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
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 Value<AtomicValue>
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 |