Lines 58-64
Link Here
|
58 |
* </pre></li> |
58 |
* </pre></li> |
59 |
* </ol> |
59 |
* </ol> |
60 |
* |
60 |
* |
61 |
* @param array the array that is concanated with the suffix character |
61 |
* @param array the array that is concatenated with the suffix character |
62 |
* @param suffix the suffix character |
62 |
* @param suffix the suffix character |
63 |
* @return the new array |
63 |
* @return the new array |
64 |
*/ |
64 |
*/ |
Lines 72-79
Link Here
|
72 |
} |
72 |
} |
73 |
|
73 |
|
74 |
/** |
74 |
/** |
75 |
* Append the given subarray to the target array starting at the given index in the target array. |
75 |
* Append the given sub-array to the target array starting at the given index in the target array. |
76 |
* The start of the subarray is inclusive, the end is exclusive. |
76 |
* The start of the sub-array is inclusive, the end is exclusive. |
77 |
* Answers a new target array if it needs to grow, otherwise answers the same target array. |
77 |
* Answers a new target array if it needs to grow, otherwise answers the same target array. |
78 |
* <br> |
78 |
* <br> |
79 |
* For example:<br> |
79 |
* For example:<br> |
Lines 180-197
Link Here
|
180 |
/** |
180 |
/** |
181 |
* Answers true if the pattern matches the given name using CamelCase rules, or false otherwise. |
181 |
* Answers true if the pattern matches the given name using CamelCase rules, or false otherwise. |
182 |
* char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. |
182 |
* char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. |
183 |
* <br> |
183 |
* <br><br> |
184 |
* CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. |
184 |
* CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. |
185 |
* This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized |
185 |
* This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized |
186 |
* or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing |
186 |
* or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing |
187 |
* in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern |
187 |
* in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern |
188 |
* uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field |
188 |
* uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field |
189 |
* names follow the lower CamelCase convention. |
189 |
* names follow the lower CamelCase convention. |
190 |
* <br> |
190 |
* <br><br> |
191 |
* The pattern may contain lowercase characters, which will be match in a case sensitive way. These characters must |
191 |
* The pattern may contain lowercase characters, which will be match in a case sensitive way. These characters must |
192 |
* appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' |
192 |
* appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' |
193 |
* or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'. |
193 |
* or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'. |
194 |
* <br><br> |
194 |
* <br><br> |
|
|
195 |
* Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading |
196 |
* character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'. |
197 |
* <br><br> |
198 |
* Camel Case rules are applied permissively which means that name may have more parts than the pattern or its |
199 |
* last part may be a prefix of the pattern's last part (see {@link #camelCaseMatch(char[], int, int, char[], int, int, boolean)} |
200 |
* for more explanation on Camel Case strict/permissive mode. |
201 |
* <br><br> |
195 |
* Examples: |
202 |
* Examples: |
196 |
* <ol> |
203 |
* <ol> |
197 |
* <li><pre> |
204 |
* <li><pre> |
Lines 224-229
Link Here
|
224 |
* result => false |
231 |
* result => false |
225 |
* </pre> |
232 |
* </pre> |
226 |
* </li> |
233 |
* </li> |
|
|
234 |
* <li><pre> |
235 |
* pattern = { 'I', 'P', 'L', '3' } |
236 |
* patternStart = 0 |
237 |
* patternEnd = 4 |
238 |
* name = { 'I', 'P', 'e', 'r', 's', 'p', 'e', 'c', 't', 'i', 'v', 'e', 'L', 'i', 's', 't', 'e', 'n', 'e', 'r', '3' } |
239 |
* nameStart = 0 |
240 |
* nameEnd = 21 |
241 |
* result => true |
242 |
* </pre> |
243 |
* </li> |
227 |
* </ol> |
244 |
* </ol> |
228 |
* |
245 |
* |
229 |
* @param pattern the given pattern |
246 |
* @param pattern the given pattern |
Lines 237-262
Link Here
|
237 |
if (name == null) |
254 |
if (name == null) |
238 |
return false; // null name cannot match |
255 |
return false; // null name cannot match |
239 |
|
256 |
|
240 |
return camelCaseMatch(pattern, 0, pattern.length, name, 0, name.length); |
257 |
return camelCaseMatch(pattern, name, false/*prefix match for last hunk*/); |
|
|
258 |
} |
259 |
|
260 |
/** |
261 |
* Answers true if the pattern matches the given name using CamelCase rules, or false otherwise. |
262 |
* char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. |
263 |
* <br><br> |
264 |
* CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. |
265 |
* This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized |
266 |
* or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing |
267 |
* in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern |
268 |
* uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field |
269 |
* names follow the lower CamelCase convention. |
270 |
* <br><br> |
271 |
* The pattern may contain lowercase characters, which will be match in a case sensitive way. These characters must |
272 |
* appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' |
273 |
* or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'. |
274 |
* <br><br> |
275 |
* Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading |
276 |
* character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'. |
277 |
* <br><br> |
278 |
* CamelCase rules can be applied strictly or permissively. When strict mode is specified, pattern and name |
279 |
* must have <b>exactly</b> the same number of parts and if last part must be identical if it contains lowercase characters. |
280 |
* For instance, 'HMap<' and 'HaMap' patterns will match 'HashMap' but neither 'HashMapEntry' nor 'HatMapper'. |
281 |
* Note that when last part does not contain lowercase characters, then name may end with lowercase characters. |
282 |
* So, 'HM' pattern will match both 'HashMap' <b>and</b> 'HatMapper' but still not 'HashMapEntry'. |
283 |
* Reversely, if permissive mode is specified, names do not need to have same number of parts and same last part. |
284 |
* Then, both 'HM' and 'HMap' will match 'HashMap', 'HatMapper' <b>and</b>'HashMapEntry'. |
285 |
* <br><br> |
286 |
* <pre> |
287 |
* Examples: |
288 |
* <ol> |
289 |
* <li> pattern = { 'N', 'P', 'E' } |
290 |
* name = { 'N', 'u','l', 'l', 'P', 'o', 'i', 'n', 't', 'e', 'r', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
291 |
* result => true</li> |
292 |
* <li> pattern = { 'N', 'P', 'E' } |
293 |
* name = { 'N', 'o', 'P', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
294 |
* result => true</li> |
295 |
* <li> pattern = { 'N', 'u', 'P', 'o', 'E', 'x' } |
296 |
* name = { 'N', 'u','l', 'l', 'P', 'o', 'i', 'n', 't', 'e', 'r', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
297 |
* result => true</li> |
298 |
* <li> pattern = { 'N', 'u', 'P', 'o', 'E', 'x' } |
299 |
* name = { 'N', 'o', 'P', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
300 |
* result => false</li> |
301 |
* <li> pattern = { 'n', p', 'e' } |
302 |
* name = { 'N', 'u','l', 'l', 'P', 'o', 'i', 'n', 't', 'e', 'r', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
303 |
* result => false</li> |
304 |
* <li> pattern = { 'I', 'P', 'L', '3' } |
305 |
* name = { 'I', 'P', 'e', 'r', 's', 'p', 'e', 'c', 't', 'i', 'v', 'e', 'L', 'i', 's', 't', 'e', 'n', 'e', 'r', '3' } |
306 |
* result => true</li> |
307 |
* <li> pattern = { 'H', M' } |
308 |
* name = { 'H', 'a', 's', 'h', 'M', 'a', 'p', 'E', 'n', 't', 'r', 'y' } |
309 |
* result => (exactMode == false)</li> |
310 |
* <li>pattern = { 'H', M', 'a', 'p' } |
311 |
* name = { 'H', 'a', 't', 'M', 'a', 'p', 'p', 'e', 'r' } |
312 |
* result => (exactMode == false)</li> |
313 |
* </ol> |
314 |
* </pre> |
315 |
* |
316 |
* @param pattern the given pattern |
317 |
* @param name the given name |
318 |
* @param exactMode flag telling whether the name must have same |
319 |
* number of parts and same last part (if it consists of multiple letters) |
320 |
* as the pattern or not. |
321 |
* <ul> |
322 |
* <li>For example, when it's <code>true</code>:<br> |
323 |
* - <code>HM</code> type string pattern will match |
324 |
* <code>HashMap</code> and <code>HtmlMapper</code> types, |
325 |
* but not <code>HashMapEntry</code><br> |
326 |
* - <code>HMap</code> type string pattern will match |
327 |
* <code>HashMap</code> type but not <code>HtmlMapper</code>. |
328 |
* </li> |
329 |
* <li>and, when it's <code>false</code>:<br> |
330 |
* - <code>HM</code> type string pattern will match both |
331 |
* <code>HashMap</code> and <code>HtmlMapper</code> |
332 |
* and <code>HashMapEntry</code><br> |
333 |
* - <code>HMap</code> type string pattern will match both |
334 |
* <code>HashMap</code> and <code>HtmlMapper</code> types. |
335 |
* </li> |
336 |
* </ul> |
337 |
* @return true if the pattern matches the given name, false otherwise |
338 |
* @since 3.4 |
339 |
*/ |
340 |
public static final boolean camelCaseMatch(char[] pattern, char[] name, boolean exactMode) { |
341 |
if (pattern == null) |
342 |
return true; // null pattern is equivalent to '*' |
343 |
if (name == null) |
344 |
return false; // null name cannot match |
345 |
|
346 |
return camelCaseMatch(pattern, 0, pattern.length, name, 0, name.length, exactMode); |
241 |
} |
347 |
} |
242 |
|
348 |
|
243 |
/** |
349 |
/** |
244 |
* Answers true if a sub-pattern matches the subpart of the given name using CamelCase rules, or false otherwise. |
350 |
* Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise. |
245 |
* char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. |
351 |
* char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. |
246 |
* Can match only subset of name/pattern, considering end positions as non-inclusive. |
352 |
* Can match only subset of name/pattern, considering end positions as non-inclusive. |
247 |
* The subpattern is defined by the patternStart and patternEnd positions. |
353 |
* The sub-pattern is defined by the patternStart and patternEnd positions. |
248 |
* <br> |
354 |
* <br><br> |
249 |
* CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. |
355 |
* CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. |
250 |
* This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized |
356 |
* This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized |
251 |
* or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing |
357 |
* or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing |
252 |
* in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern |
358 |
* in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern |
253 |
* uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field |
359 |
* uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field |
254 |
* names follow the lower CamelCase convention. |
360 |
* names follow the lower CamelCase convention. |
255 |
* <br> |
361 |
* <br><br> |
256 |
* The pattern may contain lowercase characters, which will be match in a case sensitive way. These characters must |
362 |
* The pattern may contain lowercase characters, which will be match in a case sensitive way. These characters must |
257 |
* appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' |
363 |
* appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' |
258 |
* or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'. |
364 |
* or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'. |
259 |
* <br><br> |
365 |
* <br><br> |
|
|
366 |
* Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading |
367 |
* character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'. |
368 |
* <br><br> |
369 |
* Camel Case rules are applied permissively which means that name may have more parts than the pattern and its |
370 |
* last part may be a prefix of the pattern's last part (see {@link #camelCaseMatch(char[], int, int, char[], int, int, boolean)} |
371 |
* for more explanation on Camel Case strict/permissive mode. |
372 |
* <br><br> |
260 |
* Examples: |
373 |
* Examples: |
261 |
* <ol> |
374 |
* <ol> |
262 |
* <li><pre> |
375 |
* <li><pre> |
Lines 309-314
Link Here
|
309 |
* result => false |
422 |
* result => false |
310 |
* </pre> |
423 |
* </pre> |
311 |
* </li> |
424 |
* </li> |
|
|
425 |
* <li><pre> |
426 |
* pattern = { 'I', 'P', 'L', '3' } |
427 |
* patternStart = 0 |
428 |
* patternEnd = 4 |
429 |
* name = { 'I', 'P', 'e', 'r', 's', 'p', 'e', 'c', 't', 'i', 'v', 'e', 'L', 'i', 's', 't', 'e', 'n', 'e', 'r', '3' } |
430 |
* nameStart = 0 |
431 |
* nameEnd = 21 |
432 |
* result => true |
433 |
* </pre> |
434 |
* </li> |
312 |
* </ol> |
435 |
* </ol> |
313 |
* |
436 |
* |
314 |
* @param pattern the given pattern |
437 |
* @param pattern the given pattern |
Lines 317-326
Link Here
|
317 |
* @param name the given name |
440 |
* @param name the given name |
318 |
* @param nameStart the start index of the name, inclusive |
441 |
* @param nameStart the start index of the name, inclusive |
319 |
* @param nameEnd the end index of the name, exclusive |
442 |
* @param nameEnd the end index of the name, exclusive |
320 |
* @return true if a sub-pattern matches the subpart of the given name, false otherwise |
443 |
* @return true if a sub-pattern matches the sub-part of the given name, false otherwise |
321 |
* @since 3.2 |
444 |
* @since 3.2 |
|
|
445 |
* @deprecated Use {@link #camelCaseMatch(char[], int, int, char[], int, int, boolean)} instead |
322 |
*/ |
446 |
*/ |
323 |
public static final boolean camelCaseMatch(char[] pattern, int patternStart, int patternEnd, char[] name, int nameStart, int nameEnd) { |
447 |
public static final boolean camelCaseMatch(char[] pattern, int patternStart, int patternEnd, char[] name, int nameStart, int nameEnd) { |
|
|
448 |
return camelCaseMatch(pattern, patternStart, patternEnd, name, nameStart, nameEnd, false/*prefix match for last hunk*/); |
449 |
} |
450 |
|
451 |
/** |
452 |
* Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise. |
453 |
* char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. |
454 |
* Can match only subset of name/pattern, considering end positions as non-inclusive. |
455 |
* The sub-pattern is defined by the patternStart and patternEnd positions. |
456 |
* <br><br> |
457 |
* CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. |
458 |
* This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized |
459 |
* or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing |
460 |
* in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern |
461 |
* uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field |
462 |
* names follow the lower CamelCase convention. |
463 |
* <br><br> |
464 |
* The pattern may contain lowercase characters, which will be match in a case sensitive way. These characters must |
465 |
* appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' |
466 |
* or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'. |
467 |
* <br><br> |
468 |
* Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading |
469 |
* character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'. |
470 |
* <br><br> |
471 |
* CamelCase rules can be applied strictly or permissively. When strict mode is specified, pattern and name |
472 |
* must have <b>exactly</b> the same number of parts and if last part must be identical if it contains lowercase characters. |
473 |
* For instance, 'HMap<' and 'HaMap' patterns will match 'HashMap' but neither 'HashMapEntry' nor 'HatMapper'. |
474 |
* Note that when last part does not contain lowercase characters, then name may end with lowercase characters. |
475 |
* So, 'HM' pattern will match both 'HashMap' <b>and</b> 'HatMapper' but still not 'HashMapEntry'. |
476 |
* Reversely, if permissive mode is specified, names do not need to have same number of parts and same last part. |
477 |
* Then, both 'HM' and 'HMap' will match 'HashMap', 'HatMapper' <b>and</b>'HashMapEntry'. |
478 |
* <br><br> |
479 |
* <pre> |
480 |
* Examples: |
481 |
* <ol> |
482 |
* <li> pattern = { 'N', 'P', 'E' } |
483 |
* patternStart = 0 |
484 |
* patternEnd = 3 |
485 |
* name = { 'N', 'u','l', 'l', 'P', 'o', 'i', 'n', 't', 'e', 'r', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
486 |
* nameStart = 0 |
487 |
* nameEnd = 20 |
488 |
* result => true</li> |
489 |
* <li> pattern = { 'N', 'P', 'E' } |
490 |
* patternStart = 0 |
491 |
* patternEnd = 3 |
492 |
* name = { 'N', 'o', 'P', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
493 |
* nameStart = 0 |
494 |
* nameEnd = 21 |
495 |
* result => true</li> |
496 |
* <li> pattern = { 'N', 'u', 'P', 'o', 'E', 'x' } |
497 |
* patternStart = 0 |
498 |
* patternEnd = 6 |
499 |
* name = { 'N', 'u','l', 'l', 'P', 'o', 'i', 'n', 't', 'e', 'r', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
500 |
* nameStart = 0 |
501 |
* nameEnd = 20 |
502 |
* result => true</li> |
503 |
* <li> pattern = { 'N', 'u', 'P', 'o', 'E', 'x' } |
504 |
* patternStart = 0 |
505 |
* patternEnd = 6 |
506 |
* name = { 'N', 'o', 'P', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
507 |
* nameStart = 0 |
508 |
* nameEnd = 21 |
509 |
* result => false</li> |
510 |
* <li> pattern = { 'n', p', 'e' } |
511 |
* patternStart = 0 |
512 |
* patternEnd = 3 |
513 |
* name = { 'N', 'u','l', 'l', 'P', 'o', 'i', 'n', 't', 'e', 'r', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n' } |
514 |
* nameStart = 0 |
515 |
* nameEnd = 20 |
516 |
* result => false</li> |
517 |
* <li> pattern = { 'I', 'P', 'L', '3' } |
518 |
* patternStart = 0 |
519 |
* patternEnd = 4 |
520 |
* name = { 'I', 'P', 'e', 'r', 's', 'p', 'e', 'c', 't', 'i', 'v', 'e', 'L', 'i', 's', 't', 'e', 'n', 'e', 'r', '3' } |
521 |
* nameStart = 0 |
522 |
* nameEnd = 21 |
523 |
* result => true</li> |
524 |
* <li> pattern = { 'H', M' } |
525 |
* patternStart = 0 |
526 |
* patternEnd = 2 |
527 |
* name = { 'H', 'a', 's', 'h', 'M', 'a', 'p', 'E', 'n', 't', 'r', 'y' } |
528 |
* nameStart = 0 |
529 |
* nameEnd = 12 |
530 |
* result => (exactMode == false)</li> |
531 |
* <li> pattern = { 'H', M', 'a', 'p' } |
532 |
* patternStart = 0 |
533 |
* patternEnd = 4 |
534 |
* name = { 'H', 'a', 't', 'M', 'a', 'p', 'p', 'e', 'r' } |
535 |
* nameStart = 0 |
536 |
* nameEnd = 9 |
537 |
* result => (exactMode == false)</li> |
538 |
* </ol> |
539 |
* </pre> |
540 |
* |
541 |
* @param pattern the given pattern |
542 |
* @param patternStart the start index of the pattern, inclusive |
543 |
* @param patternEnd the end index of the pattern, exclusive |
544 |
* @param name the given name |
545 |
* @param nameStart the start index of the name, inclusive |
546 |
* @param nameEnd the end index of the name, exclusive |
547 |
* @param exactMode flag telling whether the name must have same |
548 |
* number of parts and same last part (if it consists of multiple letters) |
549 |
* as the pattern or not. |
550 |
* <ul> |
551 |
* <li>For example, when it's <code>true</code>:<br> |
552 |
* - <code>HM</code> type string pattern will match |
553 |
* <code>HashMap</code> and <code>HtmlMapper</code> types, |
554 |
* but not <code>HashMapEntry</code><br> |
555 |
* - <code>HMap</code> type string pattern will match |
556 |
* <code>HashMap</code> type but not <code>HtmlMapper</code>. |
557 |
* </li> |
558 |
* <li>and, when it's <code>false</code>:<br> |
559 |
* - <code>HM</code> type string pattern will match both |
560 |
* <code>HashMap</code> and <code>HtmlMapper</code> |
561 |
* and <code>HashMapEntry</code><br> |
562 |
* - <code>HMap</code> type string pattern will match both |
563 |
* <code>HashMap</code> and <code>HtmlMapper</code> types. |
564 |
* </li> |
565 |
* </ul> |
566 |
* @return true if a sub-pattern matches the sub-part of the given name, false otherwise |
567 |
* @since 3.4 |
568 |
*/ |
569 |
public static final boolean camelCaseMatch(char[] pattern, int patternStart, int patternEnd, char[] name, int nameStart, int nameEnd, boolean exactMode) { |
324 |
if (name == null) |
570 |
if (name == null) |
325 |
return false; // null name cannot match |
571 |
return false; // null name cannot match |
326 |
if (pattern == null) |
572 |
if (pattern == null) |
Lines 346-354
Link Here
|
346 |
iPattern++; |
592 |
iPattern++; |
347 |
iName++; |
593 |
iName++; |
348 |
|
594 |
|
349 |
if (iPattern == patternEnd) { |
595 |
if (iPattern == patternEnd) { // we have exhausted pattern... |
350 |
// We have exhausted pattern, so it's a match |
596 |
// it's a match if not exact mode or name is also exhausted |
351 |
return true; |
597 |
if (!exactMode || iName == nameEnd) return true; |
|
|
598 |
|
599 |
// it's not a match if last pattern character is a lowercase |
600 |
if ((patternChar = pattern[iPattern-1]) < ScannerHelper.MAX_OBVIOUS) { |
601 |
if ((ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[patternChar] & (ScannerHelper.C_UPPER_LETTER | ScannerHelper.C_DIGIT)) == 0) { |
602 |
return false; |
603 |
} |
604 |
} |
605 |
else if (Character.isJavaIdentifierPart(patternChar) && !Character.isUpperCase(patternChar) && !Character.isDigit(patternChar)) { |
606 |
return false; |
607 |
} |
608 |
|
609 |
// it's a match only if name has no more uppercase characters (exact mode) |
610 |
while (true) { |
611 |
if (iName == nameEnd) { |
612 |
// we have exhausted name, so it's a match |
613 |
return true; |
614 |
} |
615 |
nameChar = name[iName]; |
616 |
if (nameChar < ScannerHelper.MAX_OBVIOUS) { |
617 |
if ((ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[nameChar] & ScannerHelper.C_UPPER_LETTER) != 0) { |
618 |
// nameChar is uppercase, so it's not a match |
619 |
return false; |
620 |
} |
621 |
} |
622 |
else if (!Character.isJavaIdentifierPart(nameChar) || Character.isUpperCase(nameChar)) { |
623 |
return false; |
624 |
} |
625 |
iName++; |
626 |
} |
352 |
} |
627 |
} |
353 |
|
628 |
|
354 |
if (iName == nameEnd){ |
629 |
if (iName == nameEnd){ |