org.apache.maven.surefire.util.internal
Class StringUtils

java.lang.Object
  extended by org.apache.maven.surefire.util.internal.StringUtils

public class StringUtils
extends Object

Common String manipulation routines.

Originally from Turbine and the GenerationJavaCore library.

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

Constructor Summary
StringUtils()
           
 
Method Summary
static int escapeBytesToPrintable(byte[] out, int outoff, byte[] input, int off, int len)
          Escapes the bytes in the array str to contain only 'printable' bytes.
static void escapeToPrintable(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 boolean isBlank(String str)
           Checks if a (trimmed) String is null or blank.
static String[] split(String text, String separator)
           
static int unescapeBytes(byte[] out, String str)
          Reverses the effect of escapeBytesToPrintable(byte[], int, byte[], int, int).
static void unescapeString(StringBuilder target, CharSequence str)
          Reverses the effect of escapeToPrintable(StringBuilder, CharSequence).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtils

public StringUtils()
Method Detail

split

public static String[] split(String text,
                             String separator)

isBlank

public static boolean isBlank(String str)

Checks if a (trimmed) String is null or blank.

Parameters:
str - the String to check
Returns:
true if the String is null, or length zero once trimmed

escapeToPrintable

public static void escapeToPrintable(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.

The reverse-method is unescapeString(StringBuilder, CharSequence).

Parameters:
target - target string buffer. The required space will be up to str.getBytes().length * 5 chars.
str - String to escape values in, may be null.

unescapeString

public static void unescapeString(StringBuilder target,
                                  CharSequence str)
Reverses the effect of escapeToPrintable(StringBuilder, CharSequence).

Parameters:
target - target string buffer
str - the String to un-escape, as created by escapeToPrintable(StringBuilder, CharSequence)

escapeBytesToPrintable

public static int escapeBytesToPrintable(byte[] out,
                                         int outoff,
                                         byte[] input,
                                         int off,
                                         int len)
Escapes the bytes in the array str to contain only 'printable' bytes.

Escaping is done by encoding the non-nicely printable bytes to '\' + upperCaseHexBytes(byte).

A save length of out is len * 3 + outoff.

The reverse-method is unescapeBytes(byte[], String).

Parameters:
out - output buffer
outoff - offset in the output buffer
input - input buffer
off - offset in the input buffer
len - number of bytes to copy from the input buffer
Returns:
number of bytes written to out

unescapeBytes

public static int unescapeBytes(byte[] out,
                                String str)
Reverses the effect of escapeBytesToPrintable(byte[], int, byte[], int, int).

A save length of out is str.length()

Parameters:
out - the target byte array
str - the input String
Returns:
the number of bytes written to out


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.