Class JRStringUtil


  • public final class JRStringUtil
    extends Object
    Author:
    Teodor Danciu (teodord@users.sourceforge.net)
    • Field Detail

      • 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.
      • xmlEncode

        public static String xmlEncode​(String text)
      • xmlEncode

        public static String xmlEncode​(String text,
                                       String invalidCharReplacement)
      • encodeXmlAttribute

        public static String encodeXmlAttribute​(String text)
      • encodeXmlAttribute

        public static String encodeXmlAttribute​(String text,
                                                boolean exceptApos)
      • htmlEncode

        public static String htmlEncode​(String text)
      • 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 -
      • getString

        public static String getString​(Object value)
      • 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
      • getCSSClass

        public static String getCSSClass​(String name)
      • cssClassReplacement

        protected static String cssClassReplacement​(String text)
      • 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 3999
        isUpperCase - specifies whether the result should be made of upper case characters
        Returns:
        the Roman numeral representation of this number