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

Side by Side Diff: pkg/analyzer-experimental/lib/src/generated/java_core.dart

Issue 12543003: Use limited JavaStringBuilder implementation instead of Dart StringBuffer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweak JavaStringBuilder. Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 library java.core; 1 library java.core;
2 2
3 import "dart:math" as math; 3 import "dart:math" as math;
4 import "dart:uri"; 4 import "dart:uri";
5 5
6 class JavaSystem { 6 class JavaSystem {
7 static int currentTimeMillis() { 7 static int currentTimeMillis() {
8 return (new DateTime.now()).millisecondsSinceEpoch; 8 return (new DateTime.now()).millisecondsSinceEpoch;
9 } 9 }
10 10
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 JavaException.withCause(this.e) : message = null; 210 JavaException.withCause(this.e) : message = null;
211 String toString() => "JavaException: $message $e"; 211 String toString() => "JavaException: $message $e";
212 } 212 }
213 213
214 class IllegalArgumentException implements Exception { 214 class IllegalArgumentException implements Exception {
215 final String message; 215 final String message;
216 const IllegalArgumentException([this.message = "", Exception e = null]); 216 const IllegalArgumentException([this.message = "", Exception e = null]);
217 String toString() => "IllegalStateException: $message"; 217 String toString() => "IllegalStateException: $message";
218 } 218 }
219 219
220 class StringIndexOutOfBoundsException implements Exception {
221 final int index;
222 const StringIndexOutOfBoundsException(this.index);
223 String toString() => "StringIndexOutOfBoundsException: $index";
224 }
225
220 class IllegalStateException implements Exception { 226 class IllegalStateException implements Exception {
221 final String message; 227 final String message;
222 const IllegalStateException([this.message = ""]); 228 const IllegalStateException([this.message = ""]);
223 String toString() => "IllegalStateException: $message"; 229 String toString() => "IllegalStateException: $message";
224 } 230 }
225 231
226 class UnsupportedOperationException implements Exception { 232 class UnsupportedOperationException implements Exception {
227 String toString() => "UnsupportedOperationException"; 233 String toString() => "UnsupportedOperationException";
228 } 234 }
229 235
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 389
384 void javaMapPutAll(Map target, Map source) { 390 void javaMapPutAll(Map target, Map source) {
385 source.forEach((k, v) { 391 source.forEach((k, v) {
386 target[k] = v; 392 target[k] = v;
387 }); 393 });
388 } 394 }
389 395
390 bool javaStringEqualsIgnoreCase(String a, String b) { 396 bool javaStringEqualsIgnoreCase(String a, String b) {
391 return a.toLowerCase() == b.toLowerCase(); 397 return a.toLowerCase() == b.toLowerCase();
392 } 398 }
399
400 class JavaStringBuilder {
401 StringBuffer sb = new StringBuffer();
402 String toString() => sb.toString();
403 void append(x) {
404 sb.write(x);
405 }
406 void appendChar(int c) {
407 sb.writeCharCode(c);
408 }
409 int get length => sb.length;
410 void set length(int newLength) {
411 if (newLength < 0) {
412 throw new StringIndexOutOfBoundsException(newLength);
413 }
414 if (sb.length < newLength) {
415 while (sb.length < newLength) {
416 sb.writeCharCode(0);
417 }
418 } else if (sb.length > newLength) {
419 var s = sb.toString().substring(0, newLength);
420 sb = new StringBuffer(s);
421 }
422 }
423 void clear() {
424 sb = new StringBuffer();
425 }
426 }
OLDNEW
« no previous file with comments | « pkg/analyzer-experimental/lib/src/generated/html_scanner.dart ('k') | pkg/analyzer-experimental/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698