fullRuntime/src/sc/util/StringUtil.java
public static String ellipsis(String text, int maxLength, boolean wholeWords) {
      if ((text == null) || (text.length() <= maxLength))
	 return text;

      // Handle the pathological cases (maxLength < 3)
      switch (maxLength) {
      case 0:
	 return "";
      case 1: 
	 return ".";
      case 2:
	 return "..";
      }

      int endIndex = maxLength - 3;

      if (wholeWords && (text.charAt(endIndex) != ' ')) {
	 int lastSpace = text.lastIndexOf(' ', endIndex);
	 // If there are no spaces in our truncated string at all,
	 // just end it in the middle of the word.
	 if (lastSpace != -1) {
	    endIndex = lastSpace;
	 }	    
      }
      return text.substring(0, endIndex) + "...";
   }
/**
    * Truncates the text String, adding ellipsis ("...") at the end.
    * If wholeWords is true, the text before the ellipsis is further
    * truncated so that it ends at the end of a word.
    */
Truncates the text String, adding ellipsis ("...") at the end.
If wholeWords is true, the text before the ellipsis is further
truncated so that it ends at the end of a word.
Truncates the text String adding ellipsis ( " ... " ) at the end . If wholeWords is true the text before the ellipsis is further truncated so that it ends at the end of a word .
public static String ellipsis(String text, int maxLength, boolean wholeWords) {
      if ((text == null) || (text.length() <= maxLength))
	 return text;
      switch (maxLength) {
      case 0:
	 return "";
      case 1: 
	 return ".";
      case 2:
	 return "..";
      }
      int endIndex = maxLength - 3;
      if (wholeWords && (text.charAt(endIndex) != ' ')) {
	 int lastSpace = text.lastIndexOf(' ', endIndex);
	 if (lastSpace != -1) {
	    endIndex = lastSpace;
	 }	    
      }
      return text.substring(0, endIndex) + "...";
   }
public static String ellipsis ( String text , int maxLength , boolean wholeWords ) { if ( ( text == null ) || ( text . length ( ) <= maxLength ) ) return text ; switch ( maxLength ) { case 0 : return "" ; case 1 : return "." ; case 2 : return ".." ; } int endIndex = maxLength - 3 ; if ( wholeWords && ( text . charAt ( endIndex ) != ' ' ) ) { int lastSpace = text . lastIndexOf ( ' ' , endIndex ) ; if ( lastSpace != - 1 ) { endIndex = lastSpace ; } } return text . substring ( 0 , endIndex ) + "..." ; }
Truncates the text String, adding ellipsis ("...") at the end.
Truncates the text String adding ellipsis ( " ... " ) at the end .
// Handle the pathological cases (maxLength < 3) // If there are no spaces in our truncated string at all, // just end it in the middle of the word.