- All Superinterfaces:
IAnyAtomicItem,IAtomicValuedItem,ICollectionValue,IItem
- All Known Subinterfaces:
IDecimalItem,IIntegerItem,INonNegativeIntegerItem,IPositiveIntegerItem
Represents an atomic Metapath item containing a numeric data value, which can
be either an integer or decimal. This interface provides operations for
numeric type conversion, comparison, and mathematical operations commonly
used in Metapath expressions.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionabs()Get the absolute value of the item.default INumericItemadd(INumericItem addend) Create a new sum by adding this value to the provided addend value.Get this item's value as a decimal.Get this item's value as an integer.static INumericItemcast(IAnyAtomicItem item) Cast the provided type to this item type.castAsType(IAnyAtomicItem item) Cast the provideditemto be the same type as this item.ceiling()Round the value to the whole number closest to positive infinity.default INumericItemdivide(INumericItem divisor) Divide this dividend value by the provided divisor value.floor()Round the value to the whole number closest to negative infinity.default IIntegerItemintegerDivide(INumericItem divisor) Divide this dividend value by the provided divisor value using integer division.default INumericItemmod(INumericItem divisor) Compute the remainder when dividing this dividend value by the provided divisor value.default INumericItemmultiply(INumericItem multiplier) Multiply this multiplicand value by the provided multiplier value.negate()Reverse the sign of this value.default INumericItemround()Round the item's value with zero precision.default INumericItemround(IIntegerItem precisionItem) Round the item's value with the specified precision.default INumericItemsubtract(INumericItem subtrahend) Determine the difference by subtracting the provided subtrahend value from this minuend value.booleanGet the effective boolean value of this item based on XPath 3.1.intConvert this numeric item to a Java int, exactly.static IAtomicOrUnionType<INumericItem>type()Get the type information for this item.Methods inherited from interface dev.metaschema.core.metapath.item.atomic.IAnyAtomicItem
accept, asMapKey, asString, asStringItem, atomize, deepEquals, getJavaTypeAdapter, getValue, toAtomicItemMethods inherited from interface dev.metaschema.core.metapath.item.ICollectionValue
deepEquals, toSignatureMethods inherited from interface dev.metaschema.core.metapath.item.IItem
contentsAsSequence, flatten, getType, hasValue, toSequence
-
Method Details
-
type
Get the type information for this item.- Returns:
- the type information
-
cast
Cast the provided type to this item type.Per XPath 3.1, boolean values are cast as:
true→ 1,false→ 0.- Parameters:
item- the item to cast- Returns:
- the original item if it is already this type, otherwise a new item cast to this type
- Throws:
InvalidValueForCastFunctionException- if the provideditemcannot be cast to this type
-
asDecimal
Get this item's value as a decimal.- Returns:
- the equivalent decimal value
-
asInteger
Get this item's value as an integer.- Returns:
- the equivalent integer value
-
toIntValueExact
int toIntValueExact()Convert this numeric item to a Java int, exactly. If the value is not in a valid int range, an exception is thrown.- Returns:
- the int value
- Throws:
CastFunctionException- if the value does not fit in an int
-
toEffectiveBoolean
boolean toEffectiveBoolean()Get the effective boolean value of this item based on XPath 3.1.- Returns:
- the effective boolean value
-
castAsType
Description copied from interface:IAnyAtomicItemCast the provideditemto be the same type as this item.- Specified by:
castAsTypein interfaceIAnyAtomicItem- Parameters:
item- the item to cast- Returns:
- an atomic item of this type
-
abs
Get the absolute value of the item.- Returns:
- this item negated if this item is negative, or the item otherwise
-
ceiling
Round the value to the whole number closest to positive infinity.- Returns:
- the rounded value
-
floor
Round the value to the whole number closest to negative infinity.- Returns:
- the rounded value
-
round
Round the item's value with zero precision.This is the same as calling
round(IIntegerItem)with a precision of0.- Returns:
- the rounded value
-
round
Round the item's value with the specified precision.This is the same as calling
round(IIntegerItem)with a precision of0.- Parameters:
precisionItem- the precision indicating the number of digits to round to before (negative value} or after (positive value) the decimal point.- Returns:
- the rounded value
-
add
Create a new sum by adding this value to the provided addend value.- Parameters:
addend- the second value to sum- Returns:
- a new value resulting from adding this value to the provided addend value
-
subtract
Determine the difference by subtracting the provided subtrahend value from this minuend value.- Parameters:
subtrahend- the value to subtract- Returns:
- a new value resulting from subtracting the subtrahend from the minuend
-
multiply
Multiply this multiplicand value by the provided multiplier value.- Parameters:
multiplier- the value to multiply by- Returns:
- a new value resulting from multiplying the multiplicand by the multiplier
-
divide
Divide this dividend value by the provided divisor value.- Parameters:
divisor- the value to divide by- Returns:
- a new value resulting from dividing the dividend by the divisor
-
integerDivide
Divide this dividend value by the provided divisor value using integer division.- Parameters:
divisor- the value to divide by- Returns:
- a new value resulting from dividing the dividend by the divisor
-
mod
Compute the remainder when dividing this dividend value by the provided divisor value.- Parameters:
divisor- the value to divide by- Returns:
- a new value containing the remainder resulting from dividing the dividend by the divisor
-
negate
Reverse the sign of this value.- Returns:
- a new value with the sign reversed
-