public void ensureCapacity(int minimum) { if (minimum < 0 || minimum < chars.length) return; expandCapacity(minimum); }
public JBossStringBuilder append(String string) { if (string == null) string = "null"; int length = string.length(); if (length == 0) return this; int afterAppend = pos + length; if (afterAppend > chars.length) expandCapacity(afterAppend); string.getChars(0, length, chars, pos); pos = afterAppend; return this; }
public JBossStringBuilder insert(int index, char[] string, int offset, int len) { int stringLength = string.length; if (index < 0 || index > pos || offset < 0 || len < 0 || (offset + len) > string.length) throw new IndexOutOfBoundsException("Invalid index=" + index + " offset=" + offset + " len=" + len + " string.length=" + stringLength + " length=" + pos); if (len == 0) return this; int afterAppend = pos + len; if (afterAppend > chars.length) expandCapacity(afterAppend); System.arraycopy(chars, index, chars, index + stringLength, pos - index); System.arraycopy(string, offset, chars, index, len); pos = afterAppend; return this; }
public JBossStringBuilder insert(int offset, String string) { if (offset < 0 || offset > pos) throw new IndexOutOfBoundsException("Invalid offset=" + offset + " length=" + pos); if (string == null) string = "null"; int stringLength = string.length(); int afterAppend = pos + stringLength; if (afterAppend > chars.length) expandCapacity(afterAppend); System.arraycopy(chars, offset, chars, offset + stringLength, pos - offset); string.getChars(0, stringLength, chars, offset); pos = afterAppend; return this; }
public JBossStringBuilder insert(int offset, CharSequence charSequence, int start, int end) { if (charSequence == null) charSequence = "null"; int sequenceLength = charSequence.length(); if (offset < 0 || offset > pos || start < 0 || end < 0 || start > sequenceLength || end > sequenceLength || start > end) throw new IndexOutOfBoundsException("Invalid offset=" + offset + " start=" + start + " end=" + end + " sequence.length()=" + sequenceLength + " length=" + pos); int len = end - start; if (len == 0) return this; int afterAppend = pos + len; if (afterAppend > chars.length) expandCapacity(afterAppend); System.arraycopy(chars, offset, chars, offset + sequenceLength, pos - offset); for (int i = start; i < end; ++i) chars[offset++] = charSequence.charAt(i); pos = afterAppend; return this; }
public void setLength(int newLength) { if (newLength < 0) throw new StringIndexOutOfBoundsException(newLength); if (newLength > chars.length) expandCapacity(newLength); Arrays.fill(chars, newLength, chars.length, '\0'); pos = newLength; }
public JBossStringBuilder append(StringBuffer buffer) { if (buffer == null) return append("null"); int length = buffer.length(); if (length == 0) return this; int afterAppend = pos + length; if (afterAppend > chars.length) expandCapacity(afterAppend); buffer.getChars(0, length, chars, pos); pos = afterAppend; return this; }
public JBossStringBuilder append(CharSequence charSequence, int start, int end) { if (charSequence == null) return append("null"); if (start < 0 || end < 0 || start > end || start > charSequence.length()) throw new IndexOutOfBoundsException("Invalid start=" + start + " end=" + end + " length=" + charSequence.length()); int length = end - start; if (length == 0) return this; int afterAppend = pos + length; if (afterAppend > chars.length) expandCapacity(afterAppend); for (int i = start; i < end; ++i) chars[pos++] = charSequence.charAt(i); pos = afterAppend; return this; }