Class StringUtils
java.lang.Object
org.apache.maven.surefire.util.internal.StringUtils
Common java.lang.String manipulation routines.
Originally from Turbine and the GenerationJavaCore library.
NOTE: This class is not part of any api and is public purely for technical reasons !
- Since:
- 1.0
- Version:
- $Id: StringUtils.java 8001 2009-01-03 13:17:09Z vsiveton $
- Author:
- Jon S. Stevens, Daniel Rall, Greg Coladonato, Henri Yandell, Ed Korthof, Rand McNeely, Stephen Colebourne, Fredrik Westermarck, Holger Krauth, Alexander Day Chaffee, Vincent Siveton
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classEscaped string to byte array with offset 0 and certain length. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]static StringUtils.EncodedArrayescapeBytesToPrintable(byte[] header, byte[] input, int off, int len) Escapes the bytes in the arrayinputto contain only 'printable' bytes.static voidescapeToPrintable(StringBuilder target, CharSequence str) Escape the specified string to a representation that only consists of nicely printable characters, without any newlines and without a comma.static booleanChecks if a (trimmed) String isnullor blank.static booleanisNotBlank(String str) Checks if a (trimmed) String is notnulland not blank.static String[]static booleanstartsWith(StringBuffer buffer, String pattern) Determines ifbufferstarts with specific literal(s).static ByteBufferunescapeBytes(String str, String charsetName) Reverses the effect ofescapeBytesToPrintable(byte[], byte[], int, int).static voidunescapeString(StringBuilder target, CharSequence str) Reverses the effect ofescapeToPrintable(StringBuilder, CharSequence).
-
Field Details
-
NL
-
US_ASCII
TODO Use JDK7 StandardCharsets -
ISO_8859_1
-
UTF_8
-
-
Method Details
-
split
-
isBlank
Checks if a (trimmed) String is
nullor blank.- Parameters:
str- the String to check- Returns:
trueif the String isnull, or length zero once trimmed
-
isNotBlank
Checks if a (trimmed) String is not
nulland not blank.- Parameters:
str- the String to check- Returns:
trueif the String is notnulland length of trimmedstris not zero.
-
escapeToPrintable
Escape the specified string to a representation that only consists of nicely printable characters, without any newlines and without a comma.The reverse-method is
unescapeString(StringBuilder, CharSequence).- Parameters:
target- target string buffer. The required space will be up tostr.getBytes().length * 5chars.str- String to escape values in, may benull.
-
unescapeString
Reverses the effect ofescapeToPrintable(StringBuilder, CharSequence).- Parameters:
target- target string bufferstr- the String to un-escape, as created byescapeToPrintable(StringBuilder, CharSequence)
-
escapeBytesToPrintable
public static StringUtils.EncodedArray escapeBytesToPrintable(byte[] header, byte[] input, int off, int len) Escapes the bytes in the arrayinputto contain only 'printable' bytes.
Escaping is done by encoding the non-nicely printable bytes to'\' + upperCaseHexBytes(byte).
The reverse-method isunescapeBytes(String, String).
The returned byte array is started with aligned sequenceheaderand finished by\n.- Parameters:
header- prefix headerinput- input bufferoff- offset in the input bufferlen- number of bytes to copy from the input buffer- Returns:
- number of bytes written to
out - Throws:
NullPointerException- if the specified parameterheaderorinputis nullIndexOutOfBoundsException- ifofforlenis out of range (off < 0 || len < 0 || off >= input.length || len > input.length || off + len > input.length)
-
unescapeBytes
Reverses the effect ofescapeBytesToPrintable(byte[], byte[], int, int).- Parameters:
str- the input StringcharsetName- the charset name- Returns:
- the number of bytes written to
out
-
encodeStringForForkCommunication
-
startsWith
Determines ifbufferstarts with specific literal(s).- Parameters:
buffer- Examined StringBufferpattern- a pattern which should start inbuffer- Returns:
trueif buffer's literal starts with givenpattern, or both are empty.
-