Performs a search and returns the match, or null if no match was found
or more than one match was found.
@since 1.527
559
public static SuggestedItem find(SearchIndex index, String query, SearchableModelObject searchContext) {
        List<SuggestedItem> r = find(Mode.FIND, index, query, searchContext);
        if(r.isEmpty()){ 
            return null;
        }
        else if(1==r.size()){
            return r.get(0);
        }
        else  {
            // we have more than one suggested item, so return the item who's url
            // contains the query as this is probably the job's name
            return findClosestSuggestedItem(r, query);
        }
                    
    }
1135401
final public boolean exists() {
		final Model m = Query.one(
				getClass(),
				String.format("SELECT * FROM %s WHERE %s LIMIT 1",
						Utils.getTableName(getClass()),
						Utils.getWhereStatement(this))).get();
		return m != null;
	}
69864
public TrieNode matchPredictor(String search) {
    TrieNode cursor = matchEnd(search);
    if (cursor.getNumberOfChildren() > 0) {
      return cursor;
    }
    String string = cursor.getString();
    if (string.isEmpty()) return null;
    return matchPredictor(string.substring(1));
  }
546118
@Override
    public Status match(int cc)
    {
        int highest = -1;
        Iterator<Matcher> iterator = active.iterator();
        while (iterator.hasNext())
        {
            Matcher matcher = iterator.next();
            Status s = matcher.match(cc);
            highest = Math.max(highest, s.ordinal());
            switch (s)
            {
                case Match:
                    lastMatched = matcher;
                    clear();
                    return s;
                case WillMatch:
                    lastMatched = matcher;
                    return s;
                case Error:
                    iterator.remove();
                    break;
            }
        }
        if (active.isEmpty())
        {
            clear();
            return Status.Error;
        }
        return Status.values()[highest];
    }
196341
public function getMatch($key)
    {
        if (!$this->lastMatchResult) {
            $this->throwException(
                "Failed to get match $key: No match result found. Use match first"
            );
        }

        return isset($this->lastMatchResult[$key])
            ? $this->lastMatchResult[$key]
            : null;
    }
146934
@Override
	public boolean satisfies(Match match, int... ind)
	{
		assert ind.length == 2;

		return (match.get(ind[0]) == match.get(ind[1])) == equals;
	}
60941
@Override
    public int matches(Replaceable text,
                       int[] offset,
                       int limit,
                       boolean incremental) {
        // Note (1): We process text in 16-bit code units, rather than
        // 32-bit code points.  This works because stand-ins are
        // always in the BMP and because we are doing a literal match
        // operation, which can be done 16-bits at a time.
        int i;
        int[] cursor = new int[] { offset[0] };
        if (limit < cursor[0]) {
            // Match in the reverse direction
            for (i=pattern.length()-1; i>=0; --i) {
                char keyChar = pattern.charAt(i); // OK; see note (1) above
                UnicodeMatcher subm = data.lookupMatcher(keyChar);
                if (subm == null) {
                    if (cursor[0] > limit &&
                        keyChar == text.charAt(cursor[0])) { // OK; see note (1) above
                        --cursor[0];
                    } else {
                        return U_MISMATCH;
                    }
                } else {
                    int m =
                        subm.matches(text, cursor, limit, incremental);
                    if (m != U_MATCH) {
                        return m;
                    }
                }
            }
            // Record the match position, but adjust for a normal
            // forward start, limit, and only if a prior match does not
            // exist -- we want the rightmost match.
            if (matchStart < 0) {
                matchStart = cursor[0]+1;
                matchLimit = offset[0]+1;
            }
        } else {
            for (i=0; i<pattern.length(); ++i) {
                if (incremental && cursor[0] == limit) {
                    // We've reached the context limit without a mismatch and
                    // without completing our match.
                    return U_PARTIAL_MATCH;
                }
                char keyChar = pattern.charAt(i); // OK; see note (1) above
                UnicodeMatcher subm = data.lookupMatcher(keyChar);
                if (subm == null) {
                    // Don't need the cursor < limit check if
                    // incremental is true (because it's done above); do need
                    // it otherwise.
                    if (cursor[0] < limit &&
                        keyChar == text.charAt(cursor[0])) { // OK; see note (1) above
                        ++cursor[0];
                    } else {
                        return U_MISMATCH;
                    }
                } else {
                    int m =
                        subm.matches(text, cursor, limit, incremental);
                    if (m != U_MATCH) {
                        return m;
                    }
                }
            }
            // Record the match position
            matchStart = offset[0];
            matchLimit = cursor[0];
        }

        offset[0] = cursor[0];
        return U_MATCH;
    }
597893
public boolean matches(String uri) {
		if (uri == null) {
			return false;
		}
		Matcher matcher = this.matchPattern.matcher(uri);
		return matcher.matches();
	}
589943
public boolean isSingleResult() {
		if (result == null) {
			return false;
		} else {
			if (singleResult == null) {
				if (result.size() == 1 && result.values().iterator().next().size() == 1) {
					singleResult = true;
				} else {
					singleResult = false;
				}
			}
			return singleResult;
		}
	}
1058119
protected Boolean getSearchForEmptyQuery() {

        Boolean isSearchForEmptyQuery = parseOptionalBooleanValue(m_configObject, JSON_KEY_SEARCH_FOR_EMPTY_QUERY);
        return (isSearchForEmptyQuery == null) && (null != m_baseConfig)
        ? Boolean.valueOf(m_baseConfig.getGeneralConfig().getSearchForEmptyQueryParam())
        : isSearchForEmptyQuery;
    }
172923
protected TimeoutMatch findTimeout(Match matches[]) {
        TimeoutMatch ourTimeout = null;
        for (int i = 0; i < matches.length; i++) {
            if (matches[i] instanceof TimeoutMatch)
                ourTimeout = (TimeoutMatch) matches[i];
        }
        /* TODO: candidate for removal?
        if( ourTimeout == null ) {
            // Have to create our own
            ourTimeout = new TimeoutMatch(null);
        }
         */
        return ourTimeout;
    }
437462
public function match()
    {
        // if forceSlash is ON, and there is no trailing slash on current request
        if ($this->forceSlash && !$this->hasTrailingSlash($this->uriRelative)) {
            $this->forceSlash();
        }
        // Find control for current request, first with exact matching, then with variable matching
        if ($this->matchExact() || $this->matchVariable()) {
            return $this->control; // Match found
        }

        return null; // No match found
    }
892344
def match(pattern_element)
    @num_match_attempts += 1
    return :no_pattern_element unless pattern_element
    return :skipped if pattern_element.delimiter &&
      (
      if last_match
        last_match.delimiter       # don't match two delimiters in a row
      else
        @num_match_attempts > 1   # don't match a delimiter as the first element unless this is the first match attempt
      end
      )

    if result = pattern_element.parse(self)
      add_match result, pattern_element.name # success, but don't keep EmptyNodes
    end
  end
878166
private static boolean check(String data, Pattern pattern) {
        if (StringUtils.isEmpty(data)) {
            return false;
        }
        Matcher matcher = pattern.matcher(data);
        return matcher.matches();
    }
923744
public MatchIterator findAll(final int options) {
        //setPosition(0);
        return new MatchIterator() {
            private boolean checked = false;
            private boolean hasMore = false;

            @Override
            public boolean hasNext() {
                if (!checked) check();
                return hasMore;
            }

            @Override
            public MatchResult next() {
                if (!checked) check();
                if (!hasMore) throw new NoSuchElementException();
                checked = false;
                return Matcher.this;
            }
            @Override
            public void remove() {
                throw new UnsupportedOperationException("remove() not supported on MatchIterator");
            }

            private void check() {
                hasMore = find(options);
                checked = true;
            }

            @Override
            public int count() {
                if (!checked) check();
                if (!hasMore) return 0;
                int c = 1;
                while (find(options)) c++;
                checked = false;
                return c;
            }

            @Override
            public ArrayList<String> asList() {
                if (!checked) check();
                ArrayList<String> found = new ArrayList<String>(16);
                if (!hasMore) return found;
                found.add(Matcher.this.group());
                while (find(options)) found.add(Matcher.this.group());
                checked = false;
                return found;
            }
        };
    }
681532
@Override
    public boolean matches(TargetProperties targetConatiner, IBond targetBond) {
        if (this.smartQueryBond != null) {
            return smartQueryBond.matches(targetBond);
        } else {
            if (!isBondMatchFlag()) {
                return true;
            }
            if (isBondMatchFlag() && isBondTypeMatch(targetBond)) {
                return true;
            }
            if (isBondMatchFlag() && this.unsaturation == getUnsaturation(targetConatiner, targetBond)) {
                return true;
            }
        }
        return false;
    }
104957
public static boolean matches(Pattern patternMatcher, Object... elements)
    {
        if (patternMatcher == null) {
            return true;
        }

        for (Object element : elements) {
            if (matches(patternMatcher, element)) {
                return true;
            }
        }

        return false;
    }