Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.util
Class StringUtils

java.lang.Object
  extended by net.java.sip.communicator.util.StringUtils

public final class StringUtils
extends Object

Utility class that helps to work with String class.

Author:
Grigorii Balutsel, Emil Ivov

Method Summary
static String concatenateWords(String string)
          Removes all spaces from the given string and returns a concatenated result string.
static boolean containsLetters(String string)
          Indicates if the given string contains any letters.
static String convertCamelCaseToDisplayString(String camelCase)
          Gets a String which represents the conversion of a specific camel-case formatted String to a more human-readable form (i.e.
static InputStream fromString(String string)
          Creates InputStream from the string in UTF8 encoding.
static InputStream fromString(String string, String encoding)
          Creates InputStream from the string in the specified encoding.
static byte[] getUTF8Bytes(String string)
          Returns the UTF8 bytes for string and handles the unlikely case where UTF-8 is not supported.
static String getUTF8String(byte[] bytes)
          Converts string into an UTF8 String and handles the unlikely case where UTF-8 is not supported.
static boolean isEquals(String s1, String s2)
          Indicates whether strings are equal.
static boolean isNullOrEmpty(String s)
          Indicates whether string is null or empty.
static boolean isNullOrEmpty(String s, boolean trim)
          Indicates whether string is null or empty.
static boolean isNumber(String string)
          Indicates if the given string is composed only of digits or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convertCamelCaseToDisplayString

public static String convertCamelCaseToDisplayString(String camelCase)
Gets a String which represents the conversion of a specific camel-case formatted String to a more human-readable form (i.e. with spaces between the words).

Parameters:
camelCase - a camel-case (or Pascal-case) formatted String from which a human-readable String is to be constructed
Returns:
a String which represents the conversion of the specified camel-case formatted String to a more human-readable form

isNullOrEmpty

public static boolean isNullOrEmpty(String s)
Indicates whether string is null or empty.

Parameters:
s - the string to analyze.
Returns:
true if string is null or empty.

isNullOrEmpty

public static boolean isNullOrEmpty(String s,
                                    boolean trim)
Indicates whether string is null or empty.

Parameters:
s - the string to analyze.
trim - indicates whether to trim the string.
Returns:
true if string is null or empty.

isEquals

public static boolean isEquals(String s1,
                               String s2)
Indicates whether strings are equal.

Parameters:
s1 - the string to analyze.
s2 - the string to analyze.
Returns:
true if string are equal.

fromString

public static InputStream fromString(String string)
                              throws UnsupportedEncodingException
Creates InputStream from the string in UTF8 encoding.

Parameters:
string - the string to convert.
Returns:
the InputStream.
Throws:
UnsupportedEncodingException - if UTF8 is unsupported.

fromString

public static InputStream fromString(String string,
                                     String encoding)
                              throws UnsupportedEncodingException
Creates InputStream from the string in the specified encoding.

Parameters:
string - the string to convert.
encoding - the encoding
Returns:
the InputStream.
Throws:
UnsupportedEncodingException - if the encoding is unsupported.

getUTF8Bytes

public static byte[] getUTF8Bytes(String string)
Returns the UTF8 bytes for string and handles the unlikely case where UTF-8 is not supported.

Parameters:
string - the String whose bytes we'd like to obtain.
Returns:
string's bytes.

getUTF8String

public static String getUTF8String(byte[] bytes)
Converts string into an UTF8 String and handles the unlikely case where UTF-8 is not supported.

Parameters:
bytes - the byte array that we'd like to convert into a String.
Returns:
the UTF-8 String.

isNumber

public static boolean isNumber(String string)
Indicates if the given string is composed only of digits or not.

Parameters:
string - the string to check
Returns:
true if the given string is composed only of digits, false - otherwise

containsLetters

public static boolean containsLetters(String string)
Indicates if the given string contains any letters.

Parameters:
string - the string to check for letters
Returns:
true if the given string contains letters, false - otherwise

concatenateWords

public static String concatenateWords(String string)
Removes all spaces from the given string and returns a concatenated result string.

Parameters:
string - the string to concatenate
Returns:
the concatenated string

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.