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