Exemple #1
0
 /**
  * Checks if the items can be compared. Items are comparable
  *
  * @param b second item
  * @return result of check
  */
 public final boolean comparable(final Item b) {
   return type == b.type
       || num() && b.num()
       || (unt() || str()) && (b.str() || b.unt())
       || dur() && b.dur()
       || func();
 }
Exemple #2
0
 /**
  * Checks if the specified expression yields a string. Returns a token representation or an
  * exception.
  *
  * @param e expression to be evaluated
  * @param ctx query context
  * @return item
  * @throws QueryException query exception
  */
 public final byte[] checkStr(final Expr e, final QueryContext ctx) throws QueryException {
   final Item it = checkItem(e, ctx);
   if (!it.str() && !it.unt()) Err.type(this, AtomType.STR, it);
   return it.atom(input);
 }
Exemple #3
0
 /**
  * Checks if the specified item is a string or an empty sequence. Returns a token representation
  * or an exception.
  *
  * @param it item to be checked
  * @return item
  * @throws QueryException query exception
  */
 public final byte[] checkEStr(final Item it) throws QueryException {
   if (it == null) return EMPTY;
   if (!it.str() && !it.unt()) Err.type(this, AtomType.STR, it);
   return it.atom(input);
 }
Exemple #4
0
 /**
  * Checks if the specified item is a number. Returns a token representation or an exception.
  *
  * @param it item to be checked
  * @return item
  * @throws QueryException query exception
  */
 public final long checkItr(final Item it) throws QueryException {
   if (!it.unt() && !it.type.instance(AtomType.ITR)) Err.type(this, AtomType.ITR, it);
   return it.itr(input);
 }
Exemple #5
0
  /**
   * Checks if the specified expression yields a double. Returns the double or throws an exception.
   *
   * @param e expression to be checked
   * @param ctx query context
   * @return double
   * @throws QueryException query exception
   */
  public final double checkDbl(final Expr e, final QueryContext ctx) throws QueryException {

    final Item it = checkNoEmpty(e.item(ctx, input), AtomType.DBL);
    if (!it.unt() && !it.num()) Err.number(this, it);
    return it.dbl(input);
  }
Exemple #6
0
  /**
   * Checks if the specified expression yields a boolean. Returns the boolean or throws an
   * exception.
   *
   * @param e expression to be checked
   * @param ctx query context
   * @return boolean
   * @throws QueryException query exception
   */
  public final boolean checkBln(final Expr e, final QueryContext ctx) throws QueryException {

    final Item it = checkNoEmpty(e.item(ctx, input), AtomType.BLN);
    if (!it.unt() && it.type != AtomType.BLN) Err.type(this, AtomType.BLN, it);
    return it.bool(input);
  }
Exemple #7
0
 @Override
 public final int diff(final InputInfo ii, final Item it) throws QueryException {
   return !it.unt() ? -it.diff(ii, this) : Token.diff(atom(), it.atom(ii));
 }
Exemple #8
0
 @Override
 public final boolean eq(final InputInfo ii, final Item it) throws QueryException {
   return !it.unt() ? it.eq(ii, this) : Token.eq(atom(), it.atom(ii));
 }