Search in sources :

Example 41 with XSInteger

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

the class XSInteger method lt.

/*
	 * (non-Javadoc)
	 * @see org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal#lt(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)
	 */
public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
    Item carg = convertArg(arg);
    XSInteger val = (XSInteger) get_single_type(carg, XSInteger.class);
    int compareResult = int_value().compareTo(val.int_value());
    return compareResult < 0;
}
Also used : Item(org.eclipse.wst.xml.xpath2.api.Item)

Example 42 with XSInteger

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

the class XSFloat method idiv.

/**
 * Mathematical integer division operator between this XSFloat and the
 * supplied ResultSequence.
 *
 * @param arg
 *            The ResultSequence to perform an integer division with
 * @return A XSInteger consisting of the result of the mathematical integer
 *         division.
 */
public ResultSequence idiv(ResultSequence arg) throws DynamicError {
    ResultSequence carg = convertResultSequence(arg);
    XSFloat val = (XSFloat) get_single_type(carg, XSFloat.class);
    if (this.nan() || val.nan())
        throw DynamicError.numeric_overflow("Dividend or divisor is NaN");
    if (this.infinite())
        throw DynamicError.numeric_overflow("Dividend is infinite");
    if (val.zero())
        throw DynamicError.div_zero(null);
    BigDecimal result = BigDecimal.valueOf((new Float((float_value() / val.float_value()))).longValue());
    return ResultSequenceFactory.create_new(new XSInteger(result.toBigInteger()));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) BigDecimal(java.math.BigDecimal)

Example 43 with XSInteger

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

the class FnYearFromDate method year_from_date.

/**
 * Year-from-Date operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:year-from-date operation.
 */
public static ResultSequence year_from_date(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty()) {
        return ResultBuffer.EMPTY;
    }
    XSDate dt = (XSDate) arg1.first();
    int res = dt.year();
    return new XSInteger(BigInteger.valueOf(res));
}
Also used : XSDate(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) Collection(java.util.Collection)

Example 44 with XSInteger

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

the class FnYearsFromDuration method years_from_duration.

/**
 * Years-from-Duration operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:years-from-duration operation.
 */
public static ResultSequence years_from_duration(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty()) {
        return ResultBuffer.EMPTY;
    }
    XSDuration ymd = (XSDuration) arg1.first();
    int res = ymd.year();
    if (ymd.negative())
        res *= -1;
    return new XSInteger(BigInteger.valueOf(res));
}
Also used : XSDuration(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) Collection(java.util.Collection)

Aggregations

XSInteger (org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger)34 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)32 Collection (java.util.Collection)20 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)12 Iterator (java.util.Iterator)8 ResultSequence (org.eclipse.wst.xml.xpath2.processor.ResultSequence)8 XSDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration)6 URL (java.net.URL)5 XSModel (org.apache.xerces.xs.XSModel)5 Item (org.eclipse.wst.xml.xpath2.api.Item)5 XSDateTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime)5 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)4 BigInteger (java.math.BigInteger)3 XSBoolean (org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean)3 XSDate (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate)3 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 SeqType (org.eclipse.wst.xml.xpath2.processor.internal.SeqType)2 AnyAtomicType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType)2 XSTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime)2