Package eu.woolplatform.utils
Class StringEscape
- java.lang.Object
-
- eu.woolplatform.utils.StringEscape
-
public class StringEscape extends Object
This class can resolve escaped characters in a string and it can replace special characters with escaped characters. It supports the following escapes:
- \n -> new line
- \r -> carriage return
- \t -> tab
- \c (where c is any other character including \ and ") -> c
-
-
Constructor Summary
Constructors Constructor Description StringEscape()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringescape(String s)Replaces special characters with an escape sequence.static Stringescape(String s, char[] illegals)Replaces special characters with an escape sequence.static StringresolveEscapes(String s)Replaces escaped characters in the specified string.static StringresolveEscapes(String s, char[] illegals)Replaces escaped characters in the specified string.
-
-
-
Method Detail
-
resolveEscapes
public static String resolveEscapes(String s) throws ParseException
Replaces escaped characters in the specified string. This method throws an exception if it finds a lone \.- Parameters:
s- a string- Returns:
- the string without escapes
- Throws:
ParseException- if a lone \ is found
-
resolveEscapes
public static String resolveEscapes(String s, char[] illegals) throws ParseException
Replaces escaped characters in the specified string. This method throws an exception if it finds a lone \ or if one of the specified illegal characters is not escaped.- Parameters:
s- a stringillegals- characters that must be escaped- Returns:
- the string without escapes
- Throws:
ParseException- if a lone \ is found or if one of the illegal characters is not escaped
-
escape
public static String escape(String s)
Replaces special characters with an escape sequence. It escapes the characters listed at the top of this page.- Parameters:
s- a string- Returns:
- the escaped string
-
escape
public static String escape(String s, char[] illegals)
Replaces special characters with an escape sequence. It escapes the characters listed at the top of this page as well as the specified illegal characters (which are considered illegal if they are not escaped).- Parameters:
s- a stringillegals- characters that must be escaped- Returns:
- the escaped string
-
-