コード例 #1
0
ファイル: RESTCmd.java プロジェクト: LukasK/basex
  /**
   * Parses and sets a single database option.
   *
   * @param session REST session
   * @param param current parameter
   * @param force force execution
   * @return success flag, indicates if value was found
   * @throws BaseXException database exception
   */
  static boolean parseOption(
      final RESTSession session, final Entry<String, String[]> param, final boolean force)
      throws BaseXException {

    final String key = param.getKey().toUpperCase(Locale.ENGLISH);
    final MainOptions options = session.context.options;
    final boolean found = options.option(key) != null;
    if (found || force) options.assign(key, param.getValue()[0]);
    return found;
  }
コード例 #2
0
  /**
   * Parses a string as XML and adds the resulting nodes to the specified parent.
   *
   * @param value string to parse
   * @param elem element
   */
  public static void add(final byte[] value, final FElem elem) {

    try {
      final Parser parser = new XMLParser(new IOContent(value), MainOptions.get(), true);
      for (final ANode node : new DBNode(parser).children()) elem.add(node.copy());
    } catch (final IOException ex) {
      // fallback: add string representation
      Util.debug(ex);
      elem.add(value);
    }
  }