Beispiel #1
0
 /**
  * Checks if the specified expression yields an item of the specified atomic type. Returns the
  * item or throws an exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @param type type to be checked
  * @return item
  * @throws QueryException query exception
  */
 protected Item checkAtomic(final Expr ex, final QueryContext qc, final Type type)
     throws QueryException {
   return checkType(ex.atomItem(qc, info), type);
 }
Beispiel #2
0
 /**
  * Checks if the specified expression yields a string or binary item.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return byte array
  * @throws QueryException query exception
  */
 protected final byte[] toBytes(final Expr ex, final QueryContext qc) throws QueryException {
   return toBytes(ex.atomItem(qc, info));
 }
Beispiel #3
0
 /**
  * Checks if the specified expression yields a QName. Returns the item or throws an exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @param empty allow empty result
  * @return QNm item
  * @throws QueryException query exception
  */
 protected final QNm toQNm(final Expr ex, final QueryContext qc, final boolean empty)
     throws QueryException {
   return toQNm(ex.atomItem(qc, info), empty);
 }
Beispiel #4
0
 /**
  * Checks if the evaluated expression yields a non-empty item. Returns the atomized item or throws
  * an exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return atomized item
  * @throws QueryException query exception
  */
 protected final Item toAtomItem(final Expr ex, final QueryContext qc) throws QueryException {
   return checkNoEmpty(ex.atomItem(qc, info));
 }
Beispiel #5
0
 /**
  * Checks if the specified expression yields a binary item. Returns the binary item or throws an
  * exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return binary item
  * @throws QueryException query exception
  */
 protected final Bin toBin(final Expr ex, final QueryContext qc) throws QueryException {
   return toBin(ex.atomItem(qc, info));
 }
Beispiel #6
0
 /**
  * Checks if the specified expression yields a float. Returns the float or throws an exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return float
  * @throws QueryException query exception
  */
 protected final float toFloat(final Expr ex, final QueryContext qc) throws QueryException {
   final Item it = ex.atomItem(qc, info);
   if (checkNoEmpty(it, AtomType.FLT).type.isNumberOrUntyped()) return it.flt(info);
   throw numberError(this, it);
 }
Beispiel #7
0
 /**
  * Checks if the specified expression yields a number or {@code null}. Returns the number, {@code
  * null}, or throws an exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return double
  * @throws QueryException query exception
  */
 protected final ANum toNumber(final Expr ex, final QueryContext qc) throws QueryException {
   final Item it = ex.atomItem(qc, info);
   return it == null ? null : toNumber(it);
 }
Beispiel #8
0
 /**
  * Checks if the specified expression yields a double. Returns the double or throws an exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return double
  * @throws QueryException query exception
  */
 protected final double toDouble(final Expr ex, final QueryContext qc) throws QueryException {
   return toDouble(ex.atomItem(qc, info));
 }
Beispiel #9
0
 /**
  * Checks if the specified expression yields a string or an empty sequence. Returns a value as
  * token or throws an exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return token (empty string if result is an empty sequence)
  * @throws QueryException query exception
  */
 protected final byte[] toEmptyToken(final Expr ex, final QueryContext qc) throws QueryException {
   final Item it = ex.atomItem(qc, info);
   return it == null ? EMPTY : toToken(it);
 }
Beispiel #10
0
 /**
  * Checks if the specified expression yields a string. Returns a value as token or throws an
  * exception.
  *
  * @param ex expression to be evaluated
  * @param qc query context
  * @return token
  * @throws QueryException query exception
  */
 protected final byte[] toToken(final Expr ex, final QueryContext qc) throws QueryException {
   final Item it = ex.atomItem(qc, info);
   if (it == null) throw EMPTYFOUND_X.get(info, AtomType.STR);
   return toToken(it);
 }