Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ArrayList<Article> searchArticleOr(String search) {
- ArrayList<Article> result = new ArrayList<Article> ();
- ArrayList<Article> tmp = new ArrayList<Article>(showArticles());
- Iterator<Article> i = tmp.iterator();
- while (i.hasNext()) {
- Article tmpItem = (i.next());
- String[] title = tmpItem.getTitle().toLowerCase().split("\\ ");
- String[] descr = tmpItem.getDescription().toLowerCase().split("\\ ");
- String[] searchOr = search.toLowerCase().split("\\ ");
- for (int k = 0; k < searchOr.length; k++) {
- for (int j = 0; j < title.length; j++) {
- if (title[j].indexOf(searchOr[k]) >= 0) {
- if (result.contains(tmpItem) == false)
- result.add(tmpItem);
- }
- }
- for (int j = 0; j < descr.length; j++) {
- if (descr[j].indexOf(searchOr[k]) >= 0) {
- if (result.contains(tmpItem) == false)
- result.add(tmpItem);
- }
- }
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement