Class TaskDescriptionText

java.lang.Object
io.meeds.task.mcp.util.TaskDescriptionText

public final class TaskDescriptionText extends Object
The description of a task as the plain text a compact list item carries: the stored HTML read as text, one line per block, without resolving its links or mentions, and cut to a bounded length.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The most characters a compact list item carries of a task's description; a longer one is cut at the last word or line boundary before it.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    cut(String text)
    Cuts a text to MAX_LENGTH characters at most: at the last whitespace (a line break or a space) at or before that length, so that no word is cut, or, for a text without any, at that length, never between the two halves of a surrogate pair.
    static String
    Reads an HTML description as plain text: the entities decoded, the tags removed, the text of a link or a mention kept as written, a line break after each block element (paragraph, list item, heading, table row…) and each <br>, the spaces of each line collapsed, and the blank lines dropped.

    Methods inherited from class Object

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

    • MAX_LENGTH

      public static final int MAX_LENGTH
      The most characters a compact list item carries of a task's description; a longer one is cut at the last word or line boundary before it.
      See Also:
  • Method Details

    • toPlainText

      public static String toPlainText(String html)
      Reads an HTML description as plain text: the entities decoded, the tags removed, the text of a link or a mention kept as written, a line break after each block element (paragraph, list item, heading, table row…) and each <br>, the spaces of each line collapsed, and the blank lines dropped.
      Parameters:
      html - a description, possibly null or blank
      Returns:
      its plain text, null when it holds no text
    • cut

      public static String cut(String text)
      Cuts a text to MAX_LENGTH characters at most: at the last whitespace (a line break or a space) at or before that length, so that no word is cut, or, for a text without any, at that length, never between the two halves of a surrogate pair. A text that fits is returned as is.
      Parameters:
      text - a text, possibly null
      Returns:
      the text, cut when longer than MAX_LENGTH