aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/domain/SearchCritera.java
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-02-01 11:43:12 -0800
committerScott Jackson <daneren2005@gmail.com>2016-02-01 11:43:12 -0800
commitd93a8939cf7d327ce6f82b7c093a18f3bd5377ad (patch)
tree67fd09339bfb34b72894ecc144b05e089d826c50 /app/src/main/java/github/daneren2005/dsub/domain/SearchCritera.java
parentb0a9bed5112dd3cd5e1cbb6b0ec9132d59fe7ef2 (diff)
downloaddsub-d93a8939cf7d327ce6f82b7c093a18f3bd5377ad.tar.gz
dsub-d93a8939cf7d327ce6f82b7c093a18f3bd5377ad.tar.bz2
dsub-d93a8939cf7d327ce6f82b7c093a18f3bd5377ad.zip
Fix indentions to use tabs
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/domain/SearchCritera.java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/domain/SearchCritera.java125
1 files changed, 63 insertions, 62 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/domain/SearchCritera.java b/app/src/main/java/github/daneren2005/dsub/domain/SearchCritera.java
index 12c641f2..ed2400ef 100644
--- a/app/src/main/java/github/daneren2005/dsub/domain/SearchCritera.java
+++ b/app/src/main/java/github/daneren2005/dsub/domain/SearchCritera.java
@@ -27,66 +27,67 @@ import java.util.regex.Pattern;
*/
public class SearchCritera {
- private final String query;
- private final int artistCount;
- private final int albumCount;
- private final int songCount;
- private Pattern pattern;
-
- public SearchCritera(String query, int artistCount, int albumCount, int songCount) {
- this.query = query;
- this.artistCount = artistCount;
- this.albumCount = albumCount;
- this.songCount = songCount;
- }
-
- public String getQuery() {
- return query;
- }
-
- public int getArtistCount() {
- return artistCount;
- }
-
- public int getAlbumCount() {
- return albumCount;
- }
-
- public int getSongCount() {
- return songCount;
- }
-
- /**
- * Returns and caches a pattern instance that can be used to check if a
- * string matches the query.
- */
- public Pattern getPattern() {
-
- // If the pattern wasn't already cached, create a new regular expression
- // from the search string :
- // * Surround the search string with ".*" (match anything)
- // * Replace spaces and wildcard '*' characters with ".*"
- // * All other characters are properly quoted
- if (this.pattern == null) {
- String regex = ".*";
- String currentPart = "";
- for (int i = 0; i < query.length(); i++) {
- char c = query.charAt(i);
- if (c == '*' || c == ' ') {
- regex += Pattern.quote(currentPart);
- regex += ".*";
- currentPart = "";
- } else {
- currentPart += c;
- }
- }
- if (currentPart.length() > 0) {
- regex += Pattern.quote(currentPart);
- }
- regex += ".*";
- this.pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
- }
-
- return this.pattern;
- }
+ private final String query;
+ private final int artistCount;
+ private final int albumCount;
+ private final int songCount;
+ private Pattern pattern;
+
+ public SearchCritera(String query, int artistCount, int albumCount, int songCount) {
+ this.query = query;
+ this.artistCount = artistCount;
+ this.albumCount = albumCount;
+ this.songCount = songCount;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public int getArtistCount() {
+ return artistCount;
+ }
+
+ public int getAlbumCount() {
+ return albumCount;
+ }
+
+ public int getSongCount() {
+ return songCount;
+ }
+
+ /**
+ * Returns and caches a pattern instance that can be used to check if a
+ * string matches the query.
+ */
+ public Pattern getPattern() {
+
+ // If the pattern wasn't already cached, create a new regular expression
+ // from the search string :
+ // * Surround the search string with ".*" (match anything)
+ // * Replace spaces and wildcard '*' characters with ".*"
+ // * All other characters are properly quoted
+ if (this.pattern == null) {
+ String regex = ".*";
+ String currentPart = "";
+ for (int i = 0; i < query.length(); i++) {
+ char c = query.charAt(i);
+ if (c == '*' || c == ' ') {
+ regex += Pattern.quote(currentPart);
+ regex += ".*";
+ currentPart = "";
+ } else {
+ currentPart += c;
+ }
+ }
+ if (currentPart.length() > 0) {
+ regex += Pattern.quote(currentPart);
+ }
+
+ regex += ".*";
+ this.pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
+ }
+
+ return this.pattern;
+ }
}