| OLD | NEW |
| (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 package com.google.dart.compiler.util; |
| 5 |
| 6 /** |
| 7 * Utilities for {@link String}. |
| 8 */ |
| 9 public class StringUtils { |
| 10 /** |
| 11 * The empty String <code>""</code>. |
| 12 */ |
| 13 public static final String EMPTY = ""; |
| 14 |
| 15 /** |
| 16 * @return the the substring before the first occurrence of a separator. |
| 17 */ |
| 18 public static String substringBefore(String str, String separator) { |
| 19 int index = str.indexOf(separator); |
| 20 if (index == -1) { |
| 21 return str; |
| 22 } |
| 23 return str.substring(0, index); |
| 24 } |
| 25 |
| 26 /** |
| 27 * @return the substring after the first occurrence of a separator. |
| 28 */ |
| 29 public static String substringAfter(String str, String separator) { |
| 30 int index = str.indexOf(separator); |
| 31 if (index == -1) { |
| 32 return EMPTY; |
| 33 } |
| 34 return str.substring(index + separator.length()); |
| 35 } |
| 36 } |
| OLD | NEW |