public void setLength(int length) { ensureCapacity(length); this.length = length; }
public void setLength(int length) { ensureCapacity(length); this.length = length; }
public ExceptionDrivenStringBuilder append(char ch) { try { buffer[length++] = ch; } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length); buffer[length - 1] = ch; } catch (IndexOutOfBoundsException ex) { buffer[length - 1] = ch; return append(ch); } return this; }
public ExceptionDrivenStringBuilder append(char[] chars, int from, int length) { try { System.arraycopy(chars, from, buffer, this.length, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + this.length); return append(chars, from, length); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + this.length); return append(chars, from, length); } this.length += length; return this; }
public ExceptionDrivenStringBuilder append(char ch) { try { buffer[length++] = ch; } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length); buffer[length - 1] = ch; } catch (IndexOutOfBoundsException ex) { buffer[length - 1] = ch; return append(ch); } return this; }
public ExceptionDrivenStringBuilder append(char[] chars, int from, int length) { try { System.arraycopy(chars, from, buffer, this.length, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + this.length); return append(chars, from, length); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + this.length); return append(chars, from, length); } this.length += length; return this; }
public ExceptionDrivenStringBuilder append(Date date) { try { length = DateIso8601.formatToChars(date, buffer, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + 28); return append(date); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + 28); return append(date); } return this; }
public ExceptionDrivenStringBuilder append(long i) { try { length = NumberToChars.toChars(i, buffer, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + 20); return append(i); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + 20); return append(i); } return this; }
public ExceptionDrivenStringBuilder append(int i) { try { length = NumberToChars.toChars(i, buffer, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + 11); return append(i); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + 11); return append(i); } return this; }
public ExceptionDrivenStringBuilder append(Date date) { try { length = DateIso8601.formatToChars(date, buffer, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + 28); return append(date); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + 28); return append(date); } return this; }
public ExceptionDrivenStringBuilder append(long i) { try { length = NumberToChars.toChars(i, buffer, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + 20); return append(i); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + 20); return append(i); } return this; }
public ExceptionDrivenStringBuilder append(int i) { try { length = NumberToChars.toChars(i, buffer, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + 11); return append(i); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + 11); return append(i); } return this; }
public ExceptionDrivenStringBuilder append(String s, int from, int to) { if (s == null) return append(CHARS_NULL, 0, 4); int l = to - from; try { s.getChars(from, to, buffer, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + l); return append(s, from, to); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + l); return append(s, from, to); } length += l; return this; }
public ExceptionDrivenStringBuilder append(String s, int from, int to) { if (s == null) return append(CHARS_NULL, 0, 4); int l = to - from; try { s.getChars(from, to, buffer, length); } catch (ArrayIndexOutOfBoundsException ex) { ensureCapacity(length + l); return append(s, from, to); } catch (IndexOutOfBoundsException ex) { ensureCapacity(length + l); return append(s, from, to); } length += l; return this; }
public ExceptionDrivenStringBuilder replace(int start, int end, String str) { if (start < 0) throw new StringIndexOutOfBoundsException(start); if (start > length) throw new StringIndexOutOfBoundsException("start > length()"); if (start > end) throw new StringIndexOutOfBoundsException("start > end"); if (end > length) end = length; int len = str.length(); int newLength = length + len - (end - start); ensureCapacity(newLength); System.arraycopy(buffer, end, buffer, start + len, length - end); str.getChars(0, len, buffer, start); length = newLength; return this; }