Beispiel #1
0
 /**
  * Parses and returns the specified keyword.
  *
  * @param key token to be parsed
  * @param cmd referring command; if specified, the keyword is mandatory
  * @return result of check
  * @throws QueryException query exception
  */
 private boolean key(final String key, final Cmd cmd) throws QueryException {
   consumeWS();
   final int p = parser.pos;
   final boolean ok =
       (parser.consume(key) || parser.consume(key.toLowerCase(Locale.ENGLISH)))
           && (parser.curr(0) || ws(parser.curr()));
   if (!ok) {
     parser.pos = p;
     if (cmd != null) throw help(null, cmd);
   }
   return ok;
 }
Beispiel #2
0
 /**
  * Parses and returns an xquery expression.
  *
  * @param cmd referring command; if specified, the result must not be empty
  * @return path
  * @throws QueryException query exception
  */
 private String xquery(final Cmd cmd) throws QueryException {
   consumeWS();
   final StringBuilder sb = new StringBuilder();
   if (!eoc()) {
     final QueryContext qc = new QueryContext(ctx);
     try {
       final QueryParser p = new QueryParser(parser.input, null, qc, null);
       p.pos = parser.pos;
       p.parseMain();
       sb.append(parser.input.substring(parser.pos, p.pos));
       parser.pos = p.pos;
     } finally {
       qc.close();
     }
   }
   return finish(sb, cmd);
 }