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

Side by Side Diff: samples-dev/swarm/swarm_ui_lib/util/StringUtils.dart

Issue 2828603002: Format samples and samples-dev directories. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of utilslib; 5 part of utilslib;
6 6
7 /** 7 /**
8 * General purpose string manipulation utilities. 8 * General purpose string manipulation utilities.
9 */ 9 */
10 class StringUtils { 10 class StringUtils {
11 /** 11 /**
12 * Returns either [str], or if [str] is null, the value of [defaultStr]. 12 * Returns either [str], or if [str] is null, the value of [defaultStr].
13 */ 13 */
14 static String defaultString(String str, [String defaultStr='']) { 14 static String defaultString(String str, [String defaultStr = '']) {
15 return str == null ? defaultStr : str; 15 return str == null ? defaultStr : str;
16 } 16 }
17 17
18 /** Parse string to a double, and handle null intelligently */ 18 /** Parse string to a double, and handle null intelligently */
19 static double parseDouble(String str, [double ifNull = null]) { 19 static double parseDouble(String str, [double ifNull = null]) {
20 return (str == null) ? ifNull : double.parse(str); 20 return (str == null) ? ifNull : double.parse(str);
21 } 21 }
22 22
23 /** Parse string to a int, and handle null intelligently */ 23 /** Parse string to a int, and handle null intelligently */
24 static int parseInt(String str, [int ifNull = null]) { 24 static int parseInt(String str, [int ifNull = null]) {
25 return (str == null) ? ifNull : int.parse(str); 25 return (str == null) ? ifNull : int.parse(str);
26 } 26 }
27 27
28 /** Parse bool to a double, and handle null intelligently */ 28 /** Parse bool to a double, and handle null intelligently */
29 // TODO(jacobr): corelib should have a boolean parsing method 29 // TODO(jacobr): corelib should have a boolean parsing method
30 static bool parseBool(String str, [bool ifNull = null]) { 30 static bool parseBool(String str, [bool ifNull = null]) {
31 assert(str == null || str == 'true' || str == 'false'); 31 assert(str == null || str == 'true' || str == 'false');
32 return (str == null) ? ifNull : (str == 'true'); 32 return (str == null) ? ifNull : (str == 'true');
33 } 33 }
34 } 34 }
OLDNEW
« no previous file with comments | « samples-dev/swarm/swarm_ui_lib/util/DateUtils.dart ('k') | samples-dev/swarm/swarm_ui_lib/util/Uri.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698