Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public ArrayList<Article> searchArticleOr(String search) {
  2. ArrayList<Article> result = new ArrayList<Article> ();
  3. ArrayList<Article> tmp = new ArrayList<Article>(showArticles());
  4. Iterator<Article> i = tmp.iterator();
  5. while (i.hasNext()) {
  6. Article tmpItem = (i.next());
  7. String[] title = tmpItem.getTitle().toLowerCase().split("\\ ");
  8. String[] descr = tmpItem.getDescription().toLowerCase().split("\\ ");
  9. String[] searchOr = search.toLowerCase().split("\\ ");
  10.  
  11. for (int k = 0; k < searchOr.length; k++) {
  12. for (int j = 0; j < title.length; j++) {
  13. if (title[j].indexOf(searchOr[k]) >= 0) {
  14. if (result.contains(tmpItem) == false)
  15. result.add(tmpItem);
  16. }
  17. }
  18. for (int j = 0; j < descr.length; j++) {
  19. if (descr[j].indexOf(searchOr[k]) >= 0) {
  20. if (result.contains(tmpItem) == false)
  21. result.add(tmpItem);
  22. }
  23. }
  24. }
  25. }
  26. return result;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement