Here you can find the source of replacePolUtilsName( final List
public static void replacePolUtilsName( final List<String> npcListSqlLines, final int lineIndex, final String name)
//package com.java2s; /** /*w w w . j a v a 2 s.co m*/ * Copyright (c) 2010-2014 Darkstar Dev Teams * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/ * * This file is part of DarkStar-server source code. */ import java.util.List; public class Main { public static void replacePolUtilsName( final List<String> npcListSqlLines, final int lineIndex, final String name) { final String npcIdLine = npcListSqlLines.get(lineIndex); int startIndex = npcIdLine.indexOf(","); startIndex = npcIdLine.indexOf(",", startIndex + 1); int nextQuote = npcIdLine.indexOf("'", startIndex + 2); int endIndex = npcIdLine.indexOf(",", startIndex + 1); if (endIndex < nextQuote) { endIndex = npcIdLine.indexOf(",", endIndex + 1); } final String newLine; if (name == null) { newLine = npcIdLine.substring(0, startIndex + 1) + "\'\'" + npcIdLine.substring(endIndex, npcIdLine.length()); } else { newLine = npcIdLine.substring(0, startIndex + 1) + '\'' + name.replaceAll("'", "\\\\'") + '\'' + npcIdLine.substring(endIndex, npcIdLine.length()); } npcListSqlLines.set(lineIndex, newLine); } }