use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.
the class FnMatches method matches.
/**
* Matches operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:matches operation.
*/
public static ResultSequence matches(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
// get args
Iterator argiter = cargs.iterator();
ResultSequence arg1 = (ResultSequence) argiter.next();
String str1 = "";
if (!arg1.empty()) {
str1 = ((XSString) arg1.first()).value();
}
ResultSequence arg2 = (ResultSequence) argiter.next();
String pattern = ((XSString) arg2.first()).value();
String flags = null;
if (argiter.hasNext()) {
ResultSequence flagRS = null;
flagRS = (ResultSequence) argiter.next();
flags = flagRS.first().getStringValue();
if (validflags.indexOf(flags) == -1 && flags.length() > 0) {
throw DynamicError.regex_flags_error(null);
}
}
try {
boolean result = false;
result = matches(pattern, flags, str1);
return XSBoolean.valueOf(result);
} catch (PatternSyntaxException pex) {
throw DynamicError.regex_error(pex.getMessage());
}
}
use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.
the class FnMin method min.
/**
* Min operation.
*
* @param args
* Result from the expressions evaluation.
* @param dynamic
* Dynamic context
* @throws DynamicError
* Dynamic error.
* @return Result of fn:min operation.
*/
public static ResultSequence min(Collection args, DynamicContext context) throws DynamicError {
ResultSequence arg = FnMax.get_arg(args, CmpLt.class);
if (arg.empty())
return ResultSequenceFactory.create_new();
CmpLt 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 || ((CmpLt) conv).lt((AnyType) max, context)) {
max = (CmpLt) conv;
}
}
}
return ResultSequenceFactory.create_new((AnyType) max);
}
use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.
the class FnMonthFromDate method month_from_date.
/**
* Month-from-Date operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:month-from-date operation.
*/
public static ResultSequence month_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.month();
return new XSInteger(BigInteger.valueOf(res));
}
use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.
the class FnNilled method nilled.
/**
* Nilled operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:nilled operation.
*/
public static ResultSequence nilled(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return arg1;
}
NodeType nt = (NodeType) arg1.first();
return nt.nilled();
}
use of org.eclipse.wst.xml.xpath2.processor.DynamicError in project webtools.sourceediting by eclipse.
the class FnEmpty method empty.
/**
* Empty operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:empty operation.
*/
public static ResultSequence empty(Collection args) throws DynamicError {
assert args.size() == 1;
// get args
Iterator citer = args.iterator();
ResultSequence arg1 = (ResultSequence) citer.next();
return XSBoolean.valueOf(arg1.empty());
}
Aggregations