Package com.gengoai.string
Interface StringLike
-
- All Superinterfaces:
CharSequence
public interface StringLike extends CharSequence
Defines an objects which acts similar to Java String.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default char
charAt(int i)
default boolean
contains(CharSequence string)
Returns true if and only if this string contains the specified sequence of char values.default boolean
contentEquals(CharSequence content)
Determines if the content of this HString equals the given char sequence.default boolean
contentEqualsIgnoreCase(CharSequence content)
Determines if the content of this HString equals the given char sequence ignoring case.default boolean
endsWith(CharSequence suffix)
Determines if this HString ends with the given suffix.default Language
getLanguage()
Gets the language of the HString.default int
indexOf(@NonNull CharSequence text)
Returns the index within this string of the first occurrence of the specified substring.default int
indexOf(@NonNull CharSequence text, int start)
Returns the index within this string of the first occurrence of the specified substring.default int
length()
default Matcher
matcher(@NonNull String pattern)
Returns a regular expression matcher for the given pattern over this HStringdefault Matcher
matcher(@NonNull Pattern pattern)
Returns a regular expression matcher for the given pattern over this HStringdefault boolean
matches(@NonNull String regex)
Tells whether or not this string matches the given regular expression.default String
replace(@NonNull CharSequence oldString, @NonNull CharSequence newString)
Replaces all substrings of this string that matches the given string with the given replacement.default String
replaceAll(@NonNull String regex, @NonNull String replacement)
Replaces all substrings of this string that matches the given regular expression with the given replacement.default String
replaceFirst(@NonNull String regex, @NonNull String replacement)
Replaces the first substring of this string that matches the given regular expression with the given replacement.default boolean
startsWith(@NonNull CharSequence prefix)
Tests if this HString starts with the specified prefix.default CharSequence
subSequence(int startInclusive, int endExclusive)
default char[]
toCharArray()
Converts this string to a new character array.default String
toLowerCase()
To lower case.default String
toUpperCase()
Converts the HString to upper case-
Methods inherited from interface java.lang.CharSequence
chars, codePoints, toString
-
-
-
-
Method Detail
-
charAt
default char charAt(int i)
- Specified by:
charAt
in interfaceCharSequence
-
contains
default boolean contains(CharSequence string)
Returns true if and only if this string contains the specified sequence of char values.- Parameters:
string
- the sequence to search for- Returns:
- true if this string contains s, false otherwise
-
contentEquals
default boolean contentEquals(CharSequence content)
Determines if the content of this HString equals the given char sequence.- Parameters:
content
- the content to check for equality- Returns:
- True if equals, False otherwise
-
contentEqualsIgnoreCase
default boolean contentEqualsIgnoreCase(CharSequence content)
Determines if the content of this HString equals the given char sequence ignoring case.- Parameters:
content
- the content to check for equality- Returns:
- True if equals, False otherwise
-
endsWith
default boolean endsWith(CharSequence suffix)
Determines if this HString ends with the given suffix.- Parameters:
suffix
- the suffix to check- Returns:
- True ends with the given suffix, False otherwise
-
getLanguage
default Language getLanguage()
Gets the language of the HString. If no language is set for this HString, the language of document will be returned. In the event that this HString is not associated with a document, the default language will be returned.- Returns:
- The language of the HString
-
indexOf
default int indexOf(@NonNull @NonNull CharSequence text)
Returns the index within this string of the first occurrence of the specified substring.- Parameters:
text
- the substring to search for.- Returns:
- the index of the first occurrence of the specified substring, or -1 if there is no such occurrence.
- See Also:
String#indexOf(String)String#indexOf(String)String#indexOf(String)String#indexOf(String)String#indexOf(String)String#indexOf(String)
-
indexOf
default int indexOf(@NonNull @NonNull CharSequence text, int start)
Returns the index within this string of the first occurrence of the specified substring.- Parameters:
text
- the substring to search for.start
- the index to to start searching from- Returns:
- the index of the first occurrence of the specified substring, or -1 if there is no such occurrence.
- See Also:
String#indexOf(String, int)String#indexOf(String, int)String#indexOf(String, int)String#indexOf(String, int)String#indexOf(String, int)String#indexOf(String, int)
-
length
default int length()
- Specified by:
length
in interfaceCharSequence
-
matcher
default Matcher matcher(@NonNull @NonNull String pattern)
Returns a regular expression matcher for the given pattern over this HString- Parameters:
pattern
- the pattern to search for- Returns:
- the matcher
-
matcher
default Matcher matcher(@NonNull @NonNull Pattern pattern)
Returns a regular expression matcher for the given pattern over this HString- Parameters:
pattern
- the pattern to search for- Returns:
- the matcher
-
matches
default boolean matches(@NonNull @NonNull String regex)
Tells whether or not this string matches the given regular expression.- Parameters:
regex
- the regular expression- Returns:
- true if, and only if, this string matches the given regular expression
- See Also:
String#matches(String)String#matches(String)String#matches(String)String#matches(String)String#matches(String)String#matches(String)
-
replace
default String replace(@NonNull @NonNull CharSequence oldString, @NonNull @NonNull CharSequence newString)
Replaces all substrings of this string that matches the given string with the given replacement.- Parameters:
oldString
- the old stringnewString
- the new string- Returns:
- the string
- See Also:
String#replace(CharSequence, CharSequence)String#replace(CharSequence, CharSequence)String#replace(CharSequence, CharSequence)String#replace(CharSequence, CharSequence)String#replace(CharSequence, CharSequence)String#replace(CharSequence, CharSequence)
-
replaceAll
default String replaceAll(@NonNull @NonNull String regex, @NonNull @NonNull String replacement)
Replaces all substrings of this string that matches the given regular expression with the given replacement.- Parameters:
regex
- the regular expressionreplacement
- the string to be substituted- Returns:
- the resulting string
- See Also:
String#replaceAll(String, String)String#replaceAll(String, String)String#replaceAll(String, String)String#replaceAll(String, String)String#replaceAll(String, String)String#replaceAll(String, String)
-
replaceFirst
default String replaceFirst(@NonNull @NonNull String regex, @NonNull @NonNull String replacement)
Replaces the first substring of this string that matches the given regular expression with the given replacement.- Parameters:
regex
- the regular expressionreplacement
- the string to be substituted- Returns:
- the resulting string
- See Also:
String#replaceFirst(String, String)String#replaceFirst(String, String)String#replaceFirst(String, String)String#replaceFirst(String, String)String#replaceFirst(String, String)String#replaceFirst(String, String)
-
startsWith
default boolean startsWith(@NonNull @NonNull CharSequence prefix)
Tests if this HString starts with the specified prefix.- Parameters:
prefix
- the prefix- Returns:
- true if the HString starts with the specified prefix
-
subSequence
default CharSequence subSequence(int startInclusive, int endExclusive)
- Specified by:
subSequence
in interfaceCharSequence
-
toCharArray
default char[] toCharArray()
Converts this string to a new character array.- Returns:
- a newly allocated character array whose length is the length of this string and whose contents are initialized to contain the character sequence represented by this string.
-
toLowerCase
default String toLowerCase()
To lower case.
-
toUpperCase
default String toUpperCase()
Converts the HString to upper case- Returns:
- the upper case version of the HString
- See Also:
String#toUpperCase(Locale)String#toUpperCase(Locale)String#toUpperCase(Locale)String#toUpperCase(Locale)String#toUpperCase(Locale)String#toUpperCase(Locale)NOTE: Uses locale associated with the HString's langauge
-
-