MCPcopy Index your code
hub / github.com/codenameone/CodenameOne / StringBuffer

Class StringBuffer

vm/JavaAPI/src/java/lang/StringBuffer.java:36–364  ·  view source on GitHub ↗

A string buffer implements a mutable sequence of characters. A string buffer is like a String, but can be modified. At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls. String buffers are safe

Source from the content-addressed store, hash-verified

34 * Since: JDK1.0, CLDC 1.0 See Also:ByteArrayOutputStream, String
35 */
36public final class StringBuffer implements CharSequence, Appendable {
37 private StringBuilder internal;
38 /**
39 * Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
40 */
41 public StringBuffer(){
42 internal = new StringBuilder();
43 }
44
45 /**
46 * Constructs a string buffer with no characters in it and an initial capacity specified by the length argument.
47 * length - the initial capacity.
48 * - if the length argument is less than 0.
49 */
50 public StringBuffer(int length){
51 internal = new StringBuilder(length);
52 }
53
54 /**
55 * Constructs a string buffer so that it represents the same sequence of characters as the string argument; in other words, the initial contents of the string buffer is a copy of the argument string. The initial capacity of the string buffer is 16 plus the length of the string argument.
56 * str - the initial contents of the buffer.
57 */
58 public StringBuffer(java.lang.String str){
59 internal = new StringBuilder(str);
60 }
61
62 /**
63 * Appends the string representation of the boolean argument to the string buffer.
64 * The argument is converted to a string as if by the method String.valueOf, and the characters of that string are then appended to this string buffer.
65 */
66 public java.lang.StringBuffer append(boolean b){
67 internal.append(b);
68 return this;
69 }
70
71 /**
72 * Appends the string representation of the char argument to this string buffer.
73 * The argument is appended to the contents of this string buffer. The length of this string buffer increases by 1.
74 * The overall effect is exactly as if the argument were converted to a string by the method String.valueOf(char) and the character in that string were then appended to this StringBuffer object.
75 */
76 public java.lang.StringBuffer append(char c){
77 internal.append(c);
78 return this;
79 }
80
81 java.lang.StringBuffer append(char[] str){
82 internal.append(str);
83 return this;
84 }
85
86 /**
87 * Appends the string representation of a subarray of the char array argument to this string buffer.
88 * Characters of the character array str, starting at index offset, are appended, in order, to the contents of this string buffer. The length of this string buffer increases by the value of len.
89 * The overall effect is exactly as if the arguments were converted to a string by the method String.valueOf(char[],int,int) and the characters of that string were then appended to this StringBuffer object.
90 */
91 public java.lang.StringBuffer append(char[] str, int offset, int len){
92 internal.append(str, offset, len);
93 return this;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected