public abstract static class StringUtil.AbstractIndexOf extends Object implements StringUtil.IndexOf
| Constructor and Description |
|---|
AbstractIndexOf() |
| Modifier and Type | Method and Description |
|---|---|
int |
indexOf(CharSequence haystack)
The equivalent of
String.indexOf(String). |
int |
indexOf(CharSequence haystack,
int minIndex)
The equivalent of
String.indexOf(String, int). |
int |
indexOf(CharSequence haystack,
int minIndex,
int maxIndex)
Like
StringUtil.IndexOf.indexOf(CharSequence, int), but the match terminates at index maxIndex (inclusive). |
int |
indexOf(CharSequence haystack,
int minIndex,
int maxIndex,
int limit)
Like
StringUtil.IndexOf.indexOf(CharSequence, int, int), but never accesses haystack chars at position
limit or greater. |
int |
lastIndexOf(CharSequence haystack)
The equivalent of
String.lastIndexOf(String). |
int |
lastIndexOf(CharSequence haystack,
int maxIndex)
The equivalent of
String.lastIndexOf(String, int). |
int |
lastIndexOf(CharSequence haystack,
int minIndex,
int maxIndex)
Like
StringUtil.IndexOf.lastIndexOf(CharSequence, int), but the match terminates at index minIndex
(inclusive). |
abstract String |
toString() |
public int indexOf(CharSequence haystack)
StringUtil.IndexOfString.indexOf(String).
For the return value, the following condition holds true:
StringUtil.newIndexOf(needle).indexOf(haystack) == haystack.indexOf(needle)
indexOf in interface StringUtil.IndexOf0 ... haystack.length() - needle.length(), or -1public int indexOf(CharSequence haystack, int minIndex)
StringUtil.IndexOfString.indexOf(String, int).
For the return value, the following condition holds true:
StringUtil.newIndexOf(needle).indexOf(haystack, minIndex) == haystack.indexOf(needle, minIndex)
indexOf in interface StringUtil.IndexOfmax(0, minIndex) ... haystack.length() - needle.length(), or -1public int lastIndexOf(CharSequence haystack)
StringUtil.IndexOfString.lastIndexOf(String).
For the return value, the following condition holds true:
StringUtil.newIndexOf(needle).lastIndexOf(haystack) == haystack.lastIndexOf(needle)
lastIndexOf in interface StringUtil.IndexOf0 ... haystack.length() - needle.length(), or -1public int lastIndexOf(CharSequence haystack, int maxIndex)
StringUtil.IndexOfString.lastIndexOf(String, int).
For the return value, the following condition holds true:
StringUtil.newIndexOf(needle).lastIndexOf(haystack, maxIndex) == haystack.lastIndexOf(needle, maxIndex)
lastIndexOf in interface StringUtil.IndexOf0 ... min(maxIndex, haystack.length() - needle.length()), or -1public int indexOf(CharSequence haystack, int minIndex, int maxIndex)
StringUtil.IndexOfStringUtil.IndexOf.indexOf(CharSequence, int), but the match terminates at index maxIndex (inclusive).indexOf in interface StringUtil.IndexOfmax(0, minIndex) ... min(maxIndex, haystack.length() - needle.length()), or -1public int indexOf(CharSequence haystack, int minIndex, int maxIndex, int limit)
StringUtil.IndexOfStringUtil.IndexOf.indexOf(CharSequence, int, int), but never accesses haystack chars at position
limit or greater.
Instead, if there are partial matches at positions limit -
needle.length - 1 ... limit - 1, then the first of these is
returned.
Examples:
| needle | haystack | minIndex | maxIndex | limit | result |
|---|---|---|---|---|---|
ABCDE | _ABCDE_** | <=1 | >=1 | 7 | 1 |
ABCDE | __ABCDE** | <=2 | >=2 | 7 | 2 |
ABCDE | ___ABCD** | <=3 | >=3 | 7 | 3 |
ABCDE | ____ABC** | <=4 | >=4 | 7 | 4 |
ABCDE | _____AB** | <=5 | >=5 | 7 | 5 |
ABCDE | ______A** | <=6 | >=6 | 7 | 6 |
ABCDE | _______** | <=7 | >=7 | 7 | 7 |
("_": Any character but "ABCDE"; "*": Any character.)
indexOf in interface StringUtil.IndexOflimit - 0...haystack.lengthpublic int lastIndexOf(CharSequence haystack, int minIndex, int maxIndex)
StringUtil.IndexOfStringUtil.IndexOf.lastIndexOf(CharSequence, int), but the match terminates at index minIndex
(inclusive).lastIndexOf in interface StringUtil.IndexOfmax(0, minIndex) ... min(maxIndex, haystack.length() - needle.length()), or -1public abstract String toString()
toString in interface StringUtil.IndexOftoString in class ObjectCopyright © 2018 Arno Unkrig. All rights reserved.