Class WhiteSpaceUtil


  • public class WhiteSpaceUtil
    extends java.lang.Object
    Utility class for white-space handling methods that are used both in pdfHTML and the iText-core SVG module
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Set<java.lang.Character> EM_SPACES  
    • Constructor Summary

      Constructors 
      Constructor Description
      WhiteSpaceUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String collapseConsecutiveSpaces​(java.lang.String s)
      Collapse all consecutive spaces of the passed String into single spaces
      static boolean isNonEmSpace​(char ch)
      Checks if a character is white space value that is not em, en or similar special whitespace character.
      static boolean isNonLineBreakSpace​(char ch)
      Checks if a character is white space value that doesn't cause a newline.
      private static java.lang.String keepLineBreaksAndSpaces​(java.lang.String text)  
      static java.lang.String processWhitespaces​(java.lang.String text, boolean keepLineBreaks, boolean collapseSpaces)
      Processes whitespaces according to provided keepLineBreaks and collapseSpaces values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EM_SPACES

        private static final java.util.Set<java.lang.Character> EM_SPACES
    • Constructor Detail

      • WhiteSpaceUtil

        public WhiteSpaceUtil()
    • Method Detail

      • collapseConsecutiveSpaces

        public static java.lang.String collapseConsecutiveSpaces​(java.lang.String s)
        Collapse all consecutive spaces of the passed String into single spaces
        Parameters:
        s - String to collapse
        Returns:
        a String containing the contents of the input, with consecutive spaces collapsed
      • isNonEmSpace

        public static boolean isNonEmSpace​(char ch)
        Checks if a character is white space value that is not em, en or similar special whitespace character.
        Parameters:
        ch - the character
        Returns:
        true, if the character is a white space character, but no em, en or similar
      • isNonLineBreakSpace

        public static boolean isNonLineBreakSpace​(char ch)
        Checks if a character is white space value that doesn't cause a newline.
        Parameters:
        ch - the character
        Returns:
        true, if the character is a white space character, but no newline
      • processWhitespaces

        public static java.lang.String processWhitespaces​(java.lang.String text,
                                                          boolean keepLineBreaks,
                                                          boolean collapseSpaces)
        Processes whitespaces according to provided keepLineBreaks and collapseSpaces values.
        Parameters:
        text - string to process
        keepLineBreaks - whether to keep line breaks
        collapseSpaces - whether to collapse spaces
        Returns:
        processed string
      • keepLineBreaksAndSpaces

        private static java.lang.String keepLineBreaksAndSpaces​(java.lang.String text)