Class HtmlLineSplitter

java.lang.Object
ghidra.util.html.HtmlLineSplitter

public class HtmlLineSplitter extends Object
Splits into lines a given String that is meant to be rendered as HTML.

Really, this class exists simply to remove hundreds of lines of code from HTMLUtilities, which is what this code supports. The methods in here could easily be in StringUtils, but to keep dependencies low on code that has such a specific use, it lives here, with a name that implies you shouldn't use it unless you are working with HTML.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Used when trying to split on word boundaries; the value past which to give up
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<String>
    split(String text, int maxLineLength)
    Splits the given line into multiple lines based upon the given max length.
    static List<String>
    split(String text, int maxLineLength, boolean retainSpacing)
    Splits the given line into multiple lines based upon the given max length.

    Methods inherited from class java.lang.Object

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

    • MAX_WORD_LENGTH

      public static final int MAX_WORD_LENGTH
      Used when trying to split on word boundaries; the value past which to give up
      See Also:
  • Constructor Details

    • HtmlLineSplitter

      public HtmlLineSplitter()
  • Method Details

    • split

      public static List<String> split(String text, int maxLineLength)
      Splits the given line into multiple lines based upon the given max length. This method will first split on each newline and then wrap each of the lines returned from that split.

      The wrapping routine will attempt to wrap at word boundaries.

      This method does not retain leading whitespace.

      Parameters:
      text - the text to wrap
      maxLineLength - the max desired length of each output line; 0 or less signals not to wrap the line based upon length
      Returns:
      the new lines
      See Also:
    • split

      public static List<String> split(String text, int maxLineLength, boolean retainSpacing)
      Splits the given line into multiple lines based upon the given max length. This method will first split on each newline and then wrap each of the lines returned from that split.

      The wrapping routine will attempt to wrap at word boundaries.

      Parameters:
      text - the text to wrap
      maxLineLength - the max desired length of each output line; 0 or less signals not to wrap the line based upon length
      retainSpacing - true signals to keep whitespace on line breaks; false discards leading whitespace
      Returns:
      the new lines
      See Also:
      • wrap(String, int, WhitespaceHandler)