001package Torello.Java; 002 003import java.util.function.Consumer; 004import java.util.function.Predicate; 005import java.util.Vector; 006 007import Torello.JavaDoc.StaticFunctional; 008import Torello.JavaDoc.LinkJavaSource; 009import Torello.JavaDoc.Excuse; 010 011/** 012 * Similar to class String-Compare, String-Token-Compare also provides an exhaustive suite of 013 * methods that extend the basic Java <CODE>String</CODE> methods <CODE>equals, contains, 014 * startsWith</CODE> and <CODE>endsWith</CODE>, but further allowing a user to specify the 015 * match-string boundary-characters. 016 * 017 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=STR_TOK_CMPR> 018 */ 019@StaticFunctional(Excused={"DEBUG", "DEBUG_LOG"}, Excuses={Excuse.DEBUGGING, Excuse.DEBUGGING}) 020@Torello.JavaDoc.CSSLinks(FileNames="Strings.css") 021public class StrTokCmpr 022{ 023 private StrTokCmpr() { } 024 025 /** 026 * Utility field. You may choose to set this variable to true, and the following 027 * {@code String} commands will print to an internally stored {@code Consumer<String> DEBUG_LOG} 028 * class that may be set. This is generally a very minor drain on code-efficiency. When this 029 * flag is set to {@code FALSE}, a short {@code if-statement evaluation} <I>still occurs even 030 * when the flag is false</I> on each occasion that the string-comparison loops identify and 031 * return a match. This is very minor performance loss, and does provide quite a lot of help 032 * to those trying to identify difficult to notice problems with partial-{@code String} 033 * comparisons. 034 * 035 * <BR /><BR /><B CLASS=JDDescLabel>Required Setting:</B> 036 * 037 * <BR />In order to use this minor Debugging Feature, it is necessary to provide a 038 * {@code Consumer<String>} to public field {@link #DEBUG_LOG}! This field is a {@code public} 039 * and {@code static} field, which will be used by any invocation of the methods in this class. 040 * This {@code String}-consumer may do anything you would like it to do with the provided 041 * Debug-{@code String} data. 042 * 043 * <BR /><BR /><B CLASS=JDDescLabel>String-Format:</B> 044 * 045 * <BR />The {@code String} that is ultimately sent to the {@code Consumer<String>} you provide 046 * will be formatted, as below, in the following Code-Snippet: 047 * 048 * <BR /><DIV CLASS=SNIP>{@code 049 * private static void PRNT(String methodName, String srcStr, String compareStr) 050 * { DEBUG_LOG.accept(methodName + "-MATCH[" + srcStr + ", " + compareStr + "] "); } 051 * }</DIV> 052 * 053 * <BR /><BR />Generally, you would assign a writer that looks like something the Lambda-Target 054 * / Function-Pointer assignment in the snippet below: 055 * 056 * <BR /><DIV CLASS=SNIP>{@code 057 * StrTokCmpr.DEBUG_LOG = (String logInfoStr) -> System.out.println(logInfoStr); 058 * }</DIV> 059 * 060 * <BR /><BR />Finally, if you are using this field, please note that any of the methods whose 061 * name ends with the phrase "IgnoreCase" <I>will not print to the {@link #DEBUG_LOG}</I>. 062 * This is primarily because these are all <I>single-argument comparisons</I>, and logging 063 * would be of only minor benefit. 064 * 065 * <BR /><BR />The primary value of a debug-log is the ability to identify whether / when a 066 * particular substring from a list of substrings actually matched. 067 */ 068 public static boolean DEBUG = false; 069 070 /** 071 * This object reference <I><B>cannot be null when DEBUG is TRUE</B></I>. This 072 * {@code StorageWriter} will receive text-notifications every time the string-comparing loops 073 * identify a match. 074 * 075 * <BR /><BR /><B CLASS=JDDescLabel>DEBUG_LOG is not Thread-Safe:</B> 076 * 077 * <BR />No attempt has been made to ensure that this debugging feature will operate perfectly 078 * in a multi-threaded environment. The two reasons for this are: 079 * 080 * <BR /><BR /><OL CLASS=JDOL> 081 * <LI> The primary purpose of this LOG is for debugging code, not putting details about 082 * string-match information into an 'on-line' or production environment. 083 * </LI> 084 * 085 * <LI> This is a best-efforts string-comparison package that would sacrifice quite a bit of its 086 * utility if it were expected to maintain multiple instances of this class just to have 087 * {@code StrCmpr} debug operations work in multiple-threads. Code readability necessitates 088 * keeping this a class with only <B><I>static methods.</I></B> 089 * </LI> 090 * 091 * <LI> Two threads making calls to this {@code class StrCmpr} might see log-writes that, sadly, 092 * look like they 'interlaced' (crashed), but even when this occasions, reading the log 093 * wouldn't be that difficult anyway. 094 * </LI> 095 * </OL> 096 */ 097 public static Consumer<String> DEBUG_LOG = null; 098 099 private static void PRNT(String methodName, String srcStr, String token) 100 { DEBUG_LOG.accept(methodName + srcStr + ", " + token + "] "); } 101 102 /** 103 * This performs the internal AND. It expects a comparison {@code Predicate} in order for the 104 * comparison to work. 105 * 106 * @param methodName If printing-debug information is expected, by the DEBUG global-variable, 107 * this {@code String} is used. 108 * 109 * @param srcStr This is the same source-string parameter from all the methods in this class. 110 * @param tokens This is the same var-args string array from all the methods in this class. 111 * 112 * @param pred This is the comparison {@code Predicate} provided by the methods in this class 113 * that call this method. 114 * 115 * @return The AND of these {@code String's}, using the provided {@code Predicate}. 116 * 117 * @throws StrCmprException This exception shall throw if there are any invalid 118 * {@code String's} in the compare-string parameter array. 119 * 120 * <BR /><BR /><DIV CLASS=JDHint> 121 * <B STYLE="color: red;">Note:</B> The conditions that would cause this exception to throw 122 * should remind the reader that <I><B>each and every method here</I></B> will throw exception 123 * {@code 'StrCmprException'} if invalid input has been passed to the "Compare String" 124 * Variable-Arguments {@code String...} Parameter. 125 * </DIV> 126 */ 127 protected static boolean AND 128 (String methodName, String srcStr, String[] tokens, Predicate<String> pred) 129 { 130 StrCmprException.check(tokens); 131 132 for (String cmp: tokens) 133 134 if (! pred.test(cmp)) 135 { 136 if (DEBUG) PRNT(methodName + "-MATCHFAIL", srcStr, cmp); 137 return false; 138 } 139 140 return true; 141 } 142 143 /** 144 * This performs the internal NAND. It expects a comparison {@code Predicate} in order for the 145 * comparison to work. 146 * 147 * @param methodName If printing-debug information is expected, by the DEBUG global-variable, 148 * this {@code String} is used. 149 * 150 * @param srcStr This is the same source-string parameter from all the methods in this class. 151 * @param tokens This is the same var-args string array from all the methods in this class. 152 * 153 * @param pred This is the comparison {@code Predicate} provided by the methods in this class 154 * that call this method. 155 * 156 * @return The NAND of these {@code String's}, using the provided {@code Predicate}. 157 * 158 * @throws StrCmprException This exception shall throw if there are any invalid 159 * {@code String's} in the compare-string parameter array. 160 * 161 * <BR /><BR /><DIV CLASS=JDHint> 162 * <B STYLE="color: red;">Note:</B> The conditions that would cause this exception to throw 163 * should remind the reader that <I><B>each and every method here</I></B> will throw exception 164 * {@code 'StrCmprException'} if invalid input has been passed to the "Compare String" 165 * Variable-Arguments {@code String...} Parameter. 166 * </DIV> 167 */ 168 protected static boolean NAND 169 (String methodName, String srcStr, String[] tokens, Predicate<String> pred) 170 { 171 StrCmprException.check(tokens); 172 173 for (String cmp: tokens) 174 175 if (pred.test(cmp)) 176 { 177 if (DEBUG) PRNT(methodName + "-MATCH", srcStr, cmp); 178 return false; 179 } 180 181 return true; 182 } 183 184 /** 185 * This performs the internal OR. It expects a comparison {@code Predicate} in order for the 186 * comparison to work. 187 * 188 * @param methodName If printing-debug information is expected, by the DEBUG global-variable, 189 * this {@code String} is used. 190 * 191 * @param srcStr This is the same source-string parameter from all the methods in this class. 192 * @param tokens This is the same var-args string array from all the methods in this class. 193 * 194 * @param pred This is the comparison {@code Predicate} provided by the methods in this class 195 * that call this method. 196 * 197 * @return The OR of these {@code String's}, using the provided {@code Predicate}. 198 * 199 * @throws StrCmprException This exception shall throw if there are any invalid 200 * {@code String's} in the compare-string parameter array. 201 * 202 * <BR /><BR /><DIV CLASS=JDHint> 203 * <B STYLE="color: red;">Note:</B> The conditions that would cause this exception to throw 204 * should remind the reader that <I><B>each and every method here</I></B> will throw exception 205 * {@code 'StrCmprException'} if invalid input has been passed to the "Compare String" 206 * Variable-Arguments {@code String...} Parameter. 207 * </DIV> 208 */ 209 protected static boolean OR 210 (String methodName, String srcStr, String[] tokens, Predicate<String> pred) 211 { 212 StrCmprException.check(tokens); 213 214 for (String cmp: tokens) 215 216 if (pred.test(cmp)) 217 { 218 if (DEBUG) PRNT(methodName + "-MATCH", srcStr, cmp); 219 return true; 220 } 221 222 return false; 223 } 224 225 /** 226 * This performs the internal XOR. It expects a comparison {@code Predicate} in order for the 227 * comparison to work. 228 * 229 * @param methodName If printing-debug information is expected, by the DEBUG global-variable, 230 * this {@code String} is used. 231 * 232 * @param srcStr This is the same source-string parameter from all the methods in this class. 233 * @param tokens This is the same var-args string array from all the methods in this class. 234 * 235 * @param pred This is the comparison {@code Predicate} provided by the methods in this class 236 * that call this method. 237 * 238 * @return The XOR of these {@code String's}, using the provided {@code Predicate}. 239 * 240 * @throws StrCmprException This exception shall throw if there are any invalid 241 * {@code String's} in the compare-string parameter array. 242 * 243 * <BR /><BR /><DIV CLASS=JDHint> 244 * <B STYLE="color: red;">Note:</B> The conditions that would cause this exception to throw 245 * should remind the reader that <I><B>each and every method here</I></B> will throw exception 246 * {@code 'StrCmprException'} if invalid input has been passed to the "Compare String" 247 * Variable-Arguments {@code String...} Parameter. 248 * </DIV> 249 */ 250 protected static boolean XOR 251 (String methodName, String srcStr, String[] tokens, Predicate<String> pred) 252 { 253 StrCmprException.check(tokens); 254 255 int count=0; 256 257 for (String cmp: tokens) 258 259 if (pred.test(cmp)) 260 261 if (++count > 1) 262 { 263 if (DEBUG) PRNT(methodName + "-MATCH", srcStr, cmp); 264 return false; 265 } 266 267 return count == 1; 268 } 269 270 271 272 273 274 275 276 277 278 279 280 // ******************************************************************************************** 281 // ******************************************************************************************** 282 // ******************************************************************************************** 283 // ******************************************************************************************** 284 // ******************************************************************************************** 285 // ******************************************************************************************** 286 // StrCmpr Main Section #1 287 // ******************************************************************************************** 288 // ******************************************************************************************** 289 // ******************************************************************************************** 290 // ******************************************************************************************** 291 // ******************************************************************************************** 292 293 294 295 // ******************************************************************************************** 296 // ******************************************************************************************** 297 // CONTAINS 298 // ******************************************************************************************** 299 // ******************************************************************************************** 300 301 302 /** 303 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is'> 304 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 305 * @param srcStr Any non-null instance of {@code java.lang.String} 306 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 307 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 308 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 309 */ 310 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 311 public static boolean containsOR(String srcStr, String... tokens) 312 { return TokCmprCN.CONTAINS(false, OR, srcStr, tokens); } 313 314 /** 315 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is'> 316 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 317 * @param srcStr Any non-null instance of {@code java.lang.String} 318 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 319 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 320 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 321 */ 322 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 323 public static boolean containsAND(String srcStr, String... tokens) 324 { return TokCmprCN.CONTAINS(false, AND, srcStr, tokens); } 325 326 /** 327 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is'> 328 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 329 * @param srcStr Any non-null instance of {@code java.lang.String} 330 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 331 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 332 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 333 */ 334 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 335 public static boolean containsXOR(String srcStr, String... tokens) 336 { return TokCmprCN.CONTAINS(false, XOR, srcStr, tokens); } 337 338 /** 339 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is'> 340 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 341 * @param srcStr Any non-null instance of {@code java.lang.String} 342 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 343 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 344 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 345 */ 346 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 347 public static boolean containsNAND(String srcStr, String... tokens) 348 { return TokCmprCN.CONTAINS(false, NAND, srcStr, tokens); } 349 350 /** 351 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is not'> 352 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 353 * @param srcStr Any non-null instance of {@code java.lang.String} 354 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 355 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 356 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 357 */ 358 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 359 public static boolean containsOR_CI(String srcStr, String... tokens) 360 { return TokCmprCN.CONTAINS(true, OR, srcStr, tokens); } 361 362 /** 363 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is not'> 364 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 365 * @param srcStr Any non-null instance of {@code java.lang.String} 366 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 367 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 368 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 369 */ 370 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 371 public static boolean containsAND_CI(String srcStr, String... tokens) 372 { return TokCmprCN.CONTAINS(true, AND, srcStr, tokens); } 373 374 /** 375 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is not'> 376 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 377 * @param srcStr Any non-null instance of {@code java.lang.String} 378 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 379 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 380 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 381 */ 382 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 383 public static boolean containsXOR_CI(String srcStr, String... tokens) 384 { return TokCmprCN.CONTAINS(true, XOR, srcStr, tokens); } 385 386 /** 387 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is not'> 388 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 389 * @param srcStr Any non-null instance of {@code java.lang.String} 390 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 391 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 392 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 393 */ 394 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 395 public static boolean containsNAND_CI(String srcStr, String... tokens) 396 { return TokCmprCN.CONTAINS(true, NAND, srcStr, tokens); } 397 398 399 // ******************************************************************************************** 400 // ******************************************************************************************** 401 // STARTS-WITH, ENDS-WITH 402 // ******************************************************************************************** 403 // ******************************************************************************************** 404 405 406 /** 407 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is'> 408 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 409 * @param srcStr Any non-null instance of {@code java.lang.String} 410 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 411 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 412 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 413 * @see #XOR(String, String, String[], Predicate) 414 */ 415 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=3) 416 public static boolean endsWithXOR(String srcStr, String... tokens) 417 { 418 return XOR( 419 "endsWithXOR", srcStr, tokens, 420 cmp -> TokCmprEW.ew(srcStr, new LV(srcStr, 0, -1), cmp) 421 ); 422 } 423 424 /** 425 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is'> 426 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 427 * @param srcStr Any non-null instance of {@code java.lang.String} 428 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 429 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 430 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 431 * @see #NAND(String, String, String[], Predicate) 432 */ 433 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=3) 434 public static boolean endsWithNAND(String srcStr, String... tokens) 435 { 436 return NAND( 437 "endsWithNAND", srcStr, tokens, 438 cmp -> TokCmprEW.ew(srcStr, new LV(srcStr, 0, -1), cmp) 439 ); 440 } 441 442 /** 443 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is'> 444 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 445 * @param srcStr Any non-null instance of {@code java.lang.String} 446 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 447 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 448 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 449 * @see #XOR(String, String, String[], Predicate) 450 */ 451 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=3) 452 public static boolean startsWithXOR(String srcStr, String... tokens) 453 { 454 return XOR( 455 "startsWithXOR", srcStr, tokens, 456 cmp -> TokCmprSW.sw(srcStr, new LV(srcStr, 0, -1), cmp) 457 ); 458 } 459 460 /** 461 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is'> 462 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 463 * @param srcStr Any non-null instance of {@code java.lang.String} 464 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 465 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 466 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 467 * @see #NAND(String, String, String[], Predicate) 468 */ 469 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=3) 470 public static boolean startsWithNAND(String srcStr, String... tokens) 471 { 472 return NAND( 473 "startsWithNAND", srcStr, tokens, 474 cmp -> TokCmprSW.sw(srcStr, new LV(srcStr, 0, -1), cmp) 475 ); 476 } 477 478 479 // ******************************************************************************************** 480 // ******************************************************************************************** 481 // STARTS-WITH, ENDS-WITH - CASE INSENSITIVE 482 // ******************************************************************************************** 483 // ******************************************************************************************** 484 485 486 /** 487 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is not'> 488 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 489 * @param srcStr Any non-null instance of {@code java.lang.String} 490 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 491 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 492 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 493 * @see #endsWithIgnoreCase(String, String) 494 * @see #XOR(String, String, String[], Predicate) 495 */ 496 public static boolean endsWithXOR_CI(String srcStr, String... tokens) 497 { return XOR("endsWithXOR_CI", srcStr, tokens, cmp -> endsWithIgnoreCase(srcStr, cmp)); } 498 499 /** 500 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is not'> 501 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 502 * @param srcStr Any non-null instance of {@code java.lang.String} 503 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 504 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 505 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 506 * @see #endsWithIgnoreCase(String, String) 507 * @see #NAND(String, String, String[], Predicate) 508 */ 509 public static boolean endsWithNAND_CI(String srcStr, String... tokens) 510 { return NAND("endsWithNAND_CI", srcStr, tokens, cmp -> endsWithIgnoreCase(srcStr, cmp)); } 511 512 /** 513 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is not'> 514 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 515 * @param srcStr Any non-null instance of {@code java.lang.String} 516 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 517 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 518 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 519 * @see #startsWithIgnoreCase(String, String) 520 * @see #XOR(String, String, String[], Predicate) 521 */ 522 public static boolean startsWithXOR_CI(String srcStr, String... tokens) 523 { return XOR("startsWithXOR_CI", srcStr, tokens, cmp -> startsWithIgnoreCase(srcStr, cmp)); } 524 525 /** 526 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is not'> 527 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 528 * @param srcStr Any non-null instance of {@code java.lang.String} 529 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 530 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 531 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 532 * @see #startsWithIgnoreCase(String, String) 533 * @see #NAND(String, String, String[], Predicate) 534 */ 535 public static boolean startsWithNAND_CI(String srcStr, String... tokens) 536 { return NAND("startsWithNAND_CI", srcStr, tokens, cmp -> startsWithIgnoreCase(srcStr, cmp)); } 537 538 // ******************************************************************************************** 539 // Three Standard Java Methods, Added Token Checking 540 // ******************************************************************************************** 541 542 /** 543 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is'> 544 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 545 * @param srcStr Any non-null instance of {@code java.lang.String} 546 * @param token The {@code String} used in the comparison against {@code 'srcStr'} 547 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 548 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 549 */ 550 public static boolean startsWith(String srcStr, String token) 551 { 552 return srcStr.startsWith(token) 553 && ( (token.length() == srcStr.length()) 554 || Character.isWhitespace(srcStr.charAt(token.length()))); 555 } 556 557 /** 558 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is'> 559 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 560 * @param srcStr Any non-null instance of {@code java.lang.String} 561 * @param token The {@code String} used in the comparison against {@code 'srcStr'} 562 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 563 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 564 */ 565 public static boolean endsWith(String srcStr, String token) 566 { 567 return srcStr.endsWith(token) 568 && ( (token.length() == srcStr.length()) 569 || (Character.isWhitespace(srcStr.charAt(srcStr.length() - token.length() - 1)))); 570 } 571 572 /** 573 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is'> 574 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 575 * @param srcStr Any non-null instance of {@code java.lang.String} 576 * @param token The {@code String} used in the comparison against {@code 'srcStr'} 577 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 578 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 579 */ 580 public static boolean contains(String srcStr, String token) 581 { 582 int tokenLen = token.length(); 583 int loopLen = srcStr.length() - tokenLen; 584 585 for (int i=0; i <= loopLen; i++) 586 587 if ( srcStr.regionMatches(i, token, 0, tokenLen) 588 && ( (i == 0) 589 || Character.isWhitespace(srcStr.charAt(i-1))) 590 && ( ((i + tokenLen) == srcStr.length()) 591 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 592 ) 593 return true; 594 595 return false; 596 } 597 598 599 // ******************************************************************************************** 600 // ******************************************************************************************** 601 // IGNORE-CASE METHODS 602 // ******************************************************************************************** 603 // ******************************************************************************************** 604 605 606 /** 607 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is not'> 608 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 609 * @param srcStr Any non-null instance of {@code java.lang.String} 610 * @param token The {@code String} used in the comparison against {@code 'srcStr'} 611 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 612 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 613 */ 614 public static boolean startsWithIgnoreCase(String srcStr, String token) 615 { 616 return srcStr.regionMatches(true, 0, token, 0, token.length()) 617 && ( (token.length() == srcStr.length()) 618 || Character.isWhitespace(srcStr.charAt(token.length()))); 619 } 620 621 /** 622 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is not'> 623 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 624 * @param srcStr Any non-null instance of {@code java.lang.String} 625 * @param token The {@code String} used in the comparison against {@code 'srcStr'} 626 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 627 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 628 */ 629 public static boolean endsWithIgnoreCase(String srcStr, String token) 630 { 631 int tokenLen = token.length(); 632 int startPos = srcStr.length() - tokenLen; 633 634 return srcStr.regionMatches(true, startPos, token, 0, tokenLen) 635 && ( (tokenLen == srcStr.length()) 636 || (Character.isWhitespace(srcStr.charAt(startPos - 1)))); 637 } 638 639 /** 640 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is not'> 641 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 642 * @param srcStr Any non-null instance of {@code java.lang.String} 643 * @param token The {@code String} used in the comparison against {@code 'srcStr'} 644 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 645 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 646 */ 647 public static boolean containsIgnoreCase(String srcStr, String token) 648 { return TokCmprCN.containsIgnoreCase(srcStr, new LV(srcStr, 0, srcStr.length()), token); } 649 650 651 652 653 654 655 656 657 658 659 660 // ******************************************************************************************** 661 // ******************************************************************************************** 662 // ******************************************************************************************** 663 // ******************************************************************************************** 664 // ******************************************************************************************** 665 // StrCmpr Main Section 666 // ******************************************************************************************** 667 // ******************************************************************************************** 668 // ******************************************************************************************** 669 // ******************************************************************************************** 670 // ******************************************************************************************** 671 672 673 674 // ******************************************************************************************** 675 // ******************************************************************************************** 676 // CONTAINS 677 // ******************************************************************************************** 678 // ******************************************************************************************** 679 680 681 /** 682 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is'> 683 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 684 * @param srcStr Any non-null instance of {@code java.lang.String} 685 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 686 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 687 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 688 */ 689 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS_LV") 690 public static boolean containsOR(String srcStr, int sPos, int ePos, String... tokens) 691 { 692 final LV l = new LV(srcStr, sPos, ePos); 693 return TokCmprCN.CONTAINS_LV(false, OR, l, srcStr, tokens); 694 } 695 696 /** 697 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is'> 698 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 699 * @param srcStr Any non-null instance of {@code java.lang.String} 700 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 701 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 702 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 703 */ 704 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS_LV") 705 public static boolean containsAND(String srcStr, int sPos, int ePos, String... tokens) 706 { 707 final LV l = new LV(srcStr, sPos, ePos); 708 return TokCmprCN.CONTAINS_LV(false, AND, l, srcStr, tokens); 709 } 710 711 /** 712 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is'> 713 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 714 * @param srcStr Any non-null instance of {@code java.lang.String} 715 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 716 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 717 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 718 */ 719 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS_LV") 720 public static boolean containsXOR(String srcStr, int sPos, int ePos, String... tokens) 721 { 722 final LV l = new LV(srcStr, sPos, ePos); 723 return TokCmprCN.CONTAINS_LV(false, XOR, l, srcStr, tokens); 724 } 725 726 /** 727 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is'> 728 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 729 * @param srcStr Any non-null instance of {@code java.lang.String} 730 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 731 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 732 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 733 */ 734 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS_LV") 735 public static boolean containsNAND(String srcStr, int sPos, int ePos, String... tokens) 736 { 737 final LV l = new LV(srcStr, sPos, ePos); 738 return TokCmprCN.CONTAINS_LV(false, NAND, l, srcStr, tokens); 739 } 740 741 /** 742 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is not'> 743 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 744 * @param srcStr Any non-null instance of {@code java.lang.String} 745 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 746 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 747 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 748 */ 749 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS_LV") 750 public static boolean containsOR_CI(String srcStr, int sPos, int ePos, String... tokens) 751 { 752 final LV l = new LV(srcStr, sPos, ePos); 753 return TokCmprCN.CONTAINS_LV(true, OR, l, srcStr, tokens); 754 } 755 756 /** 757 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is not'> 758 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 759 * @param srcStr Any non-null instance of {@code java.lang.String} 760 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 761 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 762 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 763 */ 764 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS_LV") 765 public static boolean containsAND_CI(String srcStr, int sPos, int ePos, String... tokens) 766 { 767 final LV l = new LV(srcStr, sPos, ePos); 768 return TokCmprCN.CONTAINS_LV(true, AND, l, srcStr, tokens); 769 } 770 771 /** 772 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is not'> 773 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 774 * @param srcStr Any non-null instance of {@code java.lang.String} 775 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 776 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 777 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 778 */ 779 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS_LV") 780 public static boolean containsXOR_CI(String srcStr, int sPos, int ePos, String... tokens) 781 { 782 final LV l = new LV(srcStr, sPos, ePos); 783 return TokCmprCN.CONTAINS_LV(true, XOR, l, srcStr, tokens); 784 } 785 786 /** 787 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is not'> 788 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 789 * @param srcStr Any non-null instance of {@code java.lang.String} 790 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 791 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 792 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 793 */ 794 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS_LV") 795 public static boolean containsNAND_CI(String srcStr, int sPos, int ePos, String... tokens) 796 { 797 final LV l = new LV(srcStr, sPos, ePos); 798 return TokCmprCN.CONTAINS_LV(true, NAND, l, srcStr, tokens); 799 } 800 801 802 // ******************************************************************************************** 803 // ******************************************************************************************** 804 // STARTS-WITH, ENDS-WITH 805 // ******************************************************************************************** 806 // ******************************************************************************************** 807 808 809 /** 810 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is'> 811 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 812 * @param srcStr Any non-null instance of {@code java.lang.String} 813 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 814 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 815 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 816 * @see #XOR(String, String, String[], Predicate) 817 */ 818 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=3) 819 public static boolean endsWithXOR(String srcStr, int sPos, int ePos, String... tokens) 820 { 821 final LV l = new LV(srcStr, sPos, ePos); 822 return XOR("endsWithXOR", srcStr, tokens, cmp -> TokCmprEW.ew(srcStr, l, cmp)); 823 } 824 825 /** 826 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is'> 827 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 828 * @param srcStr Any non-null instance of {@code java.lang.String} 829 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 830 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 831 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 832 * @see #NAND(String, String, String[], Predicate) 833 */ 834 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=3) 835 public static boolean endsWithNAND(String srcStr, int sPos, int ePos, String... tokens) 836 { 837 final LV l = new LV(srcStr, sPos, ePos); 838 return NAND("endsWithNAND", srcStr, tokens, cmp -> TokCmprEW.ew(srcStr, l, cmp)); 839 } 840 841 /** 842 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is'> 843 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 844 * @param srcStr Any non-null instance of {@code java.lang.String} 845 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 846 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 847 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 848 * @see #XOR(String, String, String[], Predicate) 849 */ 850 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=3) 851 public static boolean startsWithXOR(String srcStr, int sPos, int ePos, String... tokens) 852 { 853 final LV l = new LV(srcStr, sPos, ePos); 854 return XOR("startsWithXOR", srcStr, tokens, cmp -> TokCmprSW.sw(srcStr, l, cmp)); 855 } 856 857 /** 858 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is'> 859 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 860 * @param srcStr Any non-null instance of {@code java.lang.String} 861 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 862 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 863 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 864 * @see #NAND(String, String, String[], Predicate) 865 */ 866 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=3) 867 public static boolean startsWithNAND(String srcStr, int sPos, int ePos, String... tokens) 868 { 869 final LV l = new LV(srcStr, sPos, ePos); 870 return NAND("startsWithNAND", srcStr, tokens, cmp -> TokCmprSW.sw(srcStr, l, cmp)); 871 } 872 873 874 // ******************************************************************************************** 875 // ******************************************************************************************** 876 // STARTS-WITH, ENDS-WITH - CASE INSENSITIVE 877 // ******************************************************************************************** 878 // ******************************************************************************************** 879 880 881 /** 882 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is not'> 883 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 884 * @param srcStr Any non-null instance of {@code java.lang.String} 885 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 886 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 887 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 888 * @see #XOR(String, String, String[], Predicate) 889 */ 890 @LinkJavaSource(handle="TokCmprEW", name="ew_CI", paramCount=3) 891 public static boolean endsWithXOR_CI(String srcStr, int sPos, int ePos, String... tokens) 892 { 893 final LV l = new LV(srcStr, sPos, ePos); 894 return XOR("endsWithXOR_CI", srcStr, tokens, cmp -> TokCmprEW.ew_CI(srcStr, l, cmp)); 895 } 896 897 /** 898 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is not'> 899 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 900 * @param srcStr Any non-null instance of {@code java.lang.String} 901 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 902 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 903 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 904 * @see #NAND(String, String, String[], Predicate) 905 */ 906 @LinkJavaSource(handle="TokCmprEW", name="ew_CI", paramCount=3) 907 public static boolean endsWithNAND_CI(String srcStr, int sPos, int ePos, String... tokens) 908 { 909 final LV l = new LV(srcStr, sPos, ePos); 910 return NAND("endsWithNAND_CI", srcStr, tokens, cmp -> TokCmprEW.ew_CI(srcStr, l, cmp)); 911 } 912 913 /** 914 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is not'> 915 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 916 * @param srcStr Any non-null instance of {@code java.lang.String} 917 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 918 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 919 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 920 * @see #XOR(String, String, String[], Predicate) 921 */ 922 @LinkJavaSource(handle="TokCmprSW", name="sw_CI", paramCount=3) 923 public static boolean startsWithXOR_CI(String srcStr, int sPos, int ePos, String... tokens) 924 { 925 final LV l = new LV(srcStr, sPos, ePos); 926 return XOR("startsWithXOR_CI", srcStr, tokens, cmp -> TokCmprSW.sw_CI(srcStr, l, cmp)); 927 } 928 929 /** 930 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is not'> 931 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 932 * @param srcStr Any non-null instance of {@code java.lang.String} 933 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 934 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 935 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 936 * @see #NAND(String, String, String[], Predicate) 937 */ 938 @LinkJavaSource(handle="TokCmprSW", name="sw_CI", paramCount=3) 939 public static boolean startsWithNAND_CI(String srcStr, int sPos, int ePos, String... tokens) 940 { 941 final LV l = new LV(srcStr, sPos, ePos); 942 return NAND("startsWithNAND_CI", srcStr, tokens, cmp -> TokCmprSW.sw_CI(srcStr, l, cmp)); 943 } 944 945 946 // ******************************************************************************************** 947 // ******************************************************************************************** 948 // Starts With, Ends With 949 // ******************************************************************************************** 950 // ******************************************************************************************** 951 952 953 /** 954 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is'> 955 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 956 * @param srcStr Any non-null instance of {@code java.lang.String} 957 * @param token The {@code String} used in the comparison against {@code srcStr} 958 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 959 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 960 */ 961 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=3) 962 public static boolean startsWith(String srcStr, int sPos, int ePos, String token) 963 { return TokCmprSW.sw(srcStr, new LV(srcStr, sPos, ePos), token); } 964 965 /** 966 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is not'> 967 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 968 * @param srcStr Any non-null instance of {@code java.lang.String} 969 * @param token The {@code String} used in the comparison against {@code srcStr} 970 * <EMBED CLASS='external-html' DATA-FILE-ID='SWNODELIM'> 971 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 972 */ 973 @LinkJavaSource(handle="TokCmprSW", name="sw_CI", paramCount=3) 974 public static boolean startsWithIgnoreCase(String srcStr, int sPos, int ePos, String token) 975 { return TokCmprSW.sw_CI(srcStr, new LV(srcStr, sPos, ePos), token); } 976 977 /** 978 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is'> 979 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 980 * @param srcStr Any non-null instance of {@code java.lang.String} 981 * @param token The {@code String} used in the comparison against {@code srcStr} 982 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 983 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 984 */ 985 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=3) 986 public static boolean endsWith(String srcStr, int sPos, int ePos, String token) 987 { return TokCmprEW.ew(srcStr, new LV(srcStr, sPos, ePos), token); } 988 989 /** 990 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is not'> 991 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 992 * @param srcStr Any non-null instance of {@code java.lang.String} 993 * @param token The {@code String} used in the comparison against {@code srcStr} 994 * <EMBED CLASS='external-html' DATA-FILE-ID='EWNODELIM'> 995 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 996 */ 997 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=3) 998 public static boolean endsWithIgnoreCase(String srcStr, int sPos, int ePos, String token) 999 { return TokCmprEW.ew_CI(srcStr, new LV(srcStr, sPos, ePos), token); } 1000 1001 /** 1002 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is'> 1003 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 1004 * @param srcStr Any non-null instance of {@code java.lang.String} 1005 * @param token The {@code String} used in the comparison against {@code srcStr} 1006 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 1007 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 1008 */ 1009 public static boolean contains(String srcStr, int sPos, int ePos, String token) 1010 { return TokCmprCN.contains(srcStr, new LV(srcStr, sPos, ePos), token); } 1011 1012 /** 1013 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is not'> 1014 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 1015 * @param srcStr Any non-null instance of {@code java.lang.String} 1016 * @param token The {@code String} used in the comparison against {@code srcStr} 1017 * <EMBED CLASS='external-html' DATA-FILE-ID='CNNODELIM'> 1018 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 1019 */ 1020 public static boolean containsIgnoreCase(String srcStr, int sPos, int ePos, String token) 1021 { return TokCmprCN.containsIgnoreCase(srcStr, new LV(srcStr, sPos, ePos), token); } 1022 1023 1024 1025 1026 // ******************************************************************************************** 1027 // ******************************************************************************************** 1028 // CONTAINS OPTIMIZATION 1029 // ******************************************************************************************** 1030 // ******************************************************************************************** 1031 1032 1033 /** 1034 * Signifies that an {@code 'AND'} operation is required, but only for methods that implement 1035 * one of the {@code 'contains'} variants. 1036 */ 1037 protected static final byte AND = 0; 1038 1039 /** 1040 * Signifies that an {@code 'AND'} operation is required, but only for methods that implement 1041 * one of the {@code 'contains'} variants. 1042 */ 1043 protected static final byte OR = 1; 1044 1045 /** 1046 * Signifies that an {@code 'AND'} operation is required, but only for methods that implement 1047 * one of the {@code 'contains'} variants. 1048 */ 1049 protected static final byte NAND = 2; 1050 1051 /** 1052 * Signifies that an {@code 'AND'} operation is required, but only for methods that implement 1053 * one of the {@code 'contains'} variants. 1054 */ 1055 protected static final byte XOR = 3; 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 // ******************************************************************************************** 1085 // ******************************************************************************************** 1086 // ******************************************************************************************** 1087 // ******************************************************************************************** 1088 // ******************************************************************************************** 1089 // ******************************************************************************************** 1090 // StrCmpr Main Section 1091 // ******************************************************************************************** 1092 // ******************************************************************************************** 1093 // ******************************************************************************************** 1094 // ******************************************************************************************** 1095 // ******************************************************************************************** 1096 1097 1098 1099 // ******************************************************************************************** 1100 // ******************************************************************************************** 1101 // CONTAINS 1102 // ******************************************************************************************** 1103 // ******************************************************************************************** 1104 1105 1106 /** 1107 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is'> 1108 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1109 * @param srcStr Any non-null instance of {@code java.lang.String} 1110 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1111 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1112 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1113 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1114 */ 1115 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 1116 public static boolean containsOR 1117 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1118 { return TokCmprCN.CONTAINS(false, OR, srcStr, extraDelimiterTest, tokens); } 1119 1120 /** 1121 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is'> 1122 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1123 * @param srcStr Any non-null instance of {@code java.lang.String} 1124 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1125 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1126 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1127 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1128 */ 1129 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 1130 public static boolean containsAND 1131 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1132 { return TokCmprCN.CONTAINS(false, AND, srcStr, extraDelimiterTest, tokens); } 1133 1134 /** 1135 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is'> 1136 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1137 * @param srcStr Any non-null instance of {@code java.lang.String} 1138 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1139 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1140 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1141 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1142 */ 1143 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 1144 public static boolean containsXOR 1145 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1146 { return TokCmprCN.CONTAINS(false, XOR, srcStr, extraDelimiterTest, tokens); } 1147 1148 /** 1149 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is'> 1150 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1151 * @param srcStr Any non-null instance of {@code java.lang.String} 1152 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1153 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1154 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1155 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1156 */ 1157 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 1158 public static boolean containsNAND 1159 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1160 { return TokCmprCN.CONTAINS(false, NAND, srcStr, extraDelimiterTest, tokens); } 1161 1162 /** 1163 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is not'> 1164 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1165 * @param srcStr Any non-null instance of {@code java.lang.String} 1166 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1167 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1168 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1169 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1170 */ 1171 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 1172 public static boolean containsOR_CI 1173 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1174 { return TokCmprCN.CONTAINS(true, OR, srcStr, extraDelimiterTest, tokens); } 1175 1176 /** 1177 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is not'> 1178 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1179 * @param srcStr Any non-null instance of {@code java.lang.String} 1180 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1181 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1182 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1183 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1184 */ 1185 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 1186 public static boolean containsAND_CI 1187 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1188 { return TokCmprCN.CONTAINS(true, AND, srcStr, extraDelimiterTest, tokens); } 1189 1190 /** 1191 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is not'> 1192 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1193 * @param srcStr Any non-null instance of {@code java.lang.String} 1194 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1195 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1196 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1197 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1198 */ 1199 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 1200 public static boolean containsXOR_CI 1201 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1202 { return TokCmprCN.CONTAINS(true, XOR, srcStr, extraDelimiterTest, tokens); } 1203 1204 /** 1205 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is not'> 1206 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1207 * @param srcStr Any non-null instance of {@code java.lang.String} 1208 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1209 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1210 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1211 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1212 */ 1213 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=4) 1214 public static boolean containsNAND_CI 1215 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1216 { return TokCmprCN.CONTAINS(true, NAND, srcStr, extraDelimiterTest, tokens); } 1217 1218 1219 // ******************************************************************************************** 1220 // ******************************************************************************************** 1221 // STARTS-WITH, ENDS-WITH 1222 // ******************************************************************************************** 1223 // ******************************************************************************************** 1224 1225 1226 /** 1227 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is'> 1228 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1229 * @param srcStr Any non-null instance of {@code java.lang.String} 1230 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1231 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1232 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1233 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1234 * @see #XOR(String, String, String[], Predicate) 1235 */ 1236 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=4) 1237 public static boolean endsWithXOR 1238 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1239 { 1240 return XOR( 1241 "endsWithXOR", srcStr, tokens, 1242 cmp -> TokCmprEW.ew(srcStr, new LV(srcStr, 0, -1), extraDelimiterTest, cmp) 1243 ); 1244 } 1245 1246 /** 1247 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is'> 1248 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1249 * @param srcStr Any non-null instance of {@code java.lang.String} 1250 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1251 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1252 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1253 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1254 * @see #NAND(String, String, String[], Predicate) 1255 */ 1256 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=4) 1257 public static boolean endsWithNAND 1258 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1259 { 1260 return NAND( 1261 "endsWithNAND", srcStr, tokens, 1262 cmp -> TokCmprEW.ew(srcStr, new LV(srcStr, 0, -1), extraDelimiterTest, cmp) 1263 ); 1264 } 1265 1266 /** 1267 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is'> 1268 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1269 * @param srcStr Any non-null instance of {@code java.lang.String} 1270 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1271 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1272 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1273 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1274 * @see #XOR(String, String, String[], Predicate) 1275 */ 1276 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=4) 1277 public static boolean startsWithXOR 1278 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1279 { 1280 return XOR( 1281 "startsWithXOR", srcStr, tokens, 1282 cmp -> TokCmprSW.sw(srcStr, new LV(srcStr, 0, -1), extraDelimiterTest, cmp) 1283 ); 1284 } 1285 1286 /** 1287 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is'> 1288 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1289 * @param srcStr Any non-null instance of {@code java.lang.String} 1290 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1291 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1292 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1293 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1294 * @see #NAND(String, String, String[], Predicate) 1295 */ 1296 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=4) 1297 public static boolean startsWithNAND 1298 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1299 { 1300 return NAND( 1301 "startsWithNAND", srcStr, tokens, 1302 cmp -> TokCmprSW.sw(srcStr, new LV(srcStr, 0, -1), extraDelimiterTest, cmp) 1303 ); 1304 } 1305 1306 1307 // ******************************************************************************************** 1308 // ******************************************************************************************** 1309 // STARTS-WITH, ENDS-WITH - CASE INSENSITIVE 1310 // ******************************************************************************************** 1311 // ******************************************************************************************** 1312 1313 1314 /** 1315 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is not'> 1316 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1317 * @param srcStr Any non-null instance of {@code java.lang.String} 1318 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1319 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1320 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1321 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1322 * @see #endsWithIgnoreCase(String, String) 1323 * @see #XOR(String, String, String[], Predicate) 1324 */ 1325 public static boolean endsWithXOR_CI 1326 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1327 { 1328 return XOR( 1329 "endsWithXOR_CI", srcStr, tokens, 1330 cmp -> endsWithIgnoreCase(srcStr, extraDelimiterTest, cmp) 1331 ); 1332 } 1333 1334 /** 1335 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is not'> 1336 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1337 * @param srcStr Any non-null instance of {@code java.lang.String} 1338 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1339 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1340 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1341 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1342 * @see #endsWithIgnoreCase(String, String) 1343 * @see #NAND(String, String, String[], Predicate) 1344 */ 1345 public static boolean endsWithNAND_CI 1346 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1347 { 1348 return NAND( 1349 "endsWithNAND_CI", srcStr, tokens, 1350 cmp -> endsWithIgnoreCase(srcStr, extraDelimiterTest, cmp) 1351 ); 1352 } 1353 1354 /** 1355 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is not'> 1356 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1357 * @param srcStr Any non-null instance of {@code java.lang.String} 1358 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1359 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1360 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1361 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1362 * @see #startsWithIgnoreCase(String, Predicate, String) 1363 * @see #XOR(String, String, String[], Predicate) 1364 */ 1365 public static boolean startsWithXOR_CI 1366 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1367 { 1368 return XOR( 1369 "startsWithXOR_CI", srcStr, tokens, 1370 cmp -> startsWithIgnoreCase(srcStr, extraDelimiterTest, cmp) 1371 ); 1372 } 1373 1374 /** 1375 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is not'> 1376 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC> 1377 * @param srcStr Any non-null instance of {@code java.lang.String} 1378 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1379 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1380 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1381 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET> 1382 * @see #startsWithIgnoreCase(String, Predicate, String) 1383 * @see #NAND(String, String, String[], Predicate) 1384 */ 1385 public static boolean startsWithNAND_CI 1386 (String srcStr, Predicate<Character> extraDelimiterTest, String... tokens) 1387 { 1388 return NAND( 1389 "startsWithNAND_CI", srcStr, tokens, 1390 cmp -> startsWithIgnoreCase(srcStr, extraDelimiterTest, cmp) 1391 ); 1392 } 1393 1394 1395 // ******************************************************************************************** 1396 // ******************************************************************************************** 1397 // Three Standard Java Methods, Added Token Checking 1398 // ******************************************************************************************** 1399 // ******************************************************************************************** 1400 1401 1402 /** 1403 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is'> 1404 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 1405 * @param srcStr Any non-null instance of {@code java.lang.String} 1406 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1407 * @param token The {@code String} used in the comparison against {@code srcStr} 1408 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1409 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 1410 */ 1411 public static boolean startsWith 1412 (String srcStr, Predicate<Character> extraDelimiterTest, String token) 1413 { 1414 return srcStr.startsWith(token) 1415 && ( (token.length() == srcStr.length()) 1416 || Character.isWhitespace(srcStr.charAt(token.length())) 1417 || extraDelimiterTest.test(srcStr.charAt(token.length()))); 1418 } 1419 1420 /** 1421 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is'> 1422 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 1423 * @param srcStr Any non-null instance of {@code java.lang.String} 1424 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1425 * @param token The {@code String} used in the comparison against {@code srcStr} 1426 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1427 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 1428 */ 1429 public static boolean endsWith 1430 (String srcStr, Predicate<Character> extraDelimiterTest, String token) 1431 { 1432 int tokenLen = token.length(); 1433 1434 return srcStr.endsWith(token) 1435 && ( ((srcStr.length() - tokenLen) == 0) 1436 || Character.isWhitespace(srcStr.charAt(srcStr.length() - tokenLen - 1)) 1437 || extraDelimiterTest.test(srcStr.charAt(srcStr.length() - tokenLen - 1))); 1438 } 1439 1440 /** 1441 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is'> 1442 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 1443 * @param srcStr Any non-null instance of {@code java.lang.String} 1444 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1445 * @param token The {@code String} used in the comparison against {@code srcStr} 1446 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1447 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 1448 */ 1449 public static boolean contains 1450 (String srcStr, Predicate<Character> extraDelimiterTest, String token) 1451 { 1452 int tokenLen = token.length(); 1453 int loopLen = srcStr.length() - tokenLen; 1454 1455 for (int i=0; i <= loopLen; i++) 1456 1457 if ( srcStr.regionMatches(i, token, 0, tokenLen) 1458 && ( (i == 0) 1459 || Character.isWhitespace(srcStr.charAt(i - 1)) 1460 || extraDelimiterTest.test(srcStr.charAt(i - 1))) 1461 && ( ((i + tokenLen) == srcStr.length()) 1462 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 1463 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 1464 ) 1465 1466 return true; 1467 1468 return false; 1469 } 1470 1471 1472 // ******************************************************************************************** 1473 // ******************************************************************************************** 1474 // IGNORE-CASE METHODS 1475 // ******************************************************************************************** 1476 // ******************************************************************************************** 1477 1478 1479 /** 1480 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is not'> 1481 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 1482 * @param srcStr Any non-null instance of {@code java.lang.String} 1483 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1484 * @param token The {@code String} used in the comparison against {@code srcStr} 1485 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1486 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 1487 */ 1488 public static boolean startsWithIgnoreCase 1489 (String srcStr, Predicate<Character> extraDelimiterTest, String token) 1490 { 1491 return srcStr.regionMatches(true, 0, token, 0, token.length()) 1492 && ( (token.length() == srcStr.length()) 1493 || Character.isWhitespace(srcStr.charAt(token.length())) 1494 || extraDelimiterTest.test(srcStr.charAt(token.length()))); 1495 } 1496 1497 /** 1498 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is not'> 1499 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 1500 * @param srcStr Any non-null instance of {@code java.lang.String} 1501 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1502 * @param token The {@code String} used in the comparison against {@code srcStr} 1503 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1504 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 1505 */ 1506 public static boolean endsWithIgnoreCase 1507 (String srcStr, Predicate<Character> extraDelimiterTest, String token) 1508 { 1509 int tokenLen = token.length(); 1510 1511 return srcStr.regionMatches(true, srcStr.length() - tokenLen, token, 0, tokenLen) 1512 && ( ((srcStr.length() - tokenLen) == 0) 1513 || Character.isWhitespace(srcStr.charAt(srcStr.length() - tokenLen - 1)) 1514 || extraDelimiterTest.test(srcStr.charAt(srcStr.length() - tokenLen - 1))); 1515 } 1516 1517 /** 1518 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is not'> 1519 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C> 1520 * @param srcStr Any non-null instance of {@code java.lang.String} 1521 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1522 * @param token The {@code String} used in the comparison against {@code srcStr} 1523 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1524 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C> 1525 */ 1526 public static boolean containsIgnoreCase 1527 (String srcStr, Predicate<Character> extraDelimiterTest, String token) 1528 { 1529 return TokCmprCN.containsIgnoreCase 1530 (srcStr, new LV(srcStr, 0, srcStr.length()), extraDelimiterTest, token); 1531 } 1532 1533 1534 1535 1536 1537 1538 1539 // ******************************************************************************************** 1540 // ******************************************************************************************** 1541 // ******************************************************************************************** 1542 // ******************************************************************************************** 1543 // ******************************************************************************************** 1544 // StrCmpr Main Section 1545 // ******************************************************************************************** 1546 // ******************************************************************************************** 1547 // ******************************************************************************************** 1548 // ******************************************************************************************** 1549 // ******************************************************************************************** 1550 1551 1552 1553 1554 1555 1556 1557 1558 // ******************************************************************************************** 1559 // ******************************************************************************************** 1560 // CONTAINS - Case Sensitive 1561 // ******************************************************************************************** 1562 // ******************************************************************************************** 1563 1564 1565 /** 1566 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is'> 1567 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1568 * @param srcStr Any non-null instance of {@code java.lang.String} 1569 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1570 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1571 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1572 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1573 */ 1574 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=6) 1575 public static boolean containsOR( 1576 String srcStr, int sPos, int ePos, 1577 Predicate<Character> extraDelimiterTest, String... tokens 1578 ) 1579 { 1580 final LV l = new LV(srcStr, sPos, ePos); 1581 return TokCmprCN.CONTAINS(false, OR, l, srcStr, extraDelimiterTest, tokens); 1582 } 1583 1584 /** 1585 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is'> 1586 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1587 * @param srcStr Any non-null instance of {@code java.lang.String} 1588 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1589 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1590 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1591 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1592 */ 1593 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=6) 1594 public static boolean containsAND( 1595 String srcStr, int sPos, int ePos, 1596 Predicate<Character> extraDelimiterTest, String... tokens) 1597 { 1598 final LV l = new LV(srcStr, sPos, ePos); 1599 return TokCmprCN.CONTAINS(false, AND, l, srcStr, extraDelimiterTest, tokens); 1600 } 1601 1602 /** 1603 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is'> 1604 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1605 * @param srcStr Any non-null instance of {@code java.lang.String} 1606 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1607 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1608 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1609 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1610 */ 1611 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=6) 1612 public static boolean containsXOR( 1613 String srcStr, int sPos, int ePos, 1614 Predicate<Character> extraDelimiterTest, String... tokens 1615 ) 1616 { 1617 final LV l = new LV(srcStr, sPos, ePos); 1618 return TokCmprCN.CONTAINS(false, XOR, l, srcStr, extraDelimiterTest, tokens); 1619 } 1620 1621 /** 1622 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is'> 1623 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1624 * @param srcStr Any non-null instance of {@code java.lang.String} 1625 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1626 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1627 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1628 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1629 */ 1630 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=6) 1631 public static boolean containsNAND( 1632 String srcStr, int sPos, int ePos, 1633 Predicate<Character> extraDelimiterTest, String... tokens 1634 ) 1635 { 1636 final LV l = new LV(srcStr, sPos, ePos); 1637 return TokCmprCN.CONTAINS(false, NAND, l, srcStr, extraDelimiterTest, tokens); 1638 } 1639 1640 1641 // ******************************************************************************************** 1642 // ******************************************************************************************** 1643 // CONTAINS - Case In-Sensitive 1644 // ******************************************************************************************** 1645 // ******************************************************************************************** 1646 1647 1648 /** 1649 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is not'> 1650 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1651 * @param srcStr Any non-null instance of {@code java.lang.String} 1652 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1653 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1654 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1655 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1656 */ 1657 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=6) 1658 public static boolean containsOR_CI( 1659 String srcStr, int sPos, int ePos, 1660 Predicate<Character> extraDelimiterTest, String... tokens 1661 ) 1662 { 1663 final LV l = new LV(srcStr, sPos, ePos); 1664 return TokCmprCN.CONTAINS(true, OR, l, srcStr, extraDelimiterTest, tokens); 1665 } 1666 1667 /** 1668 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is not'> 1669 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1670 * @param srcStr Any non-null instance of {@code java.lang.String} 1671 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1672 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1673 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1674 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1675 */ 1676 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=6) 1677 public static boolean containsAND_CI( 1678 String srcStr, int sPos, int ePos, 1679 Predicate<Character> extraDelimiterTest, String... tokens 1680 ) 1681 { 1682 final LV l = new LV(srcStr, sPos, ePos); 1683 return TokCmprCN.CONTAINS(true, AND, l, srcStr, extraDelimiterTest, tokens); 1684 } 1685 1686 /** 1687 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is not'> 1688 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1689 * @param srcStr Any non-null instance of {@code java.lang.String} 1690 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1691 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1692 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1693 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1694 */ 1695 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=6) 1696 public static boolean containsXOR_CI( 1697 String srcStr, int sPos, int ePos, 1698 Predicate<Character> extraDelimiterTest, String... tokens 1699 ) 1700 { 1701 final LV l = new LV(srcStr, sPos, ePos); 1702 return TokCmprCN.CONTAINS(true, XOR, l, srcStr, extraDelimiterTest, tokens); 1703 } 1704 1705 /** 1706 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is not'> 1707 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1708 * @param srcStr Any non-null instance of {@code java.lang.String} 1709 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1710 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1711 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 1712 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1713 */ 1714 @LinkJavaSource(handle="TokCmprCN", name="CONTAINS", paramCount=6) 1715 public static boolean containsNAND_CI( 1716 String srcStr, int sPos, int ePos, 1717 Predicate<Character> extraDelimiterTest, String... tokens 1718 ) 1719 { 1720 final LV l = new LV(srcStr, sPos, ePos); 1721 1722 return TokCmprCN.CONTAINS(true, NAND, l, srcStr, extraDelimiterTest, tokens); 1723 } 1724 1725 1726 // ******************************************************************************************** 1727 // ******************************************************************************************** 1728 // STARTS-WITH, ENDS-WITH, Case-Sensitive 1729 // ******************************************************************************************** 1730 // ******************************************************************************************** 1731 1732 1733 /** 1734 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is'> 1735 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1736 * @param srcStr Any non-null instance of {@code java.lang.String} 1737 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1738 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1739 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1740 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1741 * @see #XOR(String, String, String[], Predicate) 1742 */ 1743 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=4) 1744 public static boolean endsWithXOR( 1745 String srcStr, int sPos, int ePos, 1746 Predicate<Character> extraDelimiterTest, String... tokens 1747 ) 1748 { 1749 final LV l = new LV(srcStr, sPos, ePos); 1750 1751 return XOR( 1752 "endsWithXOR", srcStr, tokens, 1753 cmp -> TokCmprEW.ew(srcStr, l, extraDelimiterTest, cmp) 1754 ); 1755 } 1756 1757 /** 1758 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is'> 1759 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1760 * @param srcStr Any non-null instance of {@code java.lang.String} 1761 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1762 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1763 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1764 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1765 * @see #NAND(String, String, String[], Predicate) 1766 */ 1767 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=4) 1768 public static boolean endsWithNAND( 1769 String srcStr, int sPos, int ePos, 1770 Predicate<Character> extraDelimiterTest, String... tokens 1771 ) 1772 { 1773 final LV l = new LV(srcStr, sPos, ePos); 1774 1775 return NAND( 1776 "endsWithNAND", srcStr, tokens, 1777 cmp -> TokCmprEW.ew(srcStr, l, extraDelimiterTest, cmp) 1778 ); 1779 } 1780 1781 /** 1782 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is'> 1783 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1784 * @param srcStr Any non-null instance of {@code java.lang.String} 1785 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1786 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1787 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1788 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1789 * @see #XOR(String, String, String[], Predicate) 1790 */ 1791 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=4) 1792 public static boolean startsWithXOR( 1793 String srcStr, int sPos, int ePos, 1794 Predicate<Character> extraDelimiterTest, String... tokens 1795 ) 1796 { 1797 final LV l = new LV(srcStr, sPos, ePos); 1798 1799 return XOR( 1800 "startsWithXOR", srcStr, tokens, 1801 cmp -> TokCmprSW.sw(srcStr, l, extraDelimiterTest, cmp) 1802 ); 1803 } 1804 1805 /** 1806 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is'> 1807 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1808 * @param srcStr Any non-null instance of {@code java.lang.String} 1809 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1810 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1811 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1812 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1813 * @see #NAND(String, String, String[], Predicate) 1814 */ 1815 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=4) 1816 public static boolean startsWithNAND( 1817 String srcStr, int sPos, int ePos, 1818 Predicate<Character> extraDelimiterTest, String... tokens 1819 ) 1820 { 1821 final LV l = new LV(srcStr, sPos, ePos); 1822 1823 return NAND( 1824 "startsWithNAND", srcStr, tokens, 1825 cmp -> TokCmprSW.sw(srcStr, l, extraDelimiterTest, cmp) 1826 ); 1827 } 1828 1829 1830 // ******************************************************************************************** 1831 // ******************************************************************************************** 1832 // STARTS-WITH, ENDS-WITH - CASE INSENSITIVE 1833 // ******************************************************************************************** 1834 // ******************************************************************************************** 1835 1836 1837 /** 1838 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is not'> 1839 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1840 * @param srcStr Any non-null instance of {@code java.lang.String} 1841 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1842 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1843 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1844 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1845 * @see #XOR(String, String, String[], Predicate) 1846 */ 1847 @LinkJavaSource(handle="TokCmprEW", name="ew_CI", paramCount=4) 1848 public static boolean endsWithXOR_CI( 1849 String srcStr, int sPos, int ePos, 1850 Predicate<Character> extraDelimiterTest, String... tokens 1851 ) 1852 { 1853 final LV l = new LV(srcStr, sPos, ePos); 1854 1855 return XOR( 1856 "endsWithXOR_CI", srcStr, tokens, 1857 cmp -> TokCmprEW.ew_CI(srcStr, l, extraDelimiterTest, cmp) 1858 ); 1859 } 1860 1861 /** 1862 * <EMBED CLASS=defs DATA-DESC='does not ends with any' DATA-CI='is not'> 1863 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1864 * @param srcStr Any non-null instance of {@code java.lang.String} 1865 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1866 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1867 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1868 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1869 * @see #NAND(String, String, String[], Predicate) 1870 */ 1871 @LinkJavaSource(handle="TokCmprEW", name="ew_CI", paramCount=4) 1872 public static boolean endsWithNAND_CI( 1873 String srcStr, int sPos, int ePos, 1874 Predicate<Character> extraDelimiterTest, String... tokens 1875 ) 1876 { 1877 final LV l = new LV(srcStr, sPos, ePos); 1878 1879 return NAND( 1880 "endsWithNAND_CI", srcStr, tokens, 1881 cmp -> TokCmprEW.ew_CI(srcStr, l, extraDelimiterTest, cmp) 1882 ); 1883 } 1884 1885 /** 1886 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is not'> 1887 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1888 * @param srcStr Any non-null instance of {@code java.lang.String} 1889 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1890 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1891 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1892 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1893 * @see #XOR(String, String, String[], Predicate) 1894 */ 1895 @LinkJavaSource(handle="TokCmprSW", name="sw_CI", paramCount=4) 1896 public static boolean startsWithXOR_CI( 1897 String srcStr, int sPos, int ePos, 1898 Predicate<Character> extraDelimiterTest, String... tokens 1899 ) 1900 { 1901 final LV l = new LV(srcStr, sPos, ePos); 1902 1903 return XOR( 1904 "startsWithXOR_CI", srcStr, tokens, 1905 cmp -> TokCmprSW.sw_CI(srcStr, l, extraDelimiterTest, cmp) 1906 ); 1907 } 1908 1909 /** 1910 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is not'> 1911 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_SE> 1912 * @param srcStr Any non-null instance of {@code java.lang.String} 1913 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1914 * @param tokens The {@code String's} used in the comparison against {@code 'srcStr'} 1915 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1916 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_SE> 1917 * @see #NAND(String, String, String[], Predicate) 1918 */ 1919 @LinkJavaSource(handle="TokCmprSW", name="sw_CI", paramCount=4) 1920 public static boolean startsWithNAND_CI( 1921 String srcStr, int sPos, int ePos, 1922 Predicate<Character> extraDelimiterTest, String... tokens 1923 ) 1924 { 1925 final LV l = new LV(srcStr, sPos, ePos); 1926 1927 return NAND( 1928 "startsWithNAND_CI", srcStr, tokens, 1929 cmp -> TokCmprSW.sw_CI(srcStr, l, extraDelimiterTest, cmp) 1930 ); 1931 } 1932 1933 1934 // ******************************************************************************************** 1935 // ******************************************************************************************** 1936 // simple, with "extra-delimiter" 1937 // ******************************************************************************************** 1938 // ******************************************************************************************** 1939 1940 1941 /** 1942 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is'> 1943 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 1944 * @param srcStr Any non-null instance of {@code java.lang.String} 1945 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1946 * @param token The {@code String} used in the comparison against {@code srcStr} 1947 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1948 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 1949 */ 1950 @LinkJavaSource(handle="TokCmprSW", name="sw", paramCount=4) 1951 public static boolean startsWith 1952 (String srcStr, int sPos, int ePos, Predicate<Character> extraDelimiterTest, String token) 1953 { return TokCmprSW.sw(srcStr, new LV(srcStr, sPos, ePos), extraDelimiterTest, token); } 1954 1955 /** 1956 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is not'> 1957 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 1958 * @param srcStr Any non-null instance of {@code java.lang.String} 1959 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1960 * @param token The {@code String} used in the comparison against {@code srcStr} 1961 * <EMBED CLASS='external-html' DATA-FILE-ID=SWDELIM> 1962 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 1963 */ 1964 @LinkJavaSource(handle="TokCmprSW", name="sw_CI", paramCount=4) 1965 public static boolean startsWithIgnoreCase 1966 (String srcStr, int sPos, int ePos, Predicate<Character> extraDelimiterTest, String token) 1967 { return TokCmprSW.sw_CI(srcStr, new LV(srcStr, sPos, ePos), extraDelimiterTest, token); } 1968 1969 /** 1970 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is'> 1971 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 1972 * @param srcStr Any non-null instance of {@code java.lang.String} 1973 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1974 * @param token The {@code String} used in the comparison against {@code srcStr} 1975 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1976 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 1977 */ 1978 @LinkJavaSource(handle="TokCmprEW", name="ew", paramCount=4) 1979 public static boolean endsWith 1980 (String srcStr, int sPos, int ePos, Predicate<Character> extraDelimiterTest, String token) 1981 { return TokCmprEW.ew(srcStr, new LV(srcStr, sPos, ePos), extraDelimiterTest, token); } 1982 1983 /** 1984 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is not'> 1985 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 1986 * @param srcStr Any non-null instance of {@code java.lang.String} 1987 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 1988 * @param token The {@code String} used in the comparison against {@code srcStr} 1989 * <EMBED CLASS='external-html' DATA-FILE-ID=EWDELIM> 1990 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 1991 */ 1992 @LinkJavaSource(handle="TokCmprEW", name="ew_CI", paramCount=4) 1993 public static boolean endsWithIgnoreCase 1994 (String srcStr, int sPos, int ePos, Predicate<Character> extraDelimiterTest, String token) 1995 { return TokCmprEW.ew_CI(srcStr, new LV(srcStr, sPos, ePos), extraDelimiterTest, token); } 1996 1997 /** 1998 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is'> 1999 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 2000 * @param srcStr Any non-null instance of {@code java.lang.String} 2001 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 2002 * @param token The {@code String} used in the comparison against {@code srcStr} 2003 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 2004 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 2005 */ 2006 public static boolean contains 2007 (String srcStr, int sPos, int ePos, Predicate<Character> extraDelimiterTest, String token) 2008 { return TokCmprCN.contains(srcStr, new LV(srcStr, sPos, ePos), extraDelimiterTest, token); } 2009 2010 /** 2011 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is not'> 2012 * <EMBED CLASS='external-html' DATA-FILE-ID=STC_DESC_1C_SE> 2013 * @param srcStr Any non-null instance of {@code java.lang.String} 2014 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=XTRADELIM> 2015 * @param token The {@code String} used in the comparison against {@code srcStr} 2016 * <EMBED CLASS='external-html' DATA-FILE-ID=CNDELIM> 2017 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STC_RET_1C_SE> 2018 */ 2019 public static boolean containsIgnoreCase 2020 (String srcStr, int sPos, int ePos, Predicate<Character> extraDelimiterTest, String token) 2021 { 2022 return TokCmprCN.containsIgnoreCase 2023 (srcStr, new LV(srcStr, sPos, ePos), extraDelimiterTest, token); 2024 } 2025 2026 2027}