use of org.eclipse.wst.xml.xpath2.api.ResultSequence in project webtools.sourceediting by eclipse.
the class FnMax method max.
/**
* Max operation.
*
* @param args
* Result from the expressions evaluation.
* @param context
* Relevant dynamic context
* @throws DynamicError
* Dynamic error.
* @return Result of fn:max operation.
*/
public static ResultSequence max(Collection args, DynamicContext dynamicContext) throws DynamicError {
ResultSequence arg = get_arg(args, CmpGt.class);
if (arg.empty())
return ResultSequenceFactory.create_new();
CmpGt max = null;
TypePromoter tp = new ComparableTypePromoter();
tp.considerSequence(arg);
for (Iterator i = arg.iterator(); i.hasNext(); ) {
AnyAtomicType conv = tp.promote((AnyType) i.next());
if (conv != null) {
if (conv instanceof XSDouble && ((XSDouble) conv).nan() || conv instanceof XSFloat && ((XSFloat) conv).nan()) {
return ResultSequenceFactory.create_new(tp.promote(new XSFloat(Float.NaN)));
}
if (max == null || ((CmpGt) conv).gt((AnyType) max, dynamicContext)) {
max = (CmpGt) conv;
}
}
}
return ResultSequenceFactory.create_new((AnyType) max);
}
use of org.eclipse.wst.xml.xpath2.api.ResultSequence in project webtools.sourceediting by eclipse.
the class FnMinutesFromDateTime method minutes_from_date_time.
/**
* Minutes-from-DateTime operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:minutes-from-dateTime operation.
*/
public static ResultSequence minutes_from_date_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;
}
XSDateTime dt = (XSDateTime) arg1.first();
int res = dt.minute();
return new XSInteger(BigInteger.valueOf(res));
}
use of org.eclipse.wst.xml.xpath2.api.ResultSequence in project webtools.sourceediting by eclipse.
the class FnMonthFromDateTime method month_from_date_time.
/**
* Month-from-DateTime operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:month-from-dateTime operation.
*/
public static ResultSequence month_from_date_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;
}
XSDateTime dt = (XSDateTime) arg1.first();
int res = dt.month();
return new XSInteger(BigInteger.valueOf(res));
}
use of org.eclipse.wst.xml.xpath2.api.ResultSequence in project webtools.sourceediting by eclipse.
the class FnName method name.
/**
* Name operation.
*
* @param args
* Result from the expressions evaluation.
* @param context
* Dynamic context.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:name operation.
*/
public static ResultSequence name(Collection args, EvaluationContext ec) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
// get arg
ResultSequence arg1 = null;
if (cargs.isEmpty()) {
if (ec.getContextItem() == null)
throw DynamicError.contextUndefined();
else {
arg1 = ResultBuffer.wrap(ec.getContextItem());
}
} else {
arg1 = (ResultSequence) cargs.iterator().next();
}
if (arg1.empty()) {
return new XSString("");
}
NodeType an = (NodeType) arg1.first();
QName name = an.node_name();
String sname = "";
if (name != null)
sname = name.getStringValue();
return new XSString(sname);
}
use of org.eclipse.wst.xml.xpath2.api.ResultSequence in project webtools.sourceediting by eclipse.
the class FnZeroOrOne method zero_or_one.
/**
* Zero-or-One operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:zero-or-one operation.
*/
public static ResultSequence zero_or_one(Collection args) throws DynamicError {
assert args.size() == 1;
// get args
Iterator citer = args.iterator();
ResultSequence arg = (ResultSequence) citer.next();
if (arg.size() > 1)
throw DynamicError.more_one_item(null);
return arg;
}
Aggregations