/*
(non-Javadoc)

@see
PhoneNumberProvisioningManager#searchForNumbers(java.lang.String,
java.lang.String, java.util.regex.Pattern, boolean, boolean, boolean, boolean, int, int)
421402
@Override
    public List<PhoneNumber> searchForNumbers(String country, PhoneNumberSearchFilters listFilters) {
        Locale locale = new Locale("en",country);
        String iso3Country = locale.getISO3Country();
        if(logger.isDebugEnabled()) {
            logger.debug("searchPattern " + listFilters.getFilterPattern());
        }

        Client jerseyClient = Client.create();
        jerseyClient.addFilter(new HTTPBasicAuthFilter(username, password));

        WebResource webResource = jerseyClient.resource(searchURI);

        // https://developers.voxbone.com/docs/v3/inventory#path__didgroup.html
        webResource = webResource.queryParam(COUNTRY_CODE_PARAM,iso3Country);
//        Pattern filterPattern = listFilters.getFilterPattern();
//        if(filterPattern != null) {
//            webResource = webResource.queryParam("cityNamePattern" , filterPattern.toString());
//        }
        if(listFilters.getAreaCode() != null) {
            webResource = webResource.queryParam("areaCode", listFilters.getAreaCode());
        }
        if(listFilters.getInRateCenter() != null) {
            webResource = webResource.queryParam("rateCenter", listFilters.getInRateCenter());
        }
        if(listFilters.getSmsEnabled() != null) {
            webResource = webResource.queryParam("featureIds", "6");
        }
        if(listFilters.getFaxEnabled() != null) {
            webResource = webResource.queryParam("featureIds", "25");
        }
        if(listFilters.getRangeIndex() != -1) {
            webResource = webResource.queryParam(PAGE_NUMBER, "" + listFilters.getRangeIndex());
        } else {
            webResource = webResource.queryParam(PAGE_NUMBER, "0");
        }
        if(listFilters.getRangeSize() != -1) {
            webResource = webResource.queryParam(PAGE_SIZE, "" + listFilters.getRangeSize());
        } else {
            webResource = webResource.queryParam(PAGE_SIZE, "50");
        }
        ClientResponse clientResponse = webResource.accept(CONTENT_TYPE).type(CONTENT_TYPE)
                .get(ClientResponse.class);

        String response = clientResponse.getEntity(String.class);
        if(logger.isDebugEnabled())
            logger.debug("response " + response);

        JsonParser parser = new JsonParser();
        JsonObject jsonResponse = parser.parse(response).getAsJsonObject();

//        long count = jsonResponse.getAsJsonPrimitive("count").getAsLong();
//        if(logger.isDebugEnabled()) {
//            logger.debug("Number of numbers found : "+count);
//        }
        JsonArray voxboneNumbers = jsonResponse.getAsJsonArray("didGroups");
        final List<PhoneNumber> numbers = toAvailablePhoneNumbers(voxboneNumbers, listFilters);
        return numbers;
//        } else {
//            logger.warn("Couldn't reach uri for getting Phone Numbers. Response status was: "+response.getStatusLine().getStatusCode());
//        }
//
//        return new ArrayList<PhoneNumber>();
    }
1311976
public <T extends View> boolean searchFor(Set<T> uniqueViews, Class<T> viewClass, final int index) {
		ArrayList<T> allViews = RobotiumUtils.removeInvisibleViews(viewFetcher.getCurrentViews(viewClass, true));

		int uniqueViewsFound = (getNumberOfUniqueViews(uniqueViews, allViews));

		if(uniqueViewsFound > 0 && index < uniqueViewsFound) {
			return true;
		}

		if(uniqueViewsFound > 0 && index == 0) {
			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;
    }
1228741
@Override
    public EntityIdentifier[] searchForEntities(
            String query, IGroupConstants.SearchMethod method, Class type) throws GroupsException {
        Set allIds = new HashSet();

        for (Iterator services = getComponentServices().values().iterator(); services.hasNext(); ) {
            IIndividualGroupService service = (IIndividualGroupService) services.next();
            EntityIdentifier[] ids = service.searchForEntities(query, method, type);
            for (int i = 0; i < ids.length; i++) {
                allIds.add(ids[i]);
            }
        }
        return (EntityIdentifier[]) allIds.toArray(new EntityIdentifier[allIds.size()]);
    }
781883
@Override
	public boolean contains(Object elem) {
		if (elem == null) return false;
		if (elem instanceof Number) return contains(((Number)elem).intValue());
		return false;
	}
157292
@Override
	public boolean matchingNumbers(String number1, String number2) {
		boolean matching = AndroidContact.matchingNumbers(number1, number2);
		return matching;
	}
1034656
private NumberSelectionResult findByNumber(List<String> numberQueries,
            Sid sourceOrganizationSid, Sid destinationOrganizationSid, Set<SearchModifier> modifiers) {
        Boolean orgFiltered = false;
        NumberSelectionResult matchedNumber = new NumberSelectionResult(null, orgFiltered, null);
        int i = 0;
        while (matchedNumber.getNumber() == null && i < numberQueries.size()) {
            matchedNumber = findSingleNumber(numberQueries.get(i),
                    sourceOrganizationSid, destinationOrganizationSid, modifiers);
            //preserve the orgFiltered flag along the queries
            if (matchedNumber.getOrganizationFiltered()) {
                orgFiltered = true;
            }
            i = i + 1;
        }
        matchedNumber.setOrganizationFiltered(orgFiltered);
        return matchedNumber;
    }
359795
def search_next(self):
        

        pattern = self.get_selected_text() or self.__search_pattern
        if not pattern:
            return False

        return self.search(pattern, **{"case_sensitive": True,
                                       "whole_word": False,
                                       "regular_expressions": False,
                                       "backward_search": False,
                                       "wrap_around": True})
191164
public static List<AvailableNumber> searchLocal(final BandwidthClient client, final Map<String, Object>params) 
    																							throws Exception {
    	
        final String tollFreeUri = BandwidthConstants.AVAILABLE_NUMBERS_LOCAL_URI_PATH;
        final JSONArray array = toJSONArray(client.get(tollFreeUri, params));

        final List<AvailableNumber> numbers = new ArrayList<AvailableNumber>();
        for (final Object obj : array) {
            numbers.add(new AvailableNumber(client, (JSONObject) obj));
        }
        return numbers;
    }
397083
def search(self, string, default=None):
        """"""
        default = default if default else []
        result = [item[1] for item in self.container if item[0].search(string)]
        if self.ensure_mapping:
            assert len(result) < 2, "%s matches more than one pattern: %s" % (
                string,
                result,
            )
        return result if result else default
219057
def _number_finder(s, regex, numconv):
    """"""

    # Split.  If there are no splits, return now
    s = regex.split(s)
    if len(s) == 1:
        return tuple(s)

    # Now convert the numbers to numbers, and leave strings as strings
    s = remove_empty(s)
    for i in range(len(s)):
        try:
            s[i] = numconv(s[i])
        except ValueError:
            pass

    # If the list begins with a number, lead with an empty string.
    # This is used to get around the "unorderable types" issue.
    if not isinstance(s[0], six.string_types):
        return [''] + s
    else:
        return s
1286468
protected static boolean addMatchResult(int limit,
                                            List results,
                                            String pattern,
                                            Object value,
                                            int[] positions,
                                            int len)
    {
        int size = results.size();
        if (size < limit) {
            if (positions == null || len == 0) {
                positions = NO_POSITIONS;
            }
            else {
                int[] original = positions;
                positions = new int[len];
                for (int i=0; i<len; i++) {
                    positions[i] = original[i];
                }
            }
            results.add(new Result(pattern, value, positions));
            return size + 1 < limit;
        }
        else {
            return false;
        }
    }
79704
function findMinIndexValue(pageNumber, searchFor) {
	var lookupAttr = typeof searchFor === 'string' ? 'name' : 'token';
	var minIndexValue = null
	for (var i = 0; i < this.codePage[pageNumber].values.length; i++) {
		let index = searchFor.indexOf(this.codePage[pageNumber].values[i][lookupAttr])
		if ( index >= 0 &&
			(!minIndexValue || (index < minIndexValue.index))){
			minIndexValue = {index: index, value: this.codePage[pageNumber].values[i] }
		}
	}

	return minIndexValue
}
750976
public static int getNumberOfMatches(String regex, TextView view, Set<TextView> uniqueTextViews){
		if(view == null) {
			return uniqueTextViews.size();
		}
		
		Pattern pattern = null;
		try{
			pattern = Pattern.compile(regex);
		}catch(PatternSyntaxException e){
			pattern = Pattern.compile(regex, Pattern.LITERAL);
		}
		
		Matcher matcher = pattern.matcher(view.getText().toString());
		
		if (matcher.find()){
			uniqueTextViews.add(view);
		}
		
		if (view.getError() != null){
			matcher = pattern.matcher(view.getError().toString());
			if (matcher.find()){
				uniqueTextViews.add(view);
			}
		}	
		if (view.getText().toString().equals("") && view.getHint() != null){
			matcher = pattern.matcher(view.getHint().toString());
			if (matcher.find()){
				uniqueTextViews.add(view);
			}
		}	
		return uniqueTextViews.size();		
	}
1285268
@Override
    public Collection<MatchInfo> find(CharSequence text, int start, EnumSet<NameType> nameTypes) {
        if (text == null || text.length() == 0 || start < 0 || start >= text.length()) {
            throw new IllegalArgumentException("bad input text or range");
        }

        prepareFind();
        TZDBNameSearchHandler handler = new TZDBNameSearchHandler(nameTypes, getTargetRegion());
        TZDB_NAMES_TRIE.find(text, start, handler);
        return handler.getMatches();
    }
1282390
protected static boolean matchesOne(String str, Pattern... patterns) {
        for (Pattern pattern : patterns) {
            if (pattern.matcher(str).matches()) {
                return true;
            }
        }
        return false;
    }
781347
public final List<PhoneNumberData> getSuggstions(final String psearch, final int plimit) {
    return this.getSuggstions(psearch, plimit, Locale.ROOT);
  }