Example #1
0
  EntryResult[] queryIn(Index index) throws IOException {
    char[] key = this.selector; // can be null
    int matchRule = getMatchRule();

    switch (getMatchMode()) {
      case R_EXACT_MATCH:
        if (this.isCamelCase) break;
        if (this.selector != null && this.parameterCount >= 0 && !this.varargs)
          key = createIndexKey(this.selector, this.parameterCount);
        else { // do a prefix query with the selector
          matchRule &= ~R_EXACT_MATCH;
          matchRule |= R_PREFIX_MATCH;
        }
        break;
      case R_PREFIX_MATCH:
        // do a prefix query with the selector
        break;
      case R_PATTERN_MATCH:
        if (this.parameterCount >= 0 && !this.varargs)
          key =
              createIndexKey(this.selector == null ? ONE_STAR : this.selector, this.parameterCount);
        else if (this.selector != null && this.selector[this.selector.length - 1] != '*')
          key = CharOperation.concat(this.selector, ONE_STAR, SEPARATOR);
        // else do a pattern query with just the selector
        break;
      case R_REGEXP_MATCH:
        // TODO (frederic) implement regular expression match
        break;
    }

    return index.query(
        getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
  }
  public boolean execute(IProgressMonitor progressMonitor) {

    if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;

    /* ensure no concurrent write access to index */
    Index index =
        this.manager.getIndex(
            this.containerPath, true, /*reuse index file*/ false /*create if none*/);
    if (index == null) return true;
    ReadWriteMonitor monitor = index.monitor;
    if (monitor == null) return true; // index got deleted since acquired

    try {
      monitor.enterWrite(); // ask permission to write
      index.remove(resourceName);
    } finally {
      monitor.exitWrite(); // free write lock
    }
    return true;
  }