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

Side by Side Diff: client/util/StringUtils.dart

Issue 9382027: Move client/{base, observable, layout, touch, util, view} to samples/ui_lib . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/util/DateUtils.dart ('k') | client/util/Uri.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 /**
6 * General purpose string manipulation utilities.
7 */
8 class StringUtils {
9 /**
10 * Returns either [str], or if [str] is null, the value of [defaultStr].
11 */
12 static String defaultString(String str, [String defaultStr='']) {
13 return str === null ? defaultStr : str;
14 }
15
16 /** Parse string to a double, and handle null intelligently */
17 static double parseDouble(String str, [double ifNull = null]) {
18 return (str == null) ? ifNull : Math.parseDouble(str);
19 }
20
21 /** Parse string to a int, and handle null intelligently */
22 static int parseInt(String str, [int ifNull = null]) {
23 return (str == null) ? ifNull : Math.parseInt(str);
24 }
25
26 /** Parse bool to a double, and handle null intelligently */
27 // TODO(jacobr): corelib should have a boolean parsing method
28 static bool parseBool(String str, [bool ifNull = null]) {
29 assert(str == null || str == 'true' || str == 'false');
30 return (str == null) ? ifNull : (str == 'true');
31 }
32 }
OLDNEW
« no previous file with comments | « client/util/DateUtils.dart ('k') | client/util/Uri.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698