Code with Misuse: |
class StrBuilder { /** * Appends an object to the builder padding on the right to a fixed length. * The <code>toString</code> of the object is used. * If the object is larger than the length, the right hand side is lost. * If the object is null, null text value is used. * * @param obj the object to append, null uses null text * @param width the fixed field width, zero or negative has no effect * @param padChar the pad character to use * @return this, to enable chaining */ public StrBuilder appendFixedWidthPadRight(Object obj, int width, char padChar) { if (width > 0) { ensureCapacity(size + width); String str = (obj == null ? getNullText() : obj.toString()); int strLen = str.length(); if (strLen >= width) { str.getChars(0, width, buffer, size); } else { int padLen = width - strLen; str.getChars(0, strLen, buffer, size); for (int i = 0; i < padLen; i++) { buffer[size + strLen + i] = padChar; } } size += width; } return this; }
}
|