Search in sources :

Example 6 with XSTime

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

the class FnSecondsFromTime method seconds_from_time.

/**
 * Base-Uri operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:base-uri operation.
 */
public static ResultSequence seconds_from_time(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty()) {
        return ResultBuffer.EMPTY;
    }
    XSTime dt = (XSTime) arg1.first();
    double res = dt.second();
    return new XSDecimal(new BigDecimal(res));
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Collection(java.util.Collection) XSTime(org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime) XSDecimal(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal) BigDecimal(java.math.BigDecimal)

Example 7 with XSTime

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

the class FnMinutesFromTime method minutes_from_time.

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

Example 8 with XSTime

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

the class FnMinutesFromTime method expected_args.

/**
 * Obtain a list of expected arguments.
 *
 * @return Result of operation.
 */
public static synchronized Collection expected_args() {
    if (_expected_args == null) {
        _expected_args = new ArrayList();
        _expected_args.add(new SeqType(new XSTime(), SeqType.OCC_QMARK));
    }
    return _expected_args;
}
Also used : SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList) XSTime(org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime)

Example 9 with XSTime

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

the class FnHoursFromTime method hours_from_time.

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

Example 10 with XSTime

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

the class FnTimezoneFromTime method timezone_from_time.

/**
 * Timezone-from-Time operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:timezone-from-time operation.
 */
public static ResultSequence timezone_from_time(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty()) {
        return ResultBuffer.EMPTY;
    }
    XSTime dt = (XSTime) arg1.first();
    if (dt.timezoned()) {
        return dt.tz();
    }
    return ResultBuffer.EMPTY;
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Collection(java.util.Collection) XSTime(org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime)

Aggregations

XSTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime)13 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)6 SeqType (org.eclipse.wst.xml.xpath2.processor.internal.SeqType)6 XSDayTimeDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration)3 Iterator (java.util.Iterator)2 Duration (javax.xml.datatype.Duration)2 XSDate (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate)2 XSInteger (org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger)2 BigDecimal (java.math.BigDecimal)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)1 XSDateTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime)1 XSDecimal (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal)1 XSDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration)1