diff -r 000000000000 -r a02c979e8dfd srcanaapps/depexplorer/com.nokia.s60tools.appdep/src/com/nokia/s60tools/appdep/export/StringUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanaapps/depexplorer/com.nokia.s60tools.appdep/src/com/nokia/s60tools/appdep/export/StringUtils.java Sat Jan 09 10:04:11 2010 +0530 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.s60tools.appdep.export; + + +/** + * String utilities used for character replacements + * e.g. when creating XML reports. + */ +public class StringUtils { + + /** + * Replaces those characters that are no allowed inside XML elements + * with corresponding XML entities. + * @param in string to replace forbidden characters from + * @return string with forbidden characters replaced with corresponding entities. + */ + public static String replaceForbiddenCharacters(String in){ + String out = in.replace("&","&"); //$NON-NLS-1$ //$NON-NLS-2$ + out = out.replace("<","<"); //$NON-NLS-1$ //$NON-NLS-2$ + out = out.replace(">",">"); //$NON-NLS-1$ //$NON-NLS-2$ + out = out.replace("\"","""); //$NON-NLS-1$ //$NON-NLS-2$ + out = out.replace("'","'"); //$NON-NLS-1$ //$NON-NLS-2$ + + return out; + + } + + /** + * Replaces given sub string with given replacement if found from the input string. + * @param in input string used for replacement + * @param replaceMe sub string to be replaced + * @param replaceWith sub string used as replacement + * @return string with all occurrences replace if found. + */ + public static String replace(String in, String replaceMe, String replaceWith){ + String out = in.replace(replaceMe,replaceWith); + return out; + } + +}