Esempio n. 1
0
 @Override
 public Iter iter(final QueryContext qc) throws QueryException {
   final Value seq = qc.value(ts);
   for (final TypeCase tc : cases) {
     final Iter iter = tc.iter(qc, seq);
     if (iter != null) return iter;
   }
   // will never happen
   throw Util.notExpected();
 }
Esempio n. 2
0
 /**
  * Adds parameters from the passed on request body.
  *
  * @param body request body
  * @param params map parameters
  */
 private static void addParams(final String body, final Map<String, String[]> params) {
   for (final String nv : body.split("&")) {
     final String[] parts = nv.split("=", 2);
     if (parts.length < 2) continue;
     try {
       params.put(parts[0], new String[] {URLDecoder.decode(parts[1], Token.UTF8)});
     } catch (final Exception ex) {
       Util.notexpected(ex);
     }
   }
 }
Esempio n. 3
0
 /**
  * Returns the color for the specified string or {@code null}.
  *
  * @param string string string
  * @return color
  */
 static String color(final byte[] string) {
   for (final Object[] color : COLORS) {
     final int cl = color.length;
     for (int c = 1; c < cl; c++) {
       final Object o = color[c];
       final byte[] col =
           o instanceof byte[]
               ? (byte[]) o
               : Token.token(o instanceof Class ? Util.className((Class<?>) o) : o.toString());
       if (Token.eq(col, string)) return color[0].toString();
     }
   }
   return null;
 }
Esempio n. 4
0
 /**
  * Creates an exception with the specified message.
  *
  * @param msg message
  * @param ext error extension
  * @return exception
  * @throws QueryException query exception
  */
 QueryException error(final String msg, final Object... ext) throws QueryException {
   throw new QueryException(function.info, Err.BASX_RESTXQ, Util.info(msg, ext));
 }