1 19 20 package org.openidex.search; 21 22 28 public final class SearchPattern { 29 30 31 private String searchExpression; 32 33 34 private boolean wholeWords; 35 36 37 private boolean matchCase; 38 39 40 private boolean regExp; 41 42 48 private SearchPattern(String searchExpression, boolean wholeWords, 49 boolean matchCase, boolean regExp) { 50 this.searchExpression = searchExpression; 51 this.wholeWords = wholeWords; 52 this.matchCase = matchCase; 53 this.regExp = regExp; 54 } 55 56 63 public static SearchPattern create(String searchExpression, boolean wholeWords, 64 boolean matchCase, boolean regExp){ 65 return new SearchPattern(searchExpression, wholeWords, matchCase, regExp); 66 } 67 68 69 public String getSearchExpression(){ 70 return searchExpression; 71 } 72 73 74 public boolean isWholeWords(){ 75 return wholeWords; 76 } 77 78 79 public boolean isMatchCase(){ 80 return matchCase; 81 } 82 83 84 public boolean isRegExp(){ 85 return regExp; 86 } 87 88 public boolean equals(Object obj){ 89 if (!(obj instanceof SearchPattern)){ 90 return false; 91 } 92 SearchPattern sp = (SearchPattern)obj; 93 return (this.searchExpression.equals(sp.getSearchExpression()) && 94 this.wholeWords == sp.isWholeWords() && 95 this.matchCase == sp.isMatchCase() && 96 this.regExp == sp.isRegExp()); 97 } 98 99 public int hashCode() { 100 int result = 17; 101 result = 37*result + (this.wholeWords ? 1:0); 102 result = 37*result + (this.matchCase ? 1:0); 103 result = 37*result + (this.regExp ? 1:0); 104 result = 37*result + this.searchExpression.hashCode(); 105 return result; 106 } 107 } 108 | Popular Tags |