|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.s60tools.appdep.export; |
|
20 |
|
21 |
|
22 /** |
|
23 * String utilities used for character replacements |
|
24 * e.g. when creating XML reports. |
|
25 */ |
|
26 public class StringUtils { |
|
27 |
|
28 /** |
|
29 * Replaces those characters that are no allowed inside XML elements |
|
30 * with corresponding XML entities. |
|
31 * @param in string to replace forbidden characters from |
|
32 * @return string with forbidden characters replaced with corresponding entities. |
|
33 */ |
|
34 public static String replaceForbiddenCharacters(String in){ |
|
35 String out = in.replace("&","&"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
36 out = out.replace("<","<"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
37 out = out.replace(">",">"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
38 out = out.replace("\"","""); //$NON-NLS-1$ //$NON-NLS-2$ |
|
39 out = out.replace("'","'"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
40 |
|
41 return out; |
|
42 |
|
43 } |
|
44 |
|
45 /** |
|
46 * Replaces given sub string with given replacement if found from the input string. |
|
47 * @param in input string used for replacement |
|
48 * @param replaceMe sub string to be replaced |
|
49 * @param replaceWith sub string used as replacement |
|
50 * @return string with all occurrences replace if found. |
|
51 */ |
|
52 public static String replace(String in, String replaceMe, String replaceWith){ |
|
53 String out = in.replace(replaceMe,replaceWith); |
|
54 return out; |
|
55 } |
|
56 |
|
57 } |