Esempio n. 1
0
 /**
  * Checks if the specified expression yields an element. Returns the element or throws an
  * exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return binary item
  * @throws QueryException query exception
  */
 protected final ANode toElem(final Expr ex, final QueryContext qc) throws QueryException {
   return (ANode) checkType(ex.item(qc, info), NodeType.ELM);
 }
Esempio n. 2
0
 /**
  * Checks if the evaluated expression yields a non-empty item. Returns the item or throws an
  * exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return item
  * @throws QueryException query exception
  */
 protected final Item toItem(final Expr ex, final QueryContext qc) throws QueryException {
   return checkNoEmpty(ex.item(qc, info));
 }
Esempio n. 3
0
 /**
  * Checks if the specified expression yields a non-empty item. Returns the item or throws an
  * exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @param type expected type
  * @return item
  * @throws QueryException query exception
  */
 private Item toItem(final Expr ex, final QueryContext qc, final Type type) throws QueryException {
   return checkNoEmpty(ex.item(qc, info), type);
 }
Esempio n. 4
0
 /**
  * Checks if the specified expression yields a node. Returns the boolean or throws an exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return node
  * @throws QueryException query exception
  */
 protected final ANode toNode(final Expr ex, final QueryContext qc) throws QueryException {
   return toNode(checkNoEmpty(ex.item(qc, info), NodeType.NOD));
 }
Esempio n. 5
0
 /**
  * Checks if the specified expression yields a node or {@code null}. Returns the node, {@code
  * null}, or throws an exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return node or {@code null}
  * @throws QueryException query exception
  */
 protected final ANode toEmptyNode(final Expr ex, final QueryContext qc) throws QueryException {
   final Item it = ex.item(qc, info);
   return it == null ? null : toNode(it);
 }
Esempio n. 6
0
 /**
  * Checks if the specified expression yields a string or empty sequence. 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[] checkEStr(final Expr e, final QueryContext ctx) throws QueryException {
   return checkEStr(e.item(ctx, input));
 }
Esempio n. 7
0
 /**
  * Checks if the specified expression yields a non-empty item.
  *
  * @param e expression to be evaluated
  * @param ctx query context
  * @return item
  * @throws QueryException query exception
  */
 public final Item checkItem(final Expr e, final QueryContext ctx) throws QueryException {
   return checkEmpty(e.item(ctx, input));
 }
Esempio n. 8
0
 /**
  * Checks if the specified expression is an integer. Returns a token representation or an
  * exception.
  *
  * @param e expression to be checked
  * @param ctx query context
  * @return integer value
  * @throws QueryException query exception
  */
 public final long checkItr(final Expr e, final QueryContext ctx) throws QueryException {
   return checkItr(checkNoEmpty(e.item(ctx, input), AtomType.ITR));
 }
Esempio n. 9
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);
  }
Esempio n. 10
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);
  }