| OLD | NEW |
| 1 library java.engine; | 1 library java.engine; |
| 2 | 2 |
| 3 import 'interner.dart'; | 3 import 'interner.dart'; |
| 4 import 'java_core.dart'; | 4 import 'java_core.dart'; |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * A predicate is a one-argument function that returns a boolean value. | 7 * A predicate is a one-argument function that returns a boolean value. |
| 8 */ | 8 */ |
| 9 typedef bool Predicate<E>(E argument); | 9 typedef bool Predicate<E>(E argument); |
| 10 | 10 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 return ""; | 108 return ""; |
| 109 } | 109 } |
| 110 int index = fileName.lastIndexOf('.'); | 110 int index = fileName.lastIndexOf('.'); |
| 111 if (index >= 0) { | 111 if (index >= 0) { |
| 112 return fileName.substring(index + 1); | 112 return fileName.substring(index + 1); |
| 113 } | 113 } |
| 114 return ""; | 114 return ""; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 | |
| 119 class StringUtilities { | 118 class StringUtilities { |
| 120 static const String EMPTY = ''; | 119 static const String EMPTY = ''; |
| 121 static const List<String> EMPTY_ARRAY = const <String>[]; | 120 static const List<String> EMPTY_ARRAY = const <String>[]; |
| 122 | 121 |
| 123 static Interner INTERNER = new NullInterner(); | 122 static Interner INTERNER = new NullInterner(); |
| 124 | 123 |
| 125 static endsWith3(String str, int c1, int c2, int c3) { | 124 static endsWith3(String str, int c1, int c2, int c3) { |
| 126 var length = str.length; | 125 var length = str.length; |
| 127 return length >= 3 && | 126 return length >= 3 && |
| 128 str.codeUnitAt(length - 3) == c1 && | 127 str.codeUnitAt(length - 3) == c1 && |
| (...skipping 19 matching lines...) Expand all Loading... |
| 148 int index = start; | 147 int index = start; |
| 149 int last = str.length - 1; | 148 int last = str.length - 1; |
| 150 while (index < last) { | 149 while (index < last) { |
| 151 if (str.codeUnitAt(index) == c1 && str.codeUnitAt(index + 1) == c2) { | 150 if (str.codeUnitAt(index) == c1 && str.codeUnitAt(index + 1) == c2) { |
| 152 return index; | 151 return index; |
| 153 } | 152 } |
| 154 index++; | 153 index++; |
| 155 } | 154 } |
| 156 return -1; | 155 return -1; |
| 157 } | 156 } |
| 158 static int indexOf4(String string, int start, int c1, int c2, int c3, | 157 static int indexOf4( |
| 159 int c4) { | 158 String string, int start, int c1, int c2, int c3, int c4) { |
| 160 int index = start; | 159 int index = start; |
| 161 int last = string.length - 3; | 160 int last = string.length - 3; |
| 162 while (index < last) { | 161 while (index < last) { |
| 163 if (string.codeUnitAt(index) == c1 && | 162 if (string.codeUnitAt(index) == c1 && |
| 164 string.codeUnitAt(index + 1) == c2 && | 163 string.codeUnitAt(index + 1) == c2 && |
| 165 string.codeUnitAt(index + 2) == c3 && | 164 string.codeUnitAt(index + 2) == c3 && |
| 166 string.codeUnitAt(index + 3) == c4) { | 165 string.codeUnitAt(index + 3) == c4) { |
| 167 return index; | 166 return index; |
| 168 } | 167 } |
| 169 index++; | 168 index++; |
| 170 } | 169 } |
| 171 return -1; | 170 return -1; |
| 172 } | 171 } |
| 173 static int indexOf5(String str, int start, int c1, int c2, int c3, int c4, | 172 static int indexOf5( |
| 174 int c5) { | 173 String str, int start, int c1, int c2, int c3, int c4, int c5) { |
| 175 int index = start; | 174 int index = start; |
| 176 int last = str.length - 4; | 175 int last = str.length - 4; |
| 177 while (index < last) { | 176 while (index < last) { |
| 178 if (str.codeUnitAt(index) == c1 && | 177 if (str.codeUnitAt(index) == c1 && |
| 179 str.codeUnitAt(index + 1) == c2 && | 178 str.codeUnitAt(index + 1) == c2 && |
| 180 str.codeUnitAt(index + 2) == c3 && | 179 str.codeUnitAt(index + 2) == c3 && |
| 181 str.codeUnitAt(index + 3) == c4 && | 180 str.codeUnitAt(index + 3) == c4 && |
| 182 str.codeUnitAt(index + 4) == c5) { | 181 str.codeUnitAt(index + 4) == c5) { |
| 183 return index; | 182 return index; |
| 184 } | 183 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 str.codeUnitAt(start + 1) == c2 && | 266 str.codeUnitAt(start + 1) == c2 && |
| 268 str.codeUnitAt(start + 2) == c3; | 267 str.codeUnitAt(start + 2) == c3; |
| 269 } | 268 } |
| 270 static startsWith4(String str, int start, int c1, int c2, int c3, int c4) { | 269 static startsWith4(String str, int start, int c1, int c2, int c3, int c4) { |
| 271 return str.length - start >= 4 && | 270 return str.length - start >= 4 && |
| 272 str.codeUnitAt(start) == c1 && | 271 str.codeUnitAt(start) == c1 && |
| 273 str.codeUnitAt(start + 1) == c2 && | 272 str.codeUnitAt(start + 1) == c2 && |
| 274 str.codeUnitAt(start + 2) == c3 && | 273 str.codeUnitAt(start + 2) == c3 && |
| 275 str.codeUnitAt(start + 3) == c4; | 274 str.codeUnitAt(start + 3) == c4; |
| 276 } | 275 } |
| 277 static startsWith5(String str, int start, int c1, int c2, int c3, int c4, | 276 static startsWith5( |
| 278 int c5) { | 277 String str, int start, int c1, int c2, int c3, int c4, int c5) { |
| 279 return str.length - start >= 5 && | 278 return str.length - start >= 5 && |
| 280 str.codeUnitAt(start) == c1 && | 279 str.codeUnitAt(start) == c1 && |
| 281 str.codeUnitAt(start + 1) == c2 && | 280 str.codeUnitAt(start + 1) == c2 && |
| 282 str.codeUnitAt(start + 2) == c3 && | 281 str.codeUnitAt(start + 2) == c3 && |
| 283 str.codeUnitAt(start + 3) == c4 && | 282 str.codeUnitAt(start + 3) == c4 && |
| 284 str.codeUnitAt(start + 4) == c5; | 283 str.codeUnitAt(start + 4) == c5; |
| 285 } | 284 } |
| 286 static startsWith6(String str, int start, int c1, int c2, int c3, int c4, | 285 static startsWith6( |
| 287 int c5, int c6) { | 286 String str, int start, int c1, int c2, int c3, int c4, int c5, int c6) { |
| 288 return str.length - start >= 6 && | 287 return str.length - start >= 6 && |
| 289 str.codeUnitAt(start) == c1 && | 288 str.codeUnitAt(start) == c1 && |
| 290 str.codeUnitAt(start + 1) == c2 && | 289 str.codeUnitAt(start + 1) == c2 && |
| 291 str.codeUnitAt(start + 2) == c3 && | 290 str.codeUnitAt(start + 2) == c3 && |
| 292 str.codeUnitAt(start + 3) == c4 && | 291 str.codeUnitAt(start + 3) == c4 && |
| 293 str.codeUnitAt(start + 4) == c5 && | 292 str.codeUnitAt(start + 4) == c5 && |
| 294 str.codeUnitAt(start + 5) == c6; | 293 str.codeUnitAt(start + 5) == c6; |
| 295 } | 294 } |
| 296 static startsWithChar(String str, int c) { | 295 static startsWithChar(String str, int c) { |
| 297 return str.length != 0 && str.codeUnitAt(0) == c; | 296 return str.length != 0 && str.codeUnitAt(0) == c; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 316 return str; | 315 return str; |
| 317 } | 316 } |
| 318 int pos = indexOf1(str, 0, c); | 317 int pos = indexOf1(str, 0, c); |
| 319 if (pos < 0) { | 318 if (pos < 0) { |
| 320 return str; | 319 return str; |
| 321 } | 320 } |
| 322 return str.substring(0, pos); | 321 return str.substring(0, pos); |
| 323 } | 322 } |
| 324 } | 323 } |
| 325 | 324 |
| 326 | |
| 327 class UUID { | 325 class UUID { |
| 328 static int __nextId = 0; | 326 static int __nextId = 0; |
| 329 final String id; | 327 final String id; |
| 330 UUID(this.id); | 328 UUID(this.id); |
| 331 String toString() => id; | 329 String toString() => id; |
| 332 static UUID randomUUID() => new UUID((__nextId).toString()); | 330 static UUID randomUUID() => new UUID((__nextId).toString()); |
| 333 } | 331 } |
| OLD | NEW |