Search in sources :

Example 36 with XSInteger

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

the class FnDaysFromDuration method days_from_duration.

/**
 * Days-From-Duration operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:days-from-duration operation.
 */
public static ResultSequence days_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 dtd = (XSDuration) arg1.first();
    int res = dtd.days();
    if (dtd.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)

Example 37 with XSInteger

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

the class FnHoursFromDuration method hours_from_duration.

/**
 * Hours-from-Duration operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:hours-from-duration operation.
 */
public static ResultSequence hours_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 dtd = (XSDuration) arg1.first();
    int res = dtd.hours();
    if (dtd.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)

Example 38 with XSInteger

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

the class XSInteger method mod.

/**
 * Mathematical modulus operator between this XSInteger and the supplied
 * ResultSequence.
 *
 * @param arg
 *            The ResultSequence to perform a modulus with
 * @return A XSInteger consisting of the result of the mathematical modulus.
 */
public ResultSequence mod(ResultSequence arg) throws DynamicError {
    ResultSequence carg = convertResultSequence(arg);
    XSInteger val = (XSInteger) get_single_type(carg, XSInteger.class);
    BigInteger result = int_value().remainder(val.int_value());
    return ResultSequenceFactory.create_new(new XSInteger(result));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) BigInteger(java.math.BigInteger)

Example 39 with XSInteger

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

the class XSInteger method gt.

/*
	 * (non-Javadoc)
	 * @see org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal#gt(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)
	 */
public boolean gt(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 40 with XSInteger

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

the class XSInteger method times.

/**
 * Mathematical multiplication operator between this XSInteger and the
 * supplied ResultSequence.
 *
 * @param arg
 *            The ResultSequence to perform a multiplication with
 * @return A XSInteger consisting of the result of the mathematical
 *         multiplication.
 */
public ResultSequence times(ResultSequence arg) throws DynamicError {
    ResultSequence carg = convertResultSequence(arg);
    XSInteger val = (XSInteger) get_single_type(carg, XSInteger.class);
    return ResultSequenceFactory.create_new(new XSInteger(int_value().multiply(val.int_value())));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence)

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