Class Wrap


  • public class Wrap
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isBlank​(java.lang.CharSequence cs)  
      static int length​(java.lang.CharSequence cs)  
      static java.lang.String wrap​(java.lang.String str, int wrapLength)
      Wraps a single line of text, identifying words by ' '.
      static java.lang.String wrap​(java.lang.String str, int wrapLength, java.lang.String newLineStr, boolean wrapLongWords)
      Wraps a single line of text, identifying words by ' '.
      static java.lang.String wrap​(java.lang.String str, int wrapLength, java.lang.String newLineStr, boolean wrapLongWords, java.lang.String wrapOn)
      Wraps a single line of text, identifying words by wrapOn.
      • Methods inherited from class java.lang.Object

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

      • length

        public static int length​(java.lang.CharSequence cs)
      • isBlank

        public static boolean isBlank​(java.lang.CharSequence cs)
      • wrap

        public static java.lang.String wrap​(java.lang.String str,
                                            int wrapLength)

        Wraps a single line of text, identifying words by ' '.

        New lines will be separated by the system property line separator. Very long words, such as URLs will not be wrapped.

        Leading spaces on a new line are stripped. Trailing spaces are not stripped.

        Parameters:
        str - the String to be word wrapped, may be null
        wrapLength - the column to wrap the words at, less than 1 is treated as 1
        Returns:
        a line with newlines inserted, null if null input
      • wrap

        public static java.lang.String wrap​(java.lang.String str,
                                            int wrapLength,
                                            java.lang.String newLineStr,
                                            boolean wrapLongWords)

        Wraps a single line of text, identifying words by ' '.

        Leading spaces on a new line are stripped. Trailing spaces are not stripped.

        Parameters:
        str - the String to be word wrapped, may be null
        wrapLength - the column to wrap the words at, less than 1 is treated as 1
        newLineStr - the string to insert for a new line, null uses the system property line separator
        wrapLongWords - true if long words (such as URLs) should be wrapped
        Returns:
        a line with newlines inserted, null if null input
      • wrap

        public static java.lang.String wrap​(java.lang.String str,
                                            int wrapLength,
                                            java.lang.String newLineStr,
                                            boolean wrapLongWords,
                                            java.lang.String wrapOn)

        Wraps a single line of text, identifying words by wrapOn.

        Leading spaces on a new line are stripped. Trailing spaces are not stripped.

        Parameters:
        str - the String to be word wrapped, may be null
        wrapLength - the column to wrap the words at, less than 1 is treated as 1
        newLineStr - the string to insert for a new line, null uses the system property line separator
        wrapLongWords - true if long words (such as URLs) should be wrapped
        wrapOn - regex expression to be used as a breakable characters, if blank string is provided a space character will be used
        Returns:
        a line with newlines inserted, null if null input