org.opcfoundation.ua.utils
Class StringUtils

java.lang.Object
  extended by org.opcfoundation.ua.utils.StringUtils

public class StringUtils
extends Object

Utility functions for manipulating string data.


Constructor Summary
StringUtils()
           
 
Method Summary
static String addLineBreaks(String s, int lineLength)
          Add line breaks to the string.
static boolean equals(String str1, String str2)
          Make a null safe equals comparison of strings.
static String lineSeparator()
           
static String removeLineBreaks(String string)
          Remove line breaks from the string.
static String removeWhitespace(String string)
          Returns a string which has all whitespace characters removed from the given string.
 
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

lineSeparator

public static String lineSeparator()
Returns:
the current system lineSeparator. Equals to 'System.getProperty("line.separator")'

addLineBreaks

public static String addLineBreaks(String s,
                                   int lineLength)

Add line breaks to the string.

Parameters:
s - the string to convert.
lineLength - the number of characters per line. Use 0 or negative to omit the line breaks.
Returns:
a String with lineSeparator() added after every lineLength characters.

removeLineBreaks

public static String removeLineBreaks(String string)

Remove line breaks from the string.

Replaces all newline ("\n") and linefeed ("\r") characters in string with an empty string.

Parameters:
string - the string to convert
Returns:
the string without any line break characters.

removeWhitespace

public static String removeWhitespace(String string)
Returns a string which has all whitespace characters removed from the given string.


equals

public static boolean equals(String str1,
                             String str2)
Make a null safe equals comparison of strings.

Parameters:
str1 - first string
str2 - second string
Returns:
true, if strings are equal or if both are null


Copyright © 2018. All rights reserved.