OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 part of dart.core; | |
6 | |
7 /** | |
8 * A class for concatenating strings efficiently. | |
9 * | |
10 * Allows for the incremental building of a string using write*() methods. | |
11 * The strings are concatenated to a single string only when [toString] is | |
12 * called. | |
13 */ | |
14 class StringBuffer implements StringSink { | |
15 | |
16 /** Creates the string buffer with an initial content. */ | |
17 external StringBuffer([Object content = ""]); | |
18 | |
19 /** | |
20 * Returns the length of the content that has been accumulated so far. | |
21 * This is a constant-time operation. | |
22 */ | |
23 external int get length; | |
24 | |
25 /** Returns whether the buffer is empty. This is a constant-time operation. */ | |
26 bool get isEmpty => length == 0; | |
27 | |
28 /** | |
29 * Returns whether the buffer is not empty. This is a constant-time | |
30 * operation. | |
31 */ | |
32 bool get isNotEmpty => !isEmpty; | |
33 | |
34 /// Adds the contents of [obj], converted to a string, to the buffer. | |
35 external void write(Object obj); | |
36 | |
37 /// Adds the string representation of [charCode] to the buffer. | |
38 external void writeCharCode(int charCode); | |
39 | |
40 external void writeAll(Iterable objects, [String separator = ""]); | |
41 | |
42 external void writeln([Object obj = ""]); | |
43 | |
44 /** | |
45 * Clears the string buffer. | |
46 */ | |
47 external void clear(); | |
48 | |
49 /// Returns the contents of buffer as a concatenated string. | |
50 external String toString(); | |
51 } | |
OLD | NEW |