コード例 #1
0
ファイル: PXML.java プロジェクト: akaIDIOT/PXML-BaseX
  /**
   * Combines all conditions into a single string keeping only the unique conditions. The result
   * need not be consistent.
   *
   * @param existing A string containing conditions.
   * @param additional A BaseX Value containing additional conditions.
   * @return A single string containing conditions without duplicates.
   */
  @Requires(Permission.NONE)
  @Deterministic
  public String combine(Str existing, Value additional) {
    try {
      // create a condition 'container'
      Set<String> result = new HashSet<String>();

      // store the existing conditions
      for (Condition condition : new ConditionGenerator(existing.toJava())) {
        result.add(condition.toString());
      }

      // read all the additional conditions from the sequence.
      for (Item item : additional) {
        // a single item in the sequence might contain multiple conditions
        for (Condition condition : new ConditionGenerator(item.toJava().toString())) {
          result.add(condition.toString());
        }
      }

      // join the resulting set on a space
      return CollectionUtils.join(result, " ");
    } catch (QueryException e) {
      // TODO: submit message to BaseX logging (or declare thrown?)
      System.err.println("error combining descriptor values: " + e.getMessage());
      return "";
    }
  }
コード例 #2
0
ファイル: OutFormat.java プロジェクト: james-jw/basex
 @Override
 public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
   final String form = string(toToken(exprs[0], qc));
   final int es = exprs.length;
   final Object[] args = new Object[es - 1];
   for (int e = 1; e < es; e++) {
     final Item it = exprs[e].item(qc, info);
     args[e - 1] = it == null ? null : it.type.isUntyped() ? string(it.string(info)) : it.toJava();
   }
   try {
     return Str.get(String.format(form, args));
   } catch (final RuntimeException ex) {
     throw ERRFORMAT_X_X.get(info, Util.className(ex), ex);
   }
 }