2013-07-02 20:52:38 -06:00
|
|
|
/* Copyright (c) 2008-2013, Avian Contributors
|
2008-02-19 11:06:52 -07:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
|
|
for any purpose with or without fee is hereby granted, provided
|
|
|
|
that the above copyright notice and this permission notice appear
|
|
|
|
in all copies.
|
|
|
|
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
|
|
details. */
|
|
|
|
|
2007-07-28 19:29:01 -06:00
|
|
|
package java.lang;
|
|
|
|
|
2008-07-03 09:16:32 -06:00
|
|
|
public class StringBuffer implements CharSequence {
|
2007-07-29 17:32:23 -06:00
|
|
|
private final StringBuilder sb;
|
|
|
|
|
2007-08-30 17:31:32 -06:00
|
|
|
public StringBuffer(String s) {
|
|
|
|
sb = new StringBuilder(s);
|
|
|
|
}
|
|
|
|
|
2007-07-29 17:32:23 -06:00
|
|
|
public StringBuffer(int capacity) {
|
|
|
|
sb = new StringBuilder(capacity);
|
|
|
|
}
|
|
|
|
|
|
|
|
public StringBuffer() {
|
|
|
|
this(0);
|
|
|
|
}
|
2007-07-28 19:29:01 -06:00
|
|
|
|
|
|
|
public synchronized StringBuffer append(String s) {
|
|
|
|
sb.append(s);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2009-08-20 08:59:22 -06:00
|
|
|
public synchronized StringBuffer append(CharSequence s) {
|
|
|
|
sb.append(s);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized StringBuffer append(StringBuffer s) {
|
|
|
|
sb.append(s);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-07-28 19:29:01 -06:00
|
|
|
public synchronized StringBuffer append(Object o) {
|
|
|
|
sb.append(o);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-08-14 19:14:55 -06:00
|
|
|
public synchronized StringBuffer append(char v) {
|
|
|
|
sb.append(v);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2008-01-18 16:16:24 -07:00
|
|
|
public synchronized StringBuffer append(boolean v) {
|
|
|
|
sb.append(v);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-07-28 19:29:01 -06:00
|
|
|
public synchronized StringBuffer append(int v) {
|
|
|
|
sb.append(v);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized StringBuffer append(long v) {
|
|
|
|
sb.append(v);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-10-25 14:26:51 -06:00
|
|
|
public synchronized StringBuffer append(float v) {
|
|
|
|
sb.append(v);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2008-01-30 16:26:30 -07:00
|
|
|
public synchronized StringBuffer append(double v) {
|
|
|
|
sb.append(v);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-08-30 17:31:32 -06:00
|
|
|
public synchronized StringBuffer append(char[] b, int offset, int length) {
|
|
|
|
sb.append(b, offset, length);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2008-07-13 18:55:05 -06:00
|
|
|
public synchronized StringBuffer append(char[] b) {
|
|
|
|
sb.append(b, 0, b.length);
|
|
|
|
return this;
|
|
|
|
}
|
2008-11-11 08:20:49 -07:00
|
|
|
|
|
|
|
public synchronized int indexOf(String s) {
|
|
|
|
return sb.indexOf(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized int indexOf(String s, int fromIndex) {
|
|
|
|
return sb.indexOf(s, fromIndex);
|
|
|
|
}
|
|
|
|
|
2007-08-30 17:31:32 -06:00
|
|
|
public synchronized StringBuffer insert(int i, String s) {
|
|
|
|
sb.insert(i, s);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-09-12 18:21:37 -06:00
|
|
|
public synchronized StringBuffer insert(int i, char c) {
|
|
|
|
sb.insert(i, c);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2008-11-11 08:20:49 -07:00
|
|
|
public synchronized StringBuffer insert(int i, int v) {
|
|
|
|
sb.insert(i, v);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-10-29 15:07:36 -06:00
|
|
|
public synchronized StringBuffer delete(int start, int end) {
|
|
|
|
sb.delete(start, end);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-07-28 20:15:45 -06:00
|
|
|
public synchronized StringBuffer deleteCharAt(int i) {
|
|
|
|
sb.deleteCharAt(i);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-08-30 17:31:32 -06:00
|
|
|
public synchronized char charAt(int i) {
|
|
|
|
return sb.charAt(i);
|
|
|
|
}
|
|
|
|
|
2007-07-28 19:29:01 -06:00
|
|
|
public synchronized int length() {
|
|
|
|
return sb.length();
|
|
|
|
}
|
|
|
|
|
2007-10-29 15:07:36 -06:00
|
|
|
public synchronized StringBuffer replace(int start, int end, String str) {
|
|
|
|
sb.replace(start, end, str);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2007-07-28 20:15:45 -06:00
|
|
|
public synchronized void setLength(int v) {
|
|
|
|
sb.setLength(v);
|
|
|
|
}
|
|
|
|
|
2008-11-11 08:20:49 -07:00
|
|
|
public synchronized void setCharAt(int index, char ch) {
|
|
|
|
sb.setCharAt(index, ch);
|
|
|
|
}
|
|
|
|
|
2009-08-13 09:02:00 -06:00
|
|
|
public synchronized void getChars(int srcStart, int srcEnd, char[] dst,
|
|
|
|
int dstStart)
|
2007-07-28 19:29:01 -06:00
|
|
|
{
|
2009-08-13 09:02:00 -06:00
|
|
|
sb.getChars(srcStart, srcEnd, dst, dstStart);
|
2007-07-28 19:29:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String toString() {
|
|
|
|
return sb.toString();
|
|
|
|
}
|
2008-07-03 09:16:32 -06:00
|
|
|
|
|
|
|
public String substring(int start, int end) {
|
|
|
|
return sb.substring(start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
public CharSequence subSequence(int start, int end) {
|
|
|
|
return sb.subSequence(start, end);
|
|
|
|
}
|
2007-07-28 19:29:01 -06:00
|
|
|
}
|