net.sourceforge.jaulp.string
Class StringUtils

java.lang.Object
  extended by net.sourceforge.jaulp.string.StringUtils

public final class StringUtils
extends java.lang.Object

Utility class for the use of String object.

Version:
1.0
Author:
Asterios Raptis

Constructor Summary
StringUtils()
           
 
Method Summary
static java.lang.String convertCharsToUnicodeChars(java.lang.String s, boolean toLowerCase)
          Converts all characters from the given String to unicodes characters encoded like \uxxxx.
static byte[] convertToBytearray(char[] source)
          Converts the given chararray to a bytearray.
static java.lang.String getAttributName(java.lang.String name)
          Gets the Attribut-name without brackets.
static java.lang.String getIndex(java.lang.String name)
          Gets the first index from the brackets.
static java.lang.String getItemNumber(java.lang.String name)
          Gets the ItemNumber from the String name.
static java.lang.String getStringAfterUnderscore(java.lang.String element)
          The Method getStringAfterUnderscore(String) gets the substring after the first underscore.
static java.lang.String getStringBeforeUnderscore(java.lang.String element)
          The Method getStringBeforeUnderscore(String) gets the substring before the first underscore.
static boolean isNullOrEmpty(java.lang.String str)
          The method isEmpty(String) checks if the given String is empty or null.
static boolean isNumber(java.lang.String testString)
          Checks if the given String is an Number.
static java.lang.String putQuotesToString(java.lang.String s)
          Puts to the given String at the start and end quotes.
static java.lang.String readLine(java.lang.String stringWithCarriageReturns)
          Reads the given String till it finds a carriage return and returns it.
static java.lang.String[] removeEmptyString(java.lang.String[] words)
          Removes empty Strings from the given string array and gives it back.
static java.lang.String removeQuotesFromString(java.lang.String s)
          Removes from the given String the first and the last character.
static java.lang.String replaceAll(java.lang.String original, java.lang.String findString, java.lang.String replaceWith)
          Replaces all occurrences of a String within another String.
static java.lang.String setFirstCharacterToUpperCase(java.lang.String fieldName)
          Sets the first character from the given string to upper case and returns it.
 
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

getItemNumber

public static final java.lang.String getItemNumber(java.lang.String name)
Gets the ItemNumber from the String name. For example: If "indio[5][1]" is the given String than the name is "indio" and the first index is "5" and the second is "1". Than the Method returns "1".

Parameters:
name - the name
Returns:
the ItemNumber

getAttributName

public static final java.lang.String getAttributName(java.lang.String name)
Gets the Attribut-name without brackets. For example: If "indio[5][1]" is the given String than the name is "indio" and the first index is "5" and the second is "1". Than the Method returns "indio".

Parameters:
name - The name with brackets.
Returns:
The name without brackets.

getIndex

public static final java.lang.String getIndex(java.lang.String name)
Gets the first index from the brackets. For example: If "indio[5][1]" is the given String than the name is "indio" and the first index is "5" and the second is "1". Than the Method returns "5".

Parameters:
name - The name from the Attribute
Returns:
the index from the Attribute

getStringBeforeUnderscore

public static final java.lang.String getStringBeforeUnderscore(java.lang.String element)
The Method getStringBeforeUnderscore(String) gets the substring before the first underscore. For example:Assume that element=foobar_value then the result string is "foobar".

Parameters:
element - The element to get the substing.
Returns:
The result String.

getStringAfterUnderscore

public static final java.lang.String getStringAfterUnderscore(java.lang.String element)
The Method getStringAfterUnderscore(String) gets the substring after the first underscore. For example:Assume that element=foobar_value then the result string is "value".

Parameters:
element - The element to get the substing.
Returns:
The result String.

isNullOrEmpty

public static final boolean isNullOrEmpty(java.lang.String str)
The method isEmpty(String) checks if the given String is empty or null.

Parameters:
str - The String to check.
Returns:
true if the given String is empty or null otherwise false.

replaceAll

public static final java.lang.String replaceAll(java.lang.String original,
                                                java.lang.String findString,
                                                java.lang.String replaceWith)
Replaces all occurrences of a String within another String.

Parameters:
original - The String to search.
findString - The search pattern.
replaceWith - Replace with that String.
Returns:
Returns a new String with the replaced Strings.

readLine

public static final java.lang.String readLine(java.lang.String stringWithCarriageReturns)
Reads the given String till it finds a carriage return and returns it.

Parameters:
stringWithCarriageReturns - The String.
Returns:
Return the String till the carriage return.

isNumber

public static final boolean isNumber(java.lang.String testString)
Checks if the given String is an Number.

Parameters:
testString - The String to check.
Returns:
true if the given String is a number otherwise false.

removeQuotesFromString

public static final java.lang.String removeQuotesFromString(java.lang.String s)
Removes from the given String the first and the last character.

Parameters:
s - The String to handle.
Returns:
The String with the without the first and the last character.

putQuotesToString

public static final java.lang.String putQuotesToString(java.lang.String s)
Puts to the given String at the start and end quotes.

Parameters:
s - The String to handle.
Returns:
The String with quotes.

convertToBytearray

public static final byte[] convertToBytearray(char[] source)
Converts the given chararray to a bytearray.

Parameters:
source - the source.
Returns:
the byte[]

setFirstCharacterToUpperCase

public static final java.lang.String setFirstCharacterToUpperCase(java.lang.String fieldName)
Sets the first character from the given string to upper case and returns it. Example:
Given fieldName: userName
Result: UserName

Parameters:
fieldName - The String to modify.
Returns:
The modified string.

removeEmptyString

public static java.lang.String[] removeEmptyString(java.lang.String[] words)
Removes empty Strings from the given string array and gives it back. For instance if you use the String.split("\\W") method you get all the words from the given String as an string array. But this array contains empty Strings too. This method removes this empty strings from that array.

Parameters:
words - The string array to remove empty strings.
Returns:
An string array without empty Strings.

convertCharsToUnicodeChars

public static java.lang.String convertCharsToUnicodeChars(java.lang.String s,
                                                          boolean toLowerCase)
Converts all characters from the given String to unicodes characters encoded like \uxxxx.

Parameters:
s - The String to convert.
toLowerCase - If true the letters from the unicode characters are lower case.
Returns:
The converted String.


Copyright © 2010. All Rights Reserved.