Interface IDecimalItem

All Superinterfaces:
IAnyAtomicItem, IAtomicValuedItem, ICollectionValue, IItem, INumericItem
All Known Subinterfaces:
IIntegerItem, INonNegativeIntegerItem, IPositiveIntegerItem

public interface IDecimalItem extends INumericItem
An atomic Metapath item containing a decimal data value.
  • Field Details

    • ZERO

      @NonNull static final IDecimalItem ZERO
      The decimal item with the value "0".
  • Method Details

    • type

      @NonNull static IAtomicOrUnionType<IDecimalItem> type()
      Get the type information for this item.
      Returns:
      the type information
    • getType

      default IAtomicOrUnionType<? extends IDecimalItem> getType()
      Description copied from interface: IItem
      Get the type information for the item.
      Specified by:
      getType in interface IItem
      Returns:
      the item's type information
    • valueOf

      @NonNull static IDecimalItem valueOf(@NonNull String value)
      Construct a new decimal item using the provided string value.
      Parameters:
      value - a string representing a decimal value
      Returns:
      the new item
      Throws:
      InvalidTypeMetapathException - if the given string is not a decimal value
    • valueOf

      @NonNull static IDecimalItem valueOf(long value)
      Construct a new decimal item using the provided value.
      Parameters:
      value - a long value
      Returns:
      the new item
    • valueOf

      @NonNull static IDecimalItem valueOf(double value)
      Construct a new decimal item using the provided value.
      Parameters:
      value - a double value
      Returns:
      the new item
    • valueOf

      @NonNull static IDecimalItem valueOf(boolean value)
      Construct a new decimal item using the provided value.
      Parameters:
      value - a double value
      Returns:
      the new item
    • valueOf

      @NonNull static IDecimalItem valueOf(@NonNull BigDecimal value)
      Construct a new decimal item using the provided value.
      Parameters:
      value - a decimal value
      Returns:
      the new item
    • cast

      @NonNull static IDecimalItem cast(@NonNull IAnyAtomicItem item)
      Cast the provided type to this item type.
      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 provided item cannot be cast to this type
    • castAsType

      default IDecimalItem castAsType(IAnyAtomicItem item)
      Description copied from interface: IAnyAtomicItem
      Cast the provided item to be the same type as this item.
      Specified by:
      castAsType in interface IAnyAtomicItem
      Specified by:
      castAsType in interface INumericItem
      Parameters:
      item - the item to cast
      Returns:
      an atomic item of this type
    • toEffectiveBoolean

      default boolean toEffectiveBoolean()
      Description copied from interface: INumericItem
      Get the effective boolean value of this item based on XPath 3.1.
      Specified by:
      toEffectiveBoolean in interface INumericItem
      Returns:
      the effective boolean value
    • abs

      default INumericItem abs()
      Description copied from interface: INumericItem
      Get the absolute value of the item.
      Specified by:
      abs in interface INumericItem
      Returns:
      this item negated if this item is negative, or the item otherwise
    • ceiling

      default IIntegerItem ceiling()
      Description copied from interface: INumericItem
      Round the value to the whole number closest to positive infinity.
      Specified by:
      ceiling in interface INumericItem
      Returns:
      the rounded value
    • floor

      default IIntegerItem floor()
      Description copied from interface: INumericItem
      Round the value to the whole number closest to negative infinity.
      Specified by:
      floor in interface INumericItem
      Returns:
      the rounded value
    • toIntValueExact

      default int toIntValueExact()
      Convert this decimal item to a Java int, exactly. If the decimal is not in a valid int range, an exception is thrown.
      Specified by:
      toIntValueExact in interface INumericItem
      Returns:
      the int value
      Throws:
      CastFunctionException - if the value does not fit in an int
    • add

      @NonNull default IDecimalItem add(@NonNull IDecimalItem addend)
      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

      @NonNull default IDecimalItem subtract(@NonNull IDecimalItem subtrahend)
      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

      @NonNull default IDecimalItem multiply(@NonNull IDecimalItem multiplier)
      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

      @NonNull default IDecimalItem divide(@NonNull IDecimalItem divisor)
      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
      Throws:
      ArithmeticFunctionException - with the code ArithmeticFunctionException.DIVISION_BY_ZERO if the divisor is zero
    • integerDivide

      @NonNull default IIntegerItem integerDivide(INumericItem divisor)
      Divide this dividend value by the provided divisor value using integer division.
      Specified by:
      integerDivide in interface INumericItem
      Parameters:
      divisor - the value to divide by
      Returns:
      a new value resulting from dividing the dividend by the divisor
    • mod

      @NonNull default IDecimalItem mod(INumericItem divisor)
      Compute the remainder when dividing this dividend value by the provided divisor value.
      Specified by:
      mod in interface INumericItem
      Parameters:
      divisor - the value to divide by
      Returns:
      a new value containing the remainder resulting from dividing the dividend by the divisor
    • negate

      default IDecimalItem negate()
      Description copied from interface: INumericItem
      Reverse the sign of this value.
      Specified by:
      negate in interface INumericItem
      Returns:
      a new value with the sign reversed
    • compareTo

      default int compareTo(@NonNull IDecimalItem item)
      Compares this value with the argument.
      Parameters:
      item - the item to compare with this value
      Returns:
      a negative integer, zero, or a positive integer if this value is less than, equal to, or greater than the item.