예제 #1
0
    public long evalAsInteger(Focus focus, EvalContext context) throws EvaluationException {
      context.at(this);
      String s1 = args[0].evalAsOptString(focus, context);
      String s2 = args[1].evalAsOptString(focus, context);

      if (s1 == null || s2 == null) throw EmptyException.instance();

      Collator coll = getCollator(args.length <= 2 ? null : args[2], focus, context);
      context.at(this);
      // use Comparison.of to obtain EQ LT GT etc
      return Comparison.of(coll != null ? coll.compare(s1, s2) : s1.compareTo(s2), 0);
    }
예제 #2
0
 public double evalAsDouble(Focus focus, EvalContext context) throws EvaluationException {
   context.at(this);
   XQItem v = args[0].evalAsOptItem(focus, context);
   if (v == null) throw EmptyException.instance();
   if (v instanceof MomentValue) {
     MomentValue mv = (MomentValue) v;
     return mv.getValue().getSecond();
   }
   try {
     DateTime dt = DateTime.parseDateTime(v.getString());
     return dt.getSecond();
   } catch (DateTimeException e) {
     context.error(Conversion.ERR_CAST, this, "cannot cast to xs:dateTime : " + e.getMessage());
     return 0;
   }
 }