예제 #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();
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
  }
예제 #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);
  }
예제 #7
0
파일: ANode.java 프로젝트: bhuesemann/basex
 @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));
 }
예제 #8
0
파일: ANode.java 프로젝트: bhuesemann/basex
 @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));
 }