nl.lxtreme.ols.util
Class StringUtils

java.lang.Object
  extended by nl.lxtreme.ols.util.StringUtils

public final class StringUtils
extends Object

Provides some common string utilities.


Method Summary
static String integerToBinString(int aValue, int aFieldWidth)
          converts an integer to a bin string with leading zeros
static String integerToHexString(int aValue, int aFieldWidth)
          converts an integer to a hex string with leading zeros
static boolean isEmpty(String aValue)
          Returns whether the given string is actually empty, meaning null or an empty string.
static String[] tokenize(String aInput, String aDelimiters)
          Tokenizes a given input stream and breaks it into parts on the given delimiters.
static String[] tokenizeQuotedStrings(String aInput, String aDelimiters)
          Tokenizes a given input stream and breaks it into parts on the given delimiters.
static String unquote(String aInput)
          Removes all double quotes from the given input.
static String unquote(String aInput, char aQuoteChar)
          Removes all quotes, denoted by the given character, from the given input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

integerToBinString

public static String integerToBinString(int aValue,
                                        int aFieldWidth)
converts an integer to a bin string with leading zeros

Parameters:
aValue - integer value for conversion
aFieldWidth - number of charakters in field
Returns:
a nice string

integerToHexString

public static String integerToHexString(int aValue,
                                        int aFieldWidth)
converts an integer to a hex string with leading zeros

Parameters:
aValue - integer value for conversion
aFieldWidth - number of charakters in field
Returns:
a nice string

isEmpty

public static boolean isEmpty(String aValue)
Returns whether the given string is actually empty, meaning null or an empty string.

Parameters:
aValue - the string value to check for "emptyness", can be null.
Returns:
true if the given string is empty, false otherwise.

tokenize

public static String[] tokenize(String aInput,
                                String aDelimiters)
Tokenizes a given input stream and breaks it into parts on the given delimiters.

Parameters:
aInput - the input string to tokenize, can be null;
aDelimiters - the delimiter characters to break the given input on, cannot be null.
Returns:
the individual tokens of the given input, or null if the original input was null.

tokenizeQuotedStrings

public static String[] tokenizeQuotedStrings(String aInput,
                                             String aDelimiters)
Tokenizes a given input stream and breaks it into parts on the given delimiters. The tokens are considered to be double quoted strings.

Parameters:
aInput - the input string to tokenize, can be null;
aDelimiters - the delimiter characters to break the given input on, cannot be null.
Returns:
the individual tokens of the given input, or null if the original input was null.

unquote

public static String unquote(String aInput)
Removes all double quotes from the given input.

Parameters:
aInput - the input string to remove the quotes from, may be null.
Returns:
the unquoted version of the given input, or null if the original input was null.
See Also:
unquote(String, char)

unquote

public static String unquote(String aInput,
                             char aQuoteChar)
Removes all quotes, denoted by the given character, from the given input.

Parameters:
aInput - the input string to remove the quotes from, may be null;
aQuoteChar - the quote character to remove.
Returns:
the unquoted version of the given input, or null if the original input was null. If the given input contained leading and/or trailing whitespace, it is removed from the result.


Copyright © 2012 L'Xtreme IT consultancy. All Rights Reserved.