@SuppressWarnings("null")
  public static boolean isEmpty(@Nullable String text, int treshold) {

    // check if text block is really empty
    if (StringUtils.isEmpty(text)) {
      return true;
    }

    // check if text block has more than 20 chars
    if (text.length() > treshold) {
      return false;
    }

    // replace all whitespaces and nbsp's
    String cleanedText = StringUtils.replace(text, " ", "");
    cleanedText = StringUtils.replace(cleanedText, "&#160;", "");
    cleanedText = StringUtils.replace(cleanedText, "&nbsp;", "");
    cleanedText = StringUtils.replace(cleanedText, "\n", "");
    cleanedText = StringUtils.replace(cleanedText, "\r", "");
    return StringUtils.isEmpty(cleanedText) || "<p></p>".equals(cleanedText);
  }
@ SuppressWarnings ( "null" ) public static boolean isEmpty ( @ Nullable String text , int treshold ) { if ( StringUtils . isEmpty ( text ) ) { return true ; } if ( text . length ( ) > treshold ) { return false ; } String cleanedText = StringUtils . replace ( text , " " , "" ) ; cleanedText = StringUtils . replace ( cleanedText , "&#160;" , "" ) ; cleanedText = StringUtils . replace ( cleanedText , "&nbsp;" , "" ) ; cleanedText = StringUtils . replace ( cleanedText , "\n" , "" ) ; cleanedText = StringUtils . replace ( cleanedText , "\r" , "" ) ; return StringUtils . isEmpty ( cleanedText ) || "<p></p>" . equals ( cleanedText ) ; }
Check if the given formatted text block is empty.
A text block containing only one paragraph element and whitespaces is considered as empty.
A text block with more than pTreshold characters (raw data) is never considered as empty.
@param text XHTML text string (root element not needed)
@param treshold Treshold value - only strings with less than this number of characters are checked.
@return true if text block is empty