Exemple #1
0
  /**
   * Returns an exception string for a wrong key.
   *
   * @param key property key
   * @param found found value
   * @param allowed allowed values
   * @return exception
   * @throws SerializerException serializer exception
   */
  public static SerializerException error(
      final Object key, final String found, final String... allowed) throws SerializerException {

    final TokenBuilder tb = new TokenBuilder();
    tb.addExt(SERVAL, key, allowed[0]);
    for (int a = 1; a < allowed.length; ++a) tb.addExt(SERVAL2, allowed[a]);
    tb.addExt(SERVAL3, found);
    throw SERANY.thrwSerial(tb);
  }
Exemple #2
0
 /**
  * Sends an event to the registered sessions.
  *
  * @param ctx query context
  * @return event result
  * @throws QueryException query exception
  */
 private Item event(final QueryContext ctx) throws QueryException {
   final byte[] name = checkStr(expr[0], ctx);
   final ArrayOutput ao = new ArrayOutput();
   try {
     // run serialization
     final Serializer ser = Serializer.get(ao, ctx.serProp(true));
     final ValueIter ir = ctx.value(expr[1]).iter();
     for (Item it; (it = ir.next()) != null; ) it.serialize(ser);
     ser.close();
   } catch (final SerializerException ex) {
     throw ex.getCause(input);
   } catch (final IOException ex) {
     SERANY.thrw(input, ex);
   }
   // throw exception if event is unknown
   if (!ctx.context.events.notify(ctx.context, name, ao.toArray())) {
     NOEVENT.thrw(input, name);
   }
   return null;
 }