Returns the last whitespace location in string, before width characters.
@param message The message to break.
@param width The width of the line.
@return The last whitespace location.
356921
private static int getLastSpace(final CharSequence message, int width) {
        final int length = message.length();
        int stopPos = width;
        int currPos = 0;
        int lastSpace = -1;
        boolean inEscape = false;
        while (currPos < stopPos && currPos < length) {
            final char c = message.charAt(currPos);
            if (c == ESCAPE_CHAR) {
                stopPos++;
                inEscape = true;
            } else if (inEscape) {
                stopPos++;
                if (Character.isLetter(c))
                    inEscape = false;
            } else if (Character.isWhitespace(c)) {
                lastSpace = currPos;
            }
            currPos++;
        }
        return lastSpace;
    }
420496
public float trimLastSpace()
    {
        BaseFont ft = font.getFont();
        if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') {
            if (value.length() > 1 && value.endsWith("\u0001")) {
                value = value.substring(0, value.length() - 1);
                return font.width('\u0001');
            }
        }
        else {
            if (value.length() > 1 && value.endsWith(" ")) {
                value = value.substring(0, value.length() - 1);
                return font.width(' ');
            }
        }
        return 0;
    }
1183223
protected String format(Object[] message)
    {
        String text=null;
        if(message!=null)
        {
            //init buffer
            StringBuilder buffer=new StringBuilder();
            
            //get array size
            int amount=message.length;
            
            Object object=null;
            for(int index=0;index<amount;index++)
            {
                //get next element
                object=message[index];
                
                //append to buffer
                buffer.append(object);
            }
            
            //get text
            text=buffer.toString();
        }
        
        return text;
    }
1303898
public <T extends CharSequence> T notEmpty(final T chars, final String message) {
        if (chars == null) {
            failNull(message);
        }
        if (chars.length() == 0) {
            fail(message);
        }
        return chars;
    }
1001494
public final double getWidth(int line) {
        if (strArray.length == 0) return 0.0;

        try {
            return textRenderer.getBounds(strArray[line]).getWidth();
        } catch (GLException e) {
            reset = true;
        }

        return 0.0;
    }
491101
public static String shortDebugString(final MessageOrBuilder message) {
    try {
      final StringBuilder sb = new StringBuilder();
      SINGLE_LINE_PRINTER.print(message, new TextGenerator(sb));
      // Single line mode currently might have an extra space at the end.
      return sb.toString().trim();
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
  }
639042
private int findEndOfLine(final ByteBuf buffer) {
        int totalLength = buffer.readableBytes();
        int i = buffer.forEachByte(buffer.readerIndex() + offset, totalLength - offset, ByteProcessor.FIND_LF);
        if (i >= 0) {
            offset = 0;
            if (i > 0 && buffer.getByte(i - 1) == '\r') {
                i--;
            }
        } else {
            offset = totalLength;
        }
        return i;
    }
1287807
public static List<CharSequence> getBodies(Message message) {
        XHTMLExtension xhtmlExtension = XHTMLExtension.from(message);
        if (xhtmlExtension != null)
            return xhtmlExtension.getBodies();
        else
            return null;
    }
1197882
public String buttonBarSpacer(int width) {

        StringBuffer result = new StringBuffer(128);
        result.append("<td><span class=\"norm\"><span unselectable=\"on\" class=\"txtbutton\" style=\"width: ");
        result.append(width);
        result.append("px;\"></span></span></td>\n");
        return result.toString();
    }
933803
static int findEndOfString(String sb) {
        int result;
        for (result = sb.length(); result > 0; result --) {
            if (!Character.isWhitespace(sb.charAt(result - 1))) {
                break;
            }
        }
        return result;
    }
1240934
public String colorize(String message){
        if(SUPPORTED){
            StringBuilder buff = new StringBuilder(start.length()+message.length()+END.length());
            buff.append(start).append(message).append(END);
            return buff.toString();
        }else
            return message;
    }
1231245
private static int findMinimumLeadingSpaces(String line, int count) {
        int length = line.length();
        int index = 0;
        while (index < length && index < count && Character.isWhitespace(line.charAt(index))) index++;
        return index;
    }
725446
private String formatMessage(final String message) {
        if (null != reformatter) {
            return reformatter.reformat(context, message);
        } else {
            return message;
        }
    }
94538
public final void setWidth(String width) {
        this.width = width;
        this.dynamicWidth = width != null && width.contains("%");
    }
288027
private static boolean isWhiteSpace(final char ch) {
        if (ch == CHAR_SPACE) return true;
        if (ch == CHAR_TAB) return true;
        if (ch == CHAR_NEW_LINE) return true;
        if (ch == CHAR_VERTICAL_TAB) return true;
        if (ch == CHAR_CARRIAGE_RETURN) return true;
        if (ch == CHAR_FORM_FEED) return true;
        return false;
    }
674901
public int getWidth(String text) {

        m_elem.setInnerText(text);
        return CmsDomUtil.getCurrentStyleInt(m_elem, CmsDomUtil.Style.width);
    }
270698
public static String msgToString(AbstractMessage message)
   {
     if (message == null) return STRING_NULL;
     if (message instanceof JsMessage) return message + "[" + ((JsMessage)message).getSystemMessageId() + "]";
     return message.toString();
   }