se.unlogic.standardutils.string
Class StringUtils

java.lang.Object
  extended by se.unlogic.standardutils.string.StringUtils

public class StringUtils
extends Object


Constructor Summary
StringUtils()
           
 
Method Summary
static int countOccurrences(String string, String snippet)
           
static boolean isEmpty(String string)
           
static boolean isValidURL(String urlstring)
           
static boolean isValidUUID(String uuidstring)
           
static String parseUTF8(String encodedString)
           
static String readFileAsString(File file)
           
static String readFileAsString(String filePath)
           
static String readStreamAsString(InputStream inputStream)
           
static String removeHTMLTags(String sequence)
           
static String repeatString(String string, int repetitionCount)
           
static void repeatString(String string, int repetitionCount, StringBuilder stringBuilder)
           
static String replaceCharacters(String sequence, Properties characterSet)
          Replaces characters in a character sequence
static ArrayList<String> splitOnLineBreak(String string, boolean removeDuplicates)
          Takes a string and splits it on linebreaks (\n) and also removes any linebreak (\n) and carriage return (\r) characters from the string segments
static String substring(String string, int maxChars, String suffix)
           
static String toCommaSeparatedString(Collection<? extends Object> list)
           
static String toCommaSeparatedString(List<? extends Object> list, Field field)
           
static String toCommaSeparatedString(Object[] array)
           
static String toFirstLetterLowercase(String string)
           
static String toFirstLetterUppercase(String string)
           
static String toLogFormat(String string, int maxLength)
           
static String toQuotedCommaSeparatedString(List<? extends Object> list)
           
static String toQuotedCommaSeparatedString(Object[] array)
           
static String toSentenceCase(String string)
           
static String unEscapeHTML(String sequence)
          Unescapes escaped HTML characters Based on a fixed set of escaped HTML characters from the latin-1 set
 
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

unEscapeHTML

public static String unEscapeHTML(String sequence)
Unescapes escaped HTML characters Based on a fixed set of escaped HTML characters from the latin-1 set

Parameters:
sequence - - the secuence of characters to unescape characters in
Returns:
- a sequenced without escaped HTML characters

replaceCharacters

public static String replaceCharacters(String sequence,
                                       Properties characterSet)
Replaces characters in a character sequence

Parameters:
sequence - - the secuence of characters to replace characters in
characterSet - - a set of key=value character mappings, e.g. #=#. Occurences of key, e.g. "#" will be replaced by value, e.g. "#"
Returns:
- a sequenced with replaced characters

removeHTMLTags

public static String removeHTMLTags(String sequence)

parseUTF8

public static String parseUTF8(String encodedString)

isValidUUID

public static boolean isValidUUID(String uuidstring)

isValidURL

public static boolean isValidURL(String urlstring)

toQuotedCommaSeparatedString

public static String toQuotedCommaSeparatedString(List<? extends Object> list)

toQuotedCommaSeparatedString

public static String toQuotedCommaSeparatedString(Object[] array)

toCommaSeparatedString

public static String toCommaSeparatedString(Collection<? extends Object> list)

toCommaSeparatedString

public static String toCommaSeparatedString(Object[] array)

toCommaSeparatedString

public static String toCommaSeparatedString(List<? extends Object> list,
                                            Field field)
                                     throws IllegalArgumentException,
                                            IllegalAccessException
Throws:
IllegalArgumentException
IllegalAccessException

readFileAsString

public static String readFileAsString(String filePath)
                               throws IOException
Throws:
IOException

readFileAsString

public static String readFileAsString(File file)
                               throws IOException
Throws:
IOException

readStreamAsString

public static String readStreamAsString(InputStream inputStream)
                                 throws IOException
Throws:
IOException

isEmpty

public static boolean isEmpty(String string)

substring

public static String substring(String string,
                               int maxChars,
                               String suffix)

toLogFormat

public static String toLogFormat(String string,
                                 int maxLength)

toSentenceCase

public static String toSentenceCase(String string)

toFirstLetterUppercase

public static String toFirstLetterUppercase(String string)

toFirstLetterLowercase

public static String toFirstLetterLowercase(String string)

repeatString

public static String repeatString(String string,
                                  int repetitionCount)

repeatString

public static void repeatString(String string,
                                int repetitionCount,
                                StringBuilder stringBuilder)

splitOnLineBreak

public static ArrayList<String> splitOnLineBreak(String string,
                                                 boolean removeDuplicates)
Takes a string and splits it on linebreaks (\n) and also removes any linebreak (\n) and carriage return (\r) characters from the string segments

Parameters:
string - the string to be split
Returns:
String array containing the split segments of the string

countOccurrences

public static int countOccurrences(String string,
                                   String snippet)


Copyright © 2011. All Rights Reserved.