Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: sdk/lib/core/string_buffer.dart

Issue 12218086: Add StringSink and update StringBuffer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add writeAll to CodeBuffer. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/core/string_buffer.dart
diff --git a/sdk/lib/core/string_buffer.dart b/sdk/lib/core/string_buffer.dart
index d8b393583952238a7e66027ba20d0b45b86179e4..cbfcd6eee2959466b2931248935a9180ea5cc2d5 100644
--- a/sdk/lib/core/string_buffer.dart
+++ b/sdk/lib/core/string_buffer.dart
@@ -9,29 +9,69 @@ part of dart.core;
* efficiently. Only on a call to [toString] are the strings
* concatenated to a single String.
*/
-abstract class StringBuffer {
+class StringBuffer implements StringSink {
/// Creates the string buffer with an initial content.
- external factory StringBuffer([Object content = ""]);
+ external StringBuffer([Object content = ""]);
/// Returns the length of the buffer.
sra1 2013/02/18 21:06:57 Does it return the length of the buffer (could hav
floitsch 2013/02/19 14:21:17 Done.
- int get length;
+ external int get length;
- // Returns whether the buffer is empty.
- bool get isEmpty;
+ /// Returns whether the buffer is empty.
+ bool get isEmpty => length == 0;
- /// Converts [obj] to a string and adds it to the buffer.
- void add(Object obj);
+ /**
+ * Converts [obj] to a string and adds it to the buffer.
+ *
+ * *Deprecated*. Use [write] instead.
+ */
+ @deprecated
+ void add(Object obj) => write(obj);
+
+ external void write(Object obj);
ahe 2013/02/19 12:11:44 You forgot to document all the new methods you add
floitsch 2013/02/19 14:21:17 Documentation for them is inherited.
+
+ void writeAll(Iterable objects) {
+ for (Object obj in objects) write(obj);
+ }
+
+ void writeln(Object obj) {
+ write(obj);
+ write("\n");
+ }
+
+ /**
+ * Adds the string representation of [charCode] to the buffer.
+ *
+ * *Deprecated* Use [writeCharCode] instead.
+ */
+ @deprecated
+ void addCharCode(int charCode) {
+ writeCharCode(charCode);
+ }
/// Adds the string representation of [charCode] to the buffer.
- void addCharCode(int charCode);
+ void writeCharCode(int charCode) {
+ write(new String.fromCharCode(charCode));
+ }
- /// Adds all items in [objects] to the buffer.
- void addAll(Iterable objects);
+ /**
+ * Adds all items in [objects] to the buffer.
+ *
+ * *Deprecated*. Use [writeAll] instead.
+ */
+ @deprecated
+ void addAll(Iterable objects) {
+ for (Object obj in objects) write(obj);
+ }
- /// Clears the string buffer.
- void clear();
+ /**
+ * Clears the string buffer.
+ *
+ * *Deprecated*.
+ */
+ @deprecated
+ external void clear();
/// Returns the contents of buffer as a concatenated string.
- String toString();
+ external String toString();
}

Powered by Google App Engine
This is Rietveld 408576698