Package net.sf.jasperreports.engine.util
Class JRStringUtil
- java.lang.Object
-
- net.sf.jasperreports.engine.util.JRStringUtil
-
public final class JRStringUtil extends Object
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXCEPTION_MESSAGE_KEY_NUMBER_OUTSIDE_BOUNDS
protected static char[]
HEX_DIGITS
protected static String[]
HUNDRED_DIGITS
protected static String
JAVA_IDENTIFIER_PREFIX
protected static Pattern
PATTERN_CSS_INVALID_CHARACTER
protected static String[]
TEN_DIGITS
protected static String[]
THOUSAND_DIGITS
protected static String[]
UNIT_DIGITS
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static String
cssClassReplacement(String text)
static String
encodeXmlAttribute(String text)
static String
encodeXmlAttribute(String text, boolean exceptApos)
static String
escapeJavaScript(String input)
Escapes a text so that it can be used as a Java String literal.static String
escapeJavaStringLiteral(String text)
Escapes a text so that it can be used as a Java String literal.static String
escapeJSONString(String text)
Escapes a text to be used for a JSON string value.static String
escapeString4JavaScript(String input)
Escapes a Java String so that it can be used as a JavaScript String literal.static String
getCSSClass(String name)
static String
getJavaIdentifier(String name)
Takes a name and returns the same if it is a Java identifier; else it substitutes the illegal characters so that it can be an identifierstatic String
getLetterNumeral(int number, boolean isUpperCase)
static String
getRomanNumeral(int number, boolean isUpperCase)
static String
getString(Object value)
static List<Integer>
getTabIndexes(String text)
static String
htmlEncode(String text)
static String
replaceCRwithLF(String text)
This method replaces all occurrences of the CR character with the LF character, except when the CR is immediately followed by a LF (CRLF sequences), in which case the CR is removed.static List<String>
split(String[] srcArray, String delimiterRegExp)
static String
xmlEncode(String text)
static String
xmlEncode(String text, String invalidCharReplacement)
-
-
-
Field Detail
-
JAVA_IDENTIFIER_PREFIX
protected static final String JAVA_IDENTIFIER_PREFIX
- See Also:
- Constant Field Values
-
PATTERN_CSS_INVALID_CHARACTER
protected static final Pattern PATTERN_CSS_INVALID_CHARACTER
-
HEX_DIGITS
protected static final char[] HEX_DIGITS
-
EXCEPTION_MESSAGE_KEY_NUMBER_OUTSIDE_BOUNDS
public static final String EXCEPTION_MESSAGE_KEY_NUMBER_OUTSIDE_BOUNDS
- See Also:
- Constant Field Values
-
THOUSAND_DIGITS
protected static final String[] THOUSAND_DIGITS
-
HUNDRED_DIGITS
protected static final String[] HUNDRED_DIGITS
-
TEN_DIGITS
protected static final String[] TEN_DIGITS
-
UNIT_DIGITS
protected static final String[] UNIT_DIGITS
-
-
Method Detail
-
replaceCRwithLF
public static String replaceCRwithLF(String text)
This method replaces all occurrences of the CR character with the LF character, except when the CR is immediately followed by a LF (CRLF sequences), in which case the CR is removed.
-
getJavaIdentifier
public static String getJavaIdentifier(String name)
Takes a name and returns the same if it is a Java identifier; else it substitutes the illegal characters so that it can be an identifier- Parameters:
name
-
-
escapeJavaStringLiteral
public static String escapeJavaStringLiteral(String text)
Escapes a text so that it can be used as a Java String literal.- Parameters:
text
- the text- Returns:
- the text with escaped quotes and backslashes
-
escapeJavaScript
public static String escapeJavaScript(String input)
Escapes a text so that it can be used as a Java String literal.- Parameters:
input
-
-
escapeString4JavaScript
public static String escapeString4JavaScript(String input)
Escapes a Java String so that it can be used as a JavaScript String literal.- Parameters:
input
-
-
escapeJSONString
public static String escapeJSONString(String text)
Escapes a text to be used for a JSON string value.- Parameters:
text
- the text to escape for JSON- Returns:
- the escaped text if not null
-
getLetterNumeral
public static String getLetterNumeral(int number, boolean isUpperCase)
-
getRomanNumeral
public static String getRomanNumeral(int number, boolean isUpperCase)
- Parameters:
number
- an integer value between 1 and 3999isUpperCase
- specifies whether the result should be made of upper case characters- Returns:
- the Roman numeral representation of this number
-
-