public final class StringUtils extends Object
This class contains static utility methods for common string operations used throughout the HtmlUnit NekoHtml parser. It focuses on lightweight, performance-oriented string checks that avoid creating unnecessary String objects or using expensive operations.
| Modifier and Type | Method and Description |
|---|---|
static boolean |
equalsChar(char expected,
CharSequence s)
Checks if the provided character sequence consists of exactly one character that matches
the expected character.
|
static boolean |
isEmptyString(CharSequence s)
Checks if the provided character sequence is not null and has zero length.
|
public static boolean isEmptyString(CharSequence s)
This method differs from org.apache.commons.lang3.StringUtils#isEmpty(CharSequence)
in that it returns false if the provided string is null.
s - the character sequence to check, may be nulltrue if the sequence is not null AND has length of zero; false otherwisepublic static boolean equalsChar(char expected,
CharSequence s)
This is an optimized equality check for single-character strings, avoiding the overhead of full string comparison. It's particularly useful during HTML parsing when checking for single-character tokens or delimiters.
expected - the character that we expect to matchs - the character sequence to check, may be nulltrue if and only if the provided sequence is not null, has exactly one character,
and that character equals the expected character; false otherwiseCopyright © 2025 HtmlUnit. All rights reserved.