Search in sources :

Example 26 with XSDouble

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble in project webtools.sourceediting by eclipse.

the class XSDayTimeDuration method times.

/**
 * Mathematical multiplication between this duration stored and the supplied
 * duration of time (of type XSDayTimeDuration)
 *
 * @param arg
 *            The duration of time to multiply by
 * @return New XSDayTimeDuration representing the resulting duration after
 *         the multiplication
 * @throws DynamicError
 */
public ResultSequence times(ResultSequence arg) throws DynamicError {
    ResultSequence convertedRS = arg;
    if (arg.size() == 1) {
        Item argValue = arg.first();
        if (argValue instanceof XSDecimal) {
            convertedRS = ResultSequenceFactory.create_new(new XSDouble(argValue.getStringValue()));
        }
    }
    XSDouble val = (XSDouble) NumericType.get_single_type(convertedRS, XSDouble.class);
    if (val.nan()) {
        throw DynamicError.nan();
    }
    double res = value() * val.double_value();
    return ResultSequenceFactory.create_new(new XSDayTimeDuration(res));
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence)

Aggregations

ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)17 Item (org.eclipse.wst.xml.xpath2.api.Item)12 XSDouble (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDouble)12 Iterator (java.util.Iterator)9 AnyAtomicType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType)6 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)6 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)5 XSFloat (org.eclipse.wst.xml.xpath2.processor.internal.types.XSFloat)5 Collection (java.util.Collection)4 NumericType (org.eclipse.wst.xml.xpath2.processor.internal.types.NumericType)4 XSUntypedAtomic (org.eclipse.wst.xml.xpath2.processor.internal.types.XSUntypedAtomic)4 TypePromoter (org.eclipse.wst.xml.xpath2.processor.internal.utils.TypePromoter)4 BigDecimal (java.math.BigDecimal)3 ArrayList (java.util.ArrayList)3 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)3 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)2 ComparableTypePromoter (org.eclipse.wst.xml.xpath2.processor.internal.utils.ComparableTypePromoter)2 ScalarTypePromoter (org.eclipse.wst.xml.xpath2.processor.internal.utils.ScalarTypePromoter)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URL (java.net.URL)1