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.Excuse; 009import Torello.JavaDoc.LinkJavaSource; 010 011/** 012 * Class String-Compare provides an exhaustive-combinatoric suite of methods that extend the 013 * basic Java <CODE>String</CODE> methods <CODE>equals, contains, startsWith</CODE> and 014 * <CODE>endsWith</CODE>. 015 * 016 * <EMBED CLASS='external-html' DATA-FILE-ID=STR_CMPR> 017 */ 018@StaticFunctional(Excused={"DEBUG", "DEBUG_LOG"}, Excuses={Excuse.DEBUGGING, Excuse.DEBUGGING}) 019@Torello.JavaDoc.CSSLinks(FileNames="Strings.css") 020public class StrCmpr 021{ 022 private StrCmpr() { } 023 024 /** 025 * Utility field. You may choose to set this variable to true, and the following 026 * {@code String} commands will print to an internally stored {@code Consumer<String> DEBUG_LOG} 027 * class that may be set. This is generally a very minor drain on code-efficiency. When this 028 * flag is set to {@code FALSE}, a short {@code if-statement evaluation} <I>still occurs even 029 * when the flag is false</I> on each occasion that the string-comparison loops identify and 030 * return a match. This is very minor performance loss, and does provide quite a lot of help 031 * to those trying to identify difficult to notice problems with partial-{@code String} 032 * comparisons. 033 * 034 * <BR /><BR /><B CLASS=JDDescLabel>Required Setting:</B> 035 * 036 * <BR />In order to use this minor Debugging Feature, it is necessary to provide a 037 * {@code Consumer<String>} to public field {@link #DEBUG_LOG}! This field is a {@code public} 038 * and {@code static} field, which will be used by any invocation of the methods in this class. 039 * This {@code String}-consumer may do anything you would like it to do with the provided 040 * Debug-{@code String} data. 041 * 042 * <BR /><BR /><B CLASS=JDDescLabel>String-Format:</B> 043 * 044 * <BR />The {@code String} that is ultimately sent to the {@code Consumer<String>} you provide 045 * will be formatted, as below, in the following Code-Snippet: 046 * 047 * <BR /><DIV CLASS=SNIP>{@code 048 * private static void PRNT(String methodName, String srcStr, String compareStr) 049 * { DEBUG_LOG.accept(methodName + "-MATCH[" + srcStr + ", " + compareStr + "] "); } 050 * }</DIV> 051 * 052 * <BR /><BR />Generally, you would assign a writer that looks like something the Lambda-Target 053 * / Function-Pointer assignment in the snippet below: 054 * 055 * <BR /><DIV CLASS=SNIP>{@code 056 * StrCmpr.DEBUG_LOG = (String logInfoStr) -> System.out.println(logInfoStr); 057 * }</DIV> 058 * 059 * <BR /><BR />Finally, if you are using this field, please note that any of the methods whose 060 * name ends with the phrase "IgnoreCase" <I>will not print to the {@link #DEBUG_LOG}</I>. 061 * This is primarily because these are all <I>single-argument comparisons</I>, and logging 062 * would be of only minor benefit. 063 * 064 * <BR /><BR />The primary value of a debug-log is the ability to identify whether / when a 065 * particular substring from a list of substrings actually matched. 066 */ 067 public static boolean DEBUG = false; 068 069 /** 070 * This object reference <I><B>cannot remain null when the field {@link #DEBUG} is set to 071 * {@code TRUE}</B></I>. If you have turned {@link #DEBUG} on (by setting the field to 072 * {@code TRUE}), and this is null, then a {@code NullPointerException} will be thrown on the 073 * very next invocation of any of the methods in this class. 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 078 * perfectly 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 * <BR /><BR /> 084 * </LI> 085 * 086 * <LI> This is a best-efforts string-comparison package that would sacrifice quite a bit of its 087 * utility if it were expected to maintain multiple instances of this class just to have 088 * {@code StrCmpr} debug operations work in multiple-threads. Code readability necessitates 089 * keeping this a class with only <B><I>static methods.</I></B> 090 * <BR /><BR /> 091 * </LI> 092 * 093 * <LI> Two threads making calls to this class {@code StrCmpr} might see log-writes that, sadly, 094 * look like they 'interlaced' (crashed), but even when this occasions, reading the log 095 * wouldn't be that difficult anyway. 096 * </LI> 097 * </OL> 098 */ 099 public static Consumer<String> DEBUG_LOG = null; 100 101 private static void PRNT(String methodName, String srcStr, String compareStr) 102 { DEBUG_LOG.accept(methodName + srcStr + ", " + compareStr + "] "); } 103 104 /** 105 * This performs the internal AND. It expects a comparison {@code Predicate} in order for the 106 * comparison to work. 107 * 108 * @param methodName If printing-debug information is expected, by the DEBUG global-variable, 109 * this {@code String} is used. 110 * 111 * @param srcStr This is the same source-string parameter from all the methods in this class. 112 * @param compareStr This is the same var-args string array from all the methods in this class. 113 * 114 * @param pred This is the comparison {@code Predicate} provided by the methods in this class 115 * that call this method. 116 * 117 * @return The AND of these {@code String's}, using the provided {@code Predicate}. 118 * 119 * @throws StrCmprException This exception shall throw if there are any invalid 120 * {@code String's} in the compare-string parameter array. 121 * 122 * <BR /><BR /><DIV CLASS=JDHint> 123 * <B STYLE="color: red;">Note:</B> The conditions that would cause this exception to throw 124 * should remind the reader that <I><B>each and every method here</I></B> will throw exception 125 * {@code 'StrCmprException'} if invalid input has been passed to the "Compare String" 126 * Variable-Arguments {@code String...} Parameter. 127 * </DIV> 128 */ 129 protected static boolean AND 130 (String methodName, String srcStr, String[] compareStr, Predicate<String> pred) 131 { 132 StrCmprException.check(compareStr); 133 134 for (String cmp: compareStr) 135 136 if (! pred.test(cmp)) 137 { 138 if (DEBUG) PRNT(methodName + "-MATCHFAIL", srcStr, cmp); 139 return false; 140 } 141 142 return true; 143 } 144 145 /** 146 * This performs the internal NAND. It expects a comparison {@code Predicate} in order for the 147 * comparison to work. 148 * 149 * @param methodName If printing-debug information is expected, by the DEBUG global-variable, 150 * this {@code String} is used. 151 * 152 * @param srcStr This is the same source-string parameter from all the methods in this class. 153 * @param compareStr This is the same var-args string array from all the methods in this class. 154 * 155 * @param pred This is the comparison {@code Predicate} provided by the methods in this class 156 * that call this method. 157 * 158 * @return The NAND of these {@code String's}, using the provided {@code Predicate}. 159 * 160 * @throws StrCmprException This exception shall throw if there are any invalid 161 * {@code String's} in the compare-string parameter array. 162 * 163 * <BR /><BR /><DIV CLASS=JDHint> 164 * <B STYLE="color: red;">Note:</B> The conditions that would cause this exception to throw 165 * should remind the reader that <I><B>each and every method here</I></B> will throw exception 166 * {@code 'StrCmprException'} if invalid input has been passed to the "Compare String" 167 * Variable-Arguments {@code String...} Parameter. 168 * </DIV> 169 */ 170 protected static boolean NAND 171 (String methodName, String srcStr, String[] compareStr, Predicate<String> pred) 172 { 173 StrCmprException.check(compareStr); 174 175 for (String cmp: compareStr) 176 177 if (pred.test(cmp)) 178 { 179 if (DEBUG) PRNT(methodName + "-MATCH", srcStr, cmp); 180 return false; 181 } 182 183 return true; 184 } 185 186 /** 187 * This performs the internal OR. It expects a comparison {@code Predicate} in order for the 188 * comparison to work. 189 * 190 * @param methodName If printing-debug information is expected, by the DEBUG global-variable, 191 * this {@code String} is used. 192 * 193 * @param srcStr This is the same source-string parameter from all the methods in this class. 194 * @param compareStr This is the same var-args string array from all the methods in this class. 195 * 196 * @param pred This is the comparison {@code Predicate} provided by the methods in this class 197 * that call this method. 198 * 199 * @return The OR of these {@code String's}, using the provided {@code Predicate}. 200 * 201 * @throws StrCmprException This exception shall throw if there are any invalid 202 * {@code String's} in the compare-string parameter array. 203 * 204 * <BR /><BR /><DIV CLASS=JDHint> 205 * <B STYLE="color: red;">Note:</B> The conditions that would cause this exception to throw 206 * should remind the reader that <I><B>each and every method here</I></B> will throw exception 207 * {@code 'StrCmprException'} if invalid input has been passed to the "Compare String" 208 * Variable-Arguments {@code String...} Parameter. 209 * </DIV> 210 */ 211 protected static boolean OR 212 (String methodName, String srcStr, String[] compareStr, Predicate<String> pred) 213 { 214 StrCmprException.check(compareStr); 215 216 for (String cmp: compareStr) 217 218 if (pred.test(cmp)) 219 { 220 if (DEBUG) PRNT(methodName + "-MATCH", srcStr, cmp); 221 return true; 222 } 223 224 return false; 225 } 226 227 /** 228 * This performs the internal XOR. It expects a comparison {@code Predicate} in order for the 229 * comparison to work. 230 * 231 * @param methodName If printing-debug information is expected, by the DEBUG global-variable, 232 * this {@code String} is used. 233 * 234 * @param srcStr This is the same source-string parameter from all the methods in this class. 235 * @param compareStr This is the same var-args string array from all the methods in this class. 236 * 237 * @param pred This is the comparison {@code Predicate} provided by the methods in this class 238 * that call this method. 239 * 240 * @return The XOR of these {@code String's}, using the provided {@code Predicate}. 241 * 242 * @throws StrCmprException This exception shall throw if there are any invalid 243 * {@code String's} in the compare-string parameter array. 244 * 245 * <BR /><BR /><DIV CLASS=JDHint> 246 * <B STYLE="color: red;">Note:</B> The conditions that would cause this exception to throw 247 * should remind the reader that <I><B>each and every method here</I></B> will throw exception 248 * {@code 'StrCmprException'} if invalid input has been passed to the "Compare String" 249 * Variable-Arguments {@code String...} Parameter. 250 * </DIV> 251 */ 252 protected static boolean XOR 253 (String methodName, String srcStr, String[] compareStr, Predicate<String> pred) 254 { 255 StrCmprException.check(compareStr); 256 257 int count=0; 258 259 for (String cmp: compareStr) 260 261 if (pred.test(cmp)) 262 263 if (++count > 1) 264 { 265 if (DEBUG) PRNT(methodName + "-MATCH", srcStr, cmp); 266 return false; 267 } 268 269 return count == 1; 270 } 271 272 273 274 // ******************************************************************************************** 275 // ******************************************************************************************** 276 // ******************************************************************************************** 277 // ******************************************************************************************** 278 // ******************************************************************************************** 279 // StrCmpr Main Section #1 280 // ******************************************************************************************** 281 // ******************************************************************************************** 282 // ******************************************************************************************** 283 // ******************************************************************************************** 284 // ******************************************************************************************** 285 286 287 288 // ******************************************************************************************** 289 // ******************************************************************************************** 290 // EQUALS 291 // ******************************************************************************************** 292 // ******************************************************************************************** 293 294 295 /** 296 * <EMBED CLASS=defs DATA-DESC='equals exactly one' DATA-CI='is'> 297 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 298 * @param srcStr Any non-null instance of a {@code java.lang.String} 299 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 300 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 301 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 302 * @see #XOR(String, String, String[], Predicate) 303 */ 304 public static boolean equalsXOR(String srcStr, String... compareStr) 305 { return XOR("equalsXOR", srcStr, compareStr, cmp -> srcStr.equals(cmp)); } 306 307 /** 308 * <EMBED CLASS=defs DATA-DESC='does not equal any' DATA-CI='is'> 309 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 310 * @param srcStr Any non-null instance of a {@code java.lang.String} 311 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 312 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 313 * @see #NAND(String, String, String[], Predicate) 314 */ 315 public static boolean equalsNAND(String srcStr, String... compareStr) 316 { return NAND("equalsNAND", srcStr, compareStr, cmp -> srcStr.equals(cmp)); } 317 318 /** 319 * <EMBED CLASS=defs DATA-DESC='equals exactly one' DATA-CI='is not'> 320 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 321 * @param srcStr Any non-null instance of a {@code java.lang.String} 322 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 323 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 324 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 325 * @see #XOR(String, String, String[], Predicate) 326 */ 327 public static boolean equalsXOR_CI(String srcStr, String... compareStr) 328 { return XOR("equalsXOR_CI", srcStr, compareStr, cmp -> srcStr.equalsIgnoreCase(cmp)); } 329 330 /** 331 * <EMBED CLASS=defs DATA-DESC='does not equal any' DATA-CI='is not'> 332 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 333 * @param srcStr Any non-null instance of a {@code java.lang.String} 334 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 335 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 336 * @see #NAND(String, String, String[], Predicate) 337 */ 338 public static boolean equalsNAND_CI(String srcStr, String... compareStr) 339 { return NAND("equalsNAND_CI", srcStr, compareStr, cmp -> srcStr.equalsIgnoreCase(cmp)); } 340 341 342 // ******************************************************************************************** 343 // ******************************************************************************************** 344 // CONTAINS 345 // ******************************************************************************************** 346 // ******************************************************************************************** 347 348 349 /** 350 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is'> 351 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 352 * @param srcStr Any non-null instance of a {@code java.lang.String} 353 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 354 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 355 */ 356 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=4) 357 public static boolean containsOR(String srcStr, String... compareStr) 358 { return CmprCN.CONTAINS(false, OR, srcStr, compareStr); } 359 360 /** 361 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is'> 362 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 363 * @param srcStr Any non-null instance of a {@code java.lang.String} 364 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 365 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 366 */ 367 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=4) 368 public static boolean containsAND(String srcStr, String... compareStr) 369 { return CmprCN.CONTAINS(false, AND, srcStr, compareStr); } 370 371 /** 372 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is'> 373 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 374 * @param srcStr Any non-null instance of a {@code java.lang.String} 375 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 376 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 377 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 378 */ 379 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=4) 380 public static boolean containsXOR(String srcStr, String... compareStr) 381 { return CmprCN.CONTAINS(false, XOR, srcStr, compareStr); } 382 383 /** 384 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is'> 385 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 386 * @param srcStr Any non-null instance of a {@code java.lang.String} 387 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 388 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 389 */ 390 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=4) 391 public static boolean containsNAND(String srcStr, String... compareStr) 392 { return CmprCN.CONTAINS(false, NAND, srcStr, compareStr); } 393 394 /** 395 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is not'> 396 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 397 * @param srcStr Any non-null instance of a {@code java.lang.String} 398 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 399 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 400 */ 401 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=4) 402 public static boolean containsOR_CI(String srcStr, String... compareStr) 403 { return CmprCN.CONTAINS(true, OR, srcStr, compareStr); } 404 405 /** 406 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is not'> 407 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 408 * @param srcStr Any non-null instance of a {@code java.lang.String} 409 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 410 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 411 */ 412 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=4) 413 public static boolean containsAND_CI(String srcStr, String... compareStr) 414 { return CmprCN.CONTAINS(true, AND, srcStr, compareStr); } 415 416 /** 417 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is not'> 418 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 419 * @param srcStr Any non-null instance of a {@code java.lang.String} 420 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 421 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 422 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 423 */ 424 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=4) 425 public static boolean containsXOR_CI(String srcStr, String... compareStr) 426 { return CmprCN.CONTAINS(true, XOR, srcStr, compareStr); } 427 428 /** 429 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is not'> 430 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 431 * @param srcStr Any non-null instance of a {@code java.lang.String} 432 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 433 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 434 */ 435 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=4) 436 public static boolean containsNAND_CI(String srcStr, String... compareStr) 437 { return CmprCN.CONTAINS(true, NAND, srcStr, compareStr); } 438 439 440 // ******************************************************************************************** 441 // ******************************************************************************************** 442 // STARTS-WITH, ENDS-WITH 443 // ******************************************************************************************** 444 // ******************************************************************************************** 445 446 447 /** 448 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is'> 449 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 450 * @param srcStr Any non-null instance of a {@code java.lang.String} 451 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 452 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 453 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 454 * @see #XOR(String, String, String[], Predicate) 455 */ 456 public static boolean endsWithXOR(String srcStr, String... compareStr) 457 { return XOR("endsWithXOR", srcStr, compareStr, cmp -> srcStr.endsWith(cmp)); } 458 459 /** 460 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is'> 461 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 462 * @param srcStr Any non-null instance of a {@code java.lang.String} 463 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 464 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 465 * @see #NAND(String, String, String[], Predicate) 466 */ 467 public static boolean endsWithNAND(String srcStr, String... compareStr) 468 { return NAND("endsWithNAND", srcStr, compareStr, cmp -> srcStr.endsWith(cmp)); } 469 470 /** 471 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is'> 472 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 473 * @param srcStr Any non-null instance of a {@code java.lang.String} 474 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 475 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 476 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 477 * @see #XOR(String, String, String[], Predicate) 478 */ 479 public static boolean startsWithXOR(String srcStr, String ... compareStr) 480 { return XOR("startsWithXOR", srcStr, compareStr, cmp -> srcStr.startsWith(cmp)); } 481 482 /** 483 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is'> 484 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 485 * @param srcStr Any non-null instance of a {@code java.lang.String} 486 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 487 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 488 * @see #NAND(String, String, String[], Predicate) 489 */ 490 public static boolean startsWithNAND(String srcStr, String ... compareStr) 491 { return NAND("startsWithNAND", srcStr, compareStr, cmp -> srcStr.startsWith(cmp)); } 492 493 494 // ******************************************************************************************** 495 // ******************************************************************************************** 496 // STARTS-WITH, ENDS-WITH - CASE INSENSITIVE 497 // ******************************************************************************************** 498 // ******************************************************************************************** 499 500 501 /** 502 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is not'> 503 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 504 * @param srcStr Any non-null instance of a {@code java.lang.String} 505 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 506 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 507 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 508 * @see #endsWithIgnoreCase(String, String) 509 * @see #XOR(String, String, String[], Predicate) 510 */ 511 public static boolean endsWithXOR_CI(String srcStr, String... compareStr) 512 { return XOR("endsWithXOR_CI", srcStr, compareStr, cmp -> endsWithIgnoreCase(srcStr, cmp)); } 513 514 /** 515 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is not'> 516 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 517 * @param srcStr Any non-null instance of a {@code java.lang.String} 518 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 519 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 520 * @see #endsWithIgnoreCase(String, String) 521 * @see #NAND(String, String, String[], Predicate) 522 */ 523 public static boolean endsWithNAND_CI(String srcStr, String... compareStr) 524 { return NAND("endsWithNAND_CI", srcStr, compareStr, cmp -> endsWithIgnoreCase(srcStr, cmp)); } 525 526 /** 527 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is not'> 528 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 529 * @param srcStr Any non-null instance of a {@code java.lang.String} 530 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 531 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 532 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 533 * @see #startsWithIgnoreCase(String, String) 534 * @see #XOR(String, String, String[], Predicate) 535 */ 536 public static boolean startsWithXOR_CI(String srcStr, String ... compareStr) 537 { 538 return XOR( 539 "startsWithXOR_CI", srcStr, compareStr, 540 cmp -> startsWithIgnoreCase(srcStr, cmp) 541 ); 542 } 543 544 /** 545 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is not'> 546 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC> 547 * @param srcStr Any non-null instance of a {@code java.lang.String} 548 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 549 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET> 550 * @see #startsWithIgnoreCase(String, String) 551 * @see #NAND(String, String, String[], Predicate) 552 */ 553 public static boolean startsWithNAND_CI(String srcStr, String ... compareStr) 554 { 555 return NAND( 556 "startsWithNAND_CI", srcStr, compareStr, 557 cmp -> startsWithIgnoreCase(srcStr, cmp) 558 ); 559 } 560 561 562 // ******************************************************************************************** 563 // ******************************************************************************************** 564 // IGNORE-CASE METHODS 565 // ******************************************************************************************** 566 // ******************************************************************************************** 567 568 569 /** 570 * This performs the exact same comparison as Java's {@code String.startsWith(String)} method. 571 * Java provides an {@code 'equalsIgnoreCase()'} method, but not an 572 * {@code 'startsWithIgnoreCase()'}. This method does just that. 573 * @param srcStr This {@code String} is checked to see if it starts with the {@code compareStr}. 574 * @param compareStr This {@code String} is checked against the {@code srcStr} - specifically, 575 * if {@code srcStr} ends with {@code compareStr} 576 * @return {@code TRUE} if {@code srcStr} starts with {@code compareStr} (ignoring-case), and 577 * {@code FALSE} otherwise. 578 */ 579 public static boolean startsWithIgnoreCase(String srcStr, String compareStr) 580 { return srcStr.regionMatches(true, 0, compareStr, 0, compareStr.length()); } 581 582 /** 583 * This performs the exact same comparison as Java's {@code String.endsWith(String)} method. 584 * Java provides an {@code 'equalsIgnoreCase()'} method, but not an 585 * {@code 'endsWithIgnoreCase()'}. This method does just that. 586 * @param srcStr This {@code String} is checked to see if it ends with the {@code compareStr}. 587 * @param compareStr This {@code String} is checked against the {@code srcStr} - specifically, 588 * if {@code srcStr} ends with {@code compareStr} 589 * @return {@code TRUE} if {@code srcStr} ends with {@code compareStr} (ignoring-case), 590 * and {@code FALSE} otherwise. 591 */ 592 public static boolean endsWithIgnoreCase(String srcStr, String compareStr) 593 { 594 final int compareStrLen = compareStr.length(); 595 final int srcStrLen = srcStr.length(); 596 597 return srcStr.regionMatches(true, srcStrLen - compareStrLen, compareStr, 0, compareStrLen); 598 } 599 600 /** 601 * This performs the exact same comparison as Java's {@code String.contains(String)} method. 602 * Java provides an {@code 'equalsIgnoreCase()'} method, but not a 603 * {@code 'containsIgnoreCase()'}. This method does just that. 604 * @param srcStr This {@code String} is checked to see if it contains the {@code compareStr} 605 * @param compareStr This {@code String} is checked against the {@code srcStr} - specifically, 606 * if {@code compareStr} is contained by {@code srcStr} 607 * @return {@code TRUE} if {@code compareStr} is a substring of {@code srcStr} (ignoring-case), 608 * and {@code FALSE} otherwise. 609 */ 610 @LinkJavaSource(handle="CmprCN", name="containsIgnoreCase", paramCount=3) 611 public static boolean containsIgnoreCase(String srcStr, String compareStr) 612 { return CmprCN.containsIgnoreCase(srcStr, new LV(srcStr, 0, srcStr.length()), compareStr); } 613 614 615 616 // ******************************************************************************************** 617 // ******************************************************************************************** 618 // ******************************************************************************************** 619 // ******************************************************************************************** 620 // ******************************************************************************************** 621 // StrCmpr Main Section #2 622 // ******************************************************************************************** 623 // ******************************************************************************************** 624 // ******************************************************************************************** 625 // ******************************************************************************************** 626 // ******************************************************************************************** 627 628 629 630 // ******************************************************************************************** 631 // ******************************************************************************************** 632 // EQUALS 633 // ******************************************************************************************** 634 // ******************************************************************************************** 635 636 637 /** 638 * <EMBED CLASS=defs DATA-DESC='equals exactly one' DATA-CI='is'> 639 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 640 * @param srcStr Any non-null instance of a {@code java.lang.String} 641 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 642 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 643 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 644 * @see #XOR(String, String, String[], Predicate) 645 */ 646 @LinkJavaSource(handle="CmprEQ") 647 public static boolean equalsXOR(String srcStr, int sPos, int ePos, String... compareStr) 648 { 649 final LV l = new LV(srcStr, sPos, ePos); 650 return XOR("equalsXOR", srcStr, compareStr, cmp -> CmprEQ.eq(srcStr, l, cmp)); 651 } 652 653 /** 654 * <EMBED CLASS=defs DATA-DESC='does not equal any' DATA-CI='is'> 655 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 656 * @param srcStr Any non-null instance of a {@code java.lang.String} 657 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 658 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 659 * @see #NAND(String, String, String[], Predicate) 660 */ 661 @LinkJavaSource(handle="CmprEQ") 662 public static boolean equalsNAND(String srcStr, int sPos, int ePos, String... compareStr) 663 { 664 final LV l = new LV(srcStr, sPos, ePos); 665 return NAND("equalsNAND", srcStr, compareStr, cmp -> CmprEQ.eq(srcStr, l, cmp)); 666 } 667 668 /** 669 * <EMBED CLASS=defs DATA-DESC='equals exactly one' DATA-CI='is not'> 670 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 671 * @param srcStr Any non-null instance of a {@code java.lang.String} 672 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 673 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 674 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 675 * @see #XOR(String, String, String[], Predicate) 676 */ 677 @LinkJavaSource(handle="CmprEQ") 678 public static boolean equalsXOR_CI(String srcStr, int sPos, int ePos, String... compareStr) 679 { 680 final LV l = new LV(srcStr, sPos, ePos); 681 return XOR("equalsXOR_CI", srcStr, compareStr, cmp -> CmprEQ.eq_CI(srcStr, l, cmp)); 682 } 683 684 /** 685 * <EMBED CLASS=defs DATA-DESC='does not equal any' DATA-CI='is not'> 686 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 687 * @param srcStr Any non-null instance of a {@code java.lang.String} 688 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 689 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 690 * @see #NAND(String, String, String[], Predicate) 691 */ 692 @LinkJavaSource(handle="CmprEQ") 693 public static boolean equalsNAND_CI(String srcStr, int sPos, int ePos, String... compareStr) 694 { 695 final LV l = new LV(srcStr, sPos, ePos); 696 return NAND("equalsNAND_CI", srcStr, compareStr, cmp -> CmprEQ.eq_CI(srcStr, l, cmp)); 697 } 698 699 700 // ******************************************************************************************** 701 // ******************************************************************************************** 702 // CONTAINS - This code is redundant 703 // ******************************************************************************************** 704 // ******************************************************************************************** 705 706 707 /** 708 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is'> 709 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 710 * @param srcStr Any non-null instance of a {@code java.lang.String} 711 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 712 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 713 */ 714 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=5) 715 public static boolean containsOR(String srcStr, int sPos, int ePos, String... compareStr) 716 { 717 final LV l = new LV(srcStr, sPos, ePos); 718 return CmprCN.CONTAINS(false, OR, l, srcStr, compareStr); 719 } 720 721 /** 722 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is'> 723 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 724 * @param srcStr Any non-null instance of a {@code java.lang.String} 725 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 726 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 727 */ 728 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=5) 729 public static boolean containsAND(String srcStr, int sPos, int ePos, String... compareStr) 730 { 731 final LV l = new LV(srcStr, sPos, ePos); 732 return CmprCN.CONTAINS(false, AND, l, srcStr, compareStr); 733 } 734 735 /** 736 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is'> 737 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 738 * @param srcStr Any non-null instance of a {@code java.lang.String} 739 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 740 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 741 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 742 */ 743 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=5) 744 public static boolean containsXOR(String srcStr, int sPos, int ePos, String... compareStr) 745 { 746 final LV l = new LV(srcStr, sPos, ePos); 747 return CmprCN.CONTAINS(false, XOR, l, srcStr, compareStr); 748 } 749 750 /** 751 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is'> 752 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 753 * @param srcStr Any non-null instance of a {@code java.lang.String} 754 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 755 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 756 */ 757 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=5) 758 public static boolean containsNAND(String srcStr, int sPos, int ePos, String... compareStr) 759 { 760 final LV l = new LV(srcStr, sPos, ePos); 761 return CmprCN.CONTAINS(false, NAND, l, srcStr, compareStr); 762 } 763 764 /** 765 * <EMBED CLASS=defs DATA-DESC='contains at least one' DATA-CI='is not'> 766 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 767 * @param srcStr Any non-null instance of a {@code java.lang.String} 768 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 769 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 770 */ 771 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=5) 772 public static boolean containsOR_CI(String srcStr, int sPos, int ePos, String... compareStr) 773 { 774 final LV l = new LV(srcStr, sPos, ePos); 775 return CmprCN.CONTAINS(true, OR, l, srcStr, compareStr); 776 } 777 778 /** 779 * <EMBED CLASS=defs DATA-DESC='contains every one' DATA-CI='is not'> 780 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 781 * @param srcStr Any non-null instance of a {@code java.lang.String} 782 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 783 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 784 */ 785 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=5) 786 public static boolean containsAND_CI(String srcStr, int sPos, int ePos, String... compareStr) 787 { 788 final LV l = new LV(srcStr, sPos, ePos); 789 return CmprCN.CONTAINS(true, AND, l, srcStr, compareStr); 790 } 791 792 /** 793 * <EMBED CLASS=defs DATA-DESC='contains exactly one' DATA-CI='is not'> 794 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 795 * @param srcStr Any non-null instance of a {@code java.lang.String} 796 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 797 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 798 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 799 */ 800 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=5) 801 public static boolean containsXOR_CI(String srcStr, int sPos, int ePos, String... compareStr) 802 { 803 final LV l = new LV(srcStr, sPos, ePos); 804 return CmprCN.CONTAINS(true, XOR, l, srcStr, compareStr); 805 } 806 807 /** 808 * <EMBED CLASS=defs DATA-DESC='does not contain any' DATA-CI='is not'> 809 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 810 * @param srcStr Any non-null instance of a {@code java.lang.String} 811 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 812 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 813 */ 814 @LinkJavaSource(handle="CmprCN", name="CONTAINS", paramCount=5) 815 public static boolean containsNAND_CI(String srcStr, int sPos, int ePos, String... compareStr) 816 { 817 final LV l = new LV(srcStr, sPos, ePos); 818 return CmprCN.CONTAINS(true, NAND, l, srcStr, compareStr); 819 } 820 821 822 // ******************************************************************************************** 823 // ******************************************************************************************** 824 // STARTS-WITH, ENDS-WITH 825 // ******************************************************************************************** 826 // ******************************************************************************************** 827 828 829 /** 830 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is'> 831 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 832 * @param srcStr Any non-null instance of a {@code java.lang.String} 833 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 834 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 835 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 836 * @see #XOR(String, String, String[], Predicate) 837 */ 838 @LinkJavaSource(handle="CmprEW") 839 public static boolean endsWithXOR(String srcStr, int sPos, int ePos, String... compareStr) 840 { 841 final LV l = new LV(srcStr, sPos, ePos); 842 return XOR("endsWithXOR", srcStr, compareStr, cmp -> CmprEW.ew(srcStr, l, cmp)); 843 } 844 845 /** 846 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is'> 847 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 848 * @param srcStr Any non-null instance of a {@code java.lang.String} 849 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 850 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 851 * @see #NAND(String, String, String[], Predicate) 852 */ 853 @LinkJavaSource(handle="CmprEW") 854 public static boolean endsWithNAND(String srcStr, int sPos, int ePos, String... compareStr) 855 { 856 final LV l = new LV(srcStr, sPos, ePos); 857 return NAND("endsWithNAND", srcStr, compareStr, cmp -> CmprEW.ew(srcStr, l, cmp)); 858 } 859 860 /** 861 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is'> 862 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 863 * @param srcStr Any non-null instance of a {@code java.lang.String} 864 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 865 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 866 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 867 * @see #XOR(String, String, String[], Predicate) 868 */ 869 @LinkJavaSource(handle="CmprSW") 870 public static boolean startsWithXOR(String srcStr, int sPos, int ePos, String ... compareStr) 871 { 872 final LV l = new LV(srcStr, sPos, ePos); 873 return XOR("startsWithXOR", srcStr, compareStr, cmp -> CmprSW.sw(srcStr, l, cmp)); 874 } 875 876 /** 877 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is'> 878 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 879 * @param srcStr Any non-null instance of a {@code java.lang.String} 880 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 881 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 882 * @see #NAND(String, String, String[], Predicate) 883 */ 884 @LinkJavaSource(handle="CmprSW") 885 public static boolean startsWithNAND(String srcStr, int sPos, int ePos, String ... compareStr) 886 { 887 final LV l = new LV(srcStr, sPos, ePos); 888 return NAND("startsWithNAND", srcStr, compareStr, cmp -> CmprSW.sw(srcStr, l, cmp)); 889 } 890 891 892 // ******************************************************************************************** 893 // ******************************************************************************************** 894 // STARTS-WITH, ENDS-WITH - CASE INSENSITIVE 895 // ******************************************************************************************** 896 // ******************************************************************************************** 897 898 899 /** 900 * <EMBED CLASS=defs DATA-DESC='ends with exactly one' DATA-CI='is not'> 901 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 902 * @param srcStr Any non-null instance of a {@code java.lang.String} 903 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 904 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 905 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 906 * @see #XOR(String, String, String[], Predicate) 907 */ 908 @LinkJavaSource(handle="CmprEW") 909 public static boolean endsWithXOR_CI(String srcStr, int sPos, int ePos, String... compareStr) 910 { 911 final LV l = new LV(srcStr, sPos, ePos); 912 return XOR("endsWithXOR_CI", srcStr, compareStr, cmp -> CmprEW.ew_CI(srcStr, l, cmp)); 913 } 914 915 /** 916 * <EMBED CLASS=defs DATA-DESC='does not end with any' DATA-CI='is not'> 917 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 918 * @param srcStr Any non-null instance of a {@code java.lang.String} 919 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 920 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 921 * @see #NAND(String, String, String[], Predicate) 922 */ 923 @LinkJavaSource(handle="CmprEW") 924 public static boolean endsWithNAND_CI(String srcStr, int sPos, int ePos, String... compareStr) 925 { 926 final LV l = new LV(srcStr, sPos, ePos); 927 return NAND("endsWithNAND_CI", srcStr, compareStr, cmp -> CmprEW.ew_CI(srcStr, l, cmp)); 928 } 929 930 /** 931 * <EMBED CLASS=defs DATA-DESC='starts with exactly one' DATA-CI='is not'> 932 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 933 * @param srcStr Any non-null instance of a {@code java.lang.String} 934 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 935 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 936 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCXORNOTE> 937 * @see #XOR(String, String, String[], Predicate) 938 */ 939 @LinkJavaSource(handle="CmprSW") 940 public static boolean startsWithXOR_CI(String srcStr, int sPos, int ePos, String ... compareStr) 941 { 942 final LV l = new LV(srcStr, sPos, ePos); 943 return XOR("startsWithXOR_CI", srcStr, compareStr, cmp -> CmprSW.sw_CI(srcStr, l, cmp)); 944 } 945 946 /** 947 * <EMBED CLASS=defs DATA-DESC='does not start with any' DATA-CI='is not'> 948 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_SE> 949 * @param srcStr Any non-null instance of a {@code java.lang.String} 950 * @param compareStr The {@code String's} used in the comparison against {@code 'srcStr'} 951 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_SE> 952 * @see #NAND(String, String, String[], Predicate) 953 */ 954 @LinkJavaSource(handle="CmprSW") 955 public static boolean startsWithNAND_CI(String srcStr, int sPos, int ePos, String ... compareStr) 956 { 957 final LV l = new LV(srcStr, sPos, ePos); 958 return NAND("startsWithNAND_CI", srcStr, compareStr, cmp -> CmprSW.sw_CI(srcStr, l, cmp)); 959 } 960 961 962 // ******************************************************************************************** 963 // ******************************************************************************************** 964 // Single String Methods 965 // ******************************************************************************************** 966 // ******************************************************************************************** 967 968 969 /** 970 * <EMBED CLASS=defs DATA-FUNC='equals' DATA-CI='is'> 971 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_1C> 972 * @param srcStr Any non-null instance of a {@code java.lang.String} 973 * @param compareStr The {@code String} used in the comparison against {@code 'srcStr'} 974 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_1C> 975 */ 976 @LinkJavaSource(handle="CmprEQ") 977 public static boolean equals(String srcStr, int sPos, int ePos, String compareStr) 978 { return CmprEQ.eq(srcStr, new LV(srcStr, sPos, ePos), compareStr); } 979 980 981 /** 982 * <EMBED CLASS=defs DATA-FUNC='equals' DATA-CI='is not'> 983 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_1C> 984 * @param srcStr Any non-null instance of a {@code java.lang.String} 985 * @param compareStr The {@code String} used in the comparison against {@code 'srcStr'} 986 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_1C> 987 */ 988 @LinkJavaSource(handle="CmprEQ") 989 public static boolean equalsIgnoreCase(String srcStr, int sPos, int ePos, String compareStr) 990 { return CmprEQ.eq_CI(srcStr, new LV(srcStr, sPos, ePos), compareStr); } 991 992 993 /** 994 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is'> 995 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_1C> 996 * @param srcStr Any non-null instance of a {@code java.lang.String} 997 * @param compareStr The {@code String} used in the comparison against {@code 'srcStr'} 998 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_1C> 999 */ 1000 @LinkJavaSource(handle="CmprSW") 1001 public static boolean startsWith(String srcStr, int sPos, int ePos, String compareStr) 1002 { return CmprSW.sw(srcStr, new LV(srcStr, sPos, ePos), compareStr); } 1003 1004 1005 /** 1006 * <EMBED CLASS=defs DATA-FUNC='starts with' DATA-CI='is not'> 1007 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_1C> 1008 * @param srcStr Any non-null instance of a {@code java.lang.String} 1009 * @param compareStr The {@code String} used in the comparison against {@code 'srcStr'} 1010 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_1C> 1011 */ 1012 @LinkJavaSource(handle="CmprSW") 1013 public static boolean startsWithIgnoreCase(String srcStr, int sPos, int ePos, String compareStr) 1014 { return CmprSW.sw_CI(srcStr, new LV(srcStr, sPos, ePos), compareStr); } 1015 1016 /** 1017 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is'> 1018 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_1C> 1019 * @param srcStr Any non-null instance of a {@code java.lang.String} 1020 * @param compareStr The {@code String} used in the comparison against {@code 'srcStr'} 1021 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_1C> 1022 */ 1023 @LinkJavaSource(handle="CmprEW") 1024 public static boolean endsWith(String srcStr, int sPos, int ePos, String compareStr) 1025 { return CmprEW.ew(srcStr, new LV(srcStr, sPos, ePos), compareStr); } 1026 1027 /** 1028 * <EMBED CLASS=defs DATA-FUNC='ends with' DATA-CI='is not'> 1029 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_1C> 1030 * @param srcStr Any non-null instance of a {@code java.lang.String} 1031 * @param compareStr The {@code String} used in the comparison against {@code 'srcStr'} 1032 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_1C> 1033 */ 1034 @LinkJavaSource(handle="CmprSW") 1035 public static boolean endsWithIgnoreCase(String srcStr, int sPos, int ePos, String compareStr) 1036 { return CmprEW.ew_CI(srcStr, new LV(srcStr, sPos, ePos), compareStr); } 1037 1038 1039 /** 1040 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is'> 1041 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_1C> 1042 * @param srcStr Any non-null instance of a {@code java.lang.String} 1043 * @param compareStr The {@code String} used in the comparison against {@code 'srcStr'} 1044 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_1C> 1045 */ 1046 @LinkJavaSource(handle="CmprCN") 1047 public static boolean contains(String srcStr, int sPos, int ePos, String compareStr) 1048 { return CmprCN.contains(srcStr, new LV(srcStr, sPos, ePos), compareStr); } 1049 1050 1051 /** 1052 * <EMBED CLASS=defs DATA-FUNC='contains' DATA-CI='is not'> 1053 * <EMBED CLASS='external-html' DATA-FILE-ID=STRCDESC_1C> 1054 * @param srcStr Any non-null instance of a {@code java.lang.String} 1055 * @param compareStr The {@code String} used in the comparison against {@code 'srcStr'} 1056 * @return <EMBED CLASS='external-html' DATA-FILE-ID=STRCRET_1C> 1057 */ 1058 @LinkJavaSource(handle="CmprCN") 1059 public static boolean containsIgnoreCase(String srcStr, int sPos, int ePos, String compareStr) 1060 { return CmprCN.containsIgnoreCase(srcStr, new LV(srcStr, sPos, ePos), compareStr); } 1061 1062 1063 // ******************************************************************************************** 1064 // ******************************************************************************************** 1065 // CONTAINS OPTIMIZATION 1066 // ******************************************************************************************** 1067 // ******************************************************************************************** 1068 1069 1070 /** 1071 * Signifies that an {@code 'AND'} operation is required, but only for methods that implement 1072 * one of the {@code 'contains'} variants. 1073 */ 1074 protected static final byte AND = 0; 1075 1076 /** 1077 * Signifies that an {@code 'AND'} operation is required, but only for methods that implement 1078 * one of the {@code 'contains'} variants. 1079 */ 1080 protected static final byte OR = 1; 1081 1082 /** 1083 * Signifies that an {@code 'AND'} operation is required, but only for methods that implement 1084 * one of the {@code 'contains'} variants. 1085 */ 1086 protected static final byte NAND = 2; 1087 1088 /** 1089 * Signifies that an {@code 'AND'} operation is required, but only for methods that implement 1090 * one of the {@code 'contains'} variants. 1091 */ 1092 protected static final byte XOR = 3; 1093}