Java List Null Empty getSearchTermIndexLocationsOrNull(final List pageWords, final String searchTerm)

Here you can find the source of getSearchTermIndexLocationsOrNull(final List pageWords, final String searchTerm)

Description

get Search Term Index Locations Or Null

License

Open Source License

Declaration

public static List<Integer> getSearchTermIndexLocationsOrNull(final List<String> pageWords,
            final String searchTerm) 

Method Source Code


//package com.java2s;
//License from project: MIT License 

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<Integer> getSearchTermIndexLocationsOrNull(final List<String> pageWords,
            final String searchTerm) {
        String[] tokanizedSearchTerm = getTokanizedSearchTerm(searchTerm.toUpperCase());
        List<Integer> indexLocations = new ArrayList<Integer>();
        for (int i = 0; i < pageWords.size(); i++) {
            for (String token : tokanizedSearchTerm) {
                if (token.equals(pageWords.get(i))) {
                    indexLocations.add(i);
                }//  w w w.  ja  v a2s .  com
            }
        }
        return indexLocations;
    }

    public static String[] getTokanizedSearchTerm(final String searchTerm) {
        return searchTerm.split(" ");
    }
}

Related

  1. getListIgnoringNulls(T[] items)
  2. getNonNull(List list)
  3. getNotNullCount(List list)
  4. getNotNullId(final List idList)
  5. getScreen_BL_NONNULL(List searchableFields)
  6. getStringAsList(String input, String regexSplitter, boolean ignoreEmptyTokens)
  7. immutableListOfType(List list, Class type, boolean nullOk)
  8. isAllElementsNull(List list)
  9. isArrayEmpty(List objList)

  10. HOME | Copyright © www.java2s.com 2016