Here you can find the source of strReplaceOld(String strText, String strFrom, String strTo, boolean bMultiple)
Parameter | Description |
---|---|
strText | a parameter |
strFrom | a parameter |
strTo | a parameter |
bMultiple | a parameter |
public static String strReplaceOld(String strText, String strFrom, String strTo, boolean bMultiple)
//package com.java2s; /******************************************************************************* * Copyright 2009, 2010 Innovation Gate GmbH * //from ww w. ja v a 2 s. c o m * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ import java.util.ArrayList; import java.util.List; public class Main { /** * Old version of strReplace. No longer used. * * @deprecated * @param strText * @param strFrom * @param strTo * @param bMultiple * @return Converted string */ public static String strReplaceOld(String strText, String strFrom, String strTo, boolean bMultiple) { int iFromLength = strFrom.length(); int iToLength = strTo.length(); int iOccurs = 0; String strOutput = new String(strText); iOccurs = strOutput.toLowerCase().indexOf(strFrom.toLowerCase(), 0); int iStartWith = 0; while (iOccurs != -1) { strOutput = strOutput.substring(0, iOccurs) + strTo + strOutput.substring(iOccurs + iFromLength); iStartWith = (iOccurs - 1) + iToLength + 1; if (bMultiple) iOccurs = strOutput.toLowerCase().indexOf(strFrom.toLowerCase(), iStartWith); else iOccurs = -1; } return strOutput; } /** * Creates a new list that contains the same elements than the parameter * list, but with all string elements converted to lower case * * @param listOriginal * @return The list with all strings converted to lower case */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static List toLowerCase(List listOriginal) { List list = new ArrayList(); Object elem; for (int i = 0; i < listOriginal.size(); i++) { elem = listOriginal.get(i); if (elem instanceof String) { list.add(((String) elem).toLowerCase()); } else { list.add(elem); } } return list; } }