81 * @param includeContent |
81 * @param includeContent |
82 * The include list specified by the user |
82 * The include list specified by the user |
83 * @return |
83 * @return |
84 * A list of regular expression patterns {@link Pattern} |
84 * A list of regular expression patterns {@link Pattern} |
85 */ |
85 */ |
86 public List<Pattern> getIncludePatterns(List includeContent ) { |
86 public List<Pattern> getIncludePatterns(List<String> includeContent ) { |
87 List<Pattern> includeRegexList = new ArrayList<Pattern>(); |
87 List<Pattern> includeRegexList = new ArrayList<Pattern>(); |
88 for (int i = 0 ; i < includeContent.size(); i ++){ |
88 for (String includes : includeContent) { |
89 String includes = (String)includeContent.get(i); |
|
90 String regex = convertToRegex(includes); |
89 String regex = convertToRegex(includes); |
91 Pattern pattern = Pattern.compile(regex); |
90 Pattern pattern = Pattern.compile(regex); |
92 includeRegexList.add(pattern); |
91 includeRegexList.add(pattern); |
93 } |
92 } |
94 return includeRegexList; |
93 return includeRegexList; |
101 * @param excludeContent |
100 * @param excludeContent |
102 * The exclude list specified by the user |
101 * The exclude list specified by the user |
103 * @return |
102 * @return |
104 * A list of regular expression patterns {@link Pattern} |
103 * A list of regular expression patterns {@link Pattern} |
105 */ |
104 */ |
106 public List getExcludePatterns(List excludeContent ) { |
105 public List getExcludePatterns(List<String> excludeContent ) { |
107 List excludeRegexList = new ArrayList(); |
106 List<Pattern> excludeRegexList = new ArrayList<Pattern>(); |
108 for (int i = 0 ; i < excludeContent.size(); i ++){ |
107 for (String excludes : excludeContent) { |
109 String excludes = (String)excludeContent.get(i); |
|
110 String regex = convertToRegex(excludes); |
108 String regex = convertToRegex(excludes); |
111 Pattern pattern = Pattern.compile(regex); |
109 Pattern pattern = Pattern.compile(regex); |
112 excludeRegexList.add(pattern); |
110 excludeRegexList.add(pattern); |
113 } |
111 } |
114 return excludeRegexList; |
112 return excludeRegexList; |
124 char nc = ' '; |
122 char nc = ' '; |
125 if (pattern.length() >0 ) { |
123 if (pattern.length() >0 ) { |
126 |
124 |
127 for ( int i = 0 ; i < pattern.length(); i ++ ) { |
125 for ( int i = 0 ; i < pattern.length(); i ++ ) { |
128 char c = pattern.charAt(i); |
126 char c = pattern.charAt(i); |
129 int j = i; |
|
130 nc = ' '; |
127 nc = ' '; |
131 if ((j+1) != pattern.length()) { |
128 if ((i +1) != pattern.length()) { |
132 nc = pattern.charAt(j+1); |
129 nc = pattern.charAt(i +1); |
133 } |
130 } |
134 //escape single '.' |
131 //escape single '.' |
135 if ((c=='.') && ( nc !='.')){ |
132 if (c == '.' && nc != '.'){ |
136 regex.append('\\'); |
133 regex.append('\\'); |
137 regex.append('.'); |
134 regex.append('.'); |
138 //do not allow patterns like a..b |
135 //do not allow patterns like a..b |
139 } else if ((c=='.') && ( nc =='.')){ |
136 } else if (c == '.'){ |
140 continue; |
137 continue; |
141 // "**" gets replaced by ".*" |
138 // "**" gets replaced by ".*" |
142 } else if ((c=='*') && (nc == '*')) { |
139 } else if ((c=='*') && (nc == '*')) { |
143 regex.append(".*"); |
140 regex.append(".*"); |
144 break; |
141 break; |