示例#1
0
 /**
  * Makes a name distinct from other names which have already been used, adds it to the list, and
  * returns it.
  *
  * @param name Suggested name, may not be unique
  * @param nameList Collection of names already used
  * @param suggester Base for name when input name is null
  * @return Unique name
  */
 public static String uniquify(String name, Set<String> nameList, Suggester suggester) {
   if (name != null) {
     if (nameList.add(name)) {
       return name;
     }
   }
   final String originalName = name;
   for (int j = 0; ; j++) {
     name = suggester.apply(originalName, j, nameList.size());
     if (nameList.add(name)) {
       return name;
     }
   }
 }
示例#2
0
  /**
   * Tests whether we can support the usage of dynamic parameters in a given SargExpr.
   *
   * @param sargExpr expression to test
   * @return true if supported
   */
  private boolean testDynamicParamSupport(SargExpr sargExpr) {
    // NOTE jvs 18-Mar-2006: we don't currently support boolean operators
    // over predicates on dynamic parameters.  The reason is that we
    // evaluate sarg expressions at prepare time rather than at execution
    // time.  To support them, we would need a way to defer evaluation
    // until execution time (Broadbase used to do that).

    Set<RexDynamicParam> dynamicParams = new HashSet<RexDynamicParam>();
    sargExpr.collectDynamicParams(dynamicParams);
    if (dynamicParams.isEmpty()) {
      // no dynamic params, no problem
      return true;
    }
    if (sargExpr instanceof SargIntervalExpr) {
      // We can support a single point or ray, which is the
      // most that would have been generated by the time this is
      // called.  Should probably assert that.
      return true;
    }

    // Anything else is unsupported.
    return false;
  }