X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=source%2Fmir%2Futil%2FStringRoutines.java;h=579e92117743b933097d1d5ab7e70e1d7d8dc376;hb=d7429fe1376f25d0c4420c35c69dc9edd651ab25;hp=4c58d6a0ef6effe8b860254934cff0f5fb4e65fd;hpb=033430feeb95ba42fbf7d7a56079fbad76de6036;p=mir.git diff --git a/source/mir/util/StringRoutines.java b/source/mir/util/StringRoutines.java index 4c58d6a0..579e9211 100755 --- a/source/mir/util/StringRoutines.java +++ b/source/mir/util/StringRoutines.java @@ -1,212 +1,213 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir 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 2 of the License, or - * (at your option) any later version. - * - * Mir 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 Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mir.util; - -import gnu.regexp.RE; -import gnu.regexp.REException; - -import java.util.List; -import java.util.Vector; - -public class StringRoutines { - - private StringRoutines() { - } - - static int indexOfCharacters(String aString, char[] aCharacters, int aFrom) { - int i; - int result=-1; - int position; - - for (i=0; iseperateString("a:b:c", ":"); will lead to - * a List with 3 Strings: "a", "b" and "c" - * - * @param aString The string to split - * @param aSeparator - * @return - */ - - public static List splitString(String aString, String aSeparator) { - List result= new Vector(); - int previousPosition = 0; - int position; - int endOfNamePosition; - - while ((position = aString.indexOf(aSeparator, previousPosition))>=0) { - result.add(aString.substring(previousPosition, position)); - previousPosition = position + aSeparator.length(); - } - - result.add(aString.substring(previousPosition, aString.length())); - - return result; - } - - /** - * Separates a String into at most 2 parts based on a separator: - * - * - * - * @param aString - * @param aSeparator - * @return - */ - public static List separateString(String aString, String aSeparator) { - List result= new Vector(); - int previousPosition = 0; - int position; - int endOfNamePosition; - - if((position = aString.indexOf(aSeparator, previousPosition))>=0) { - result.add(aString.substring(previousPosition, position)); - previousPosition = position + aSeparator.length(); - } - - result.add(aString.substring(previousPosition, aString.length())); - - return result; - } +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir 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 2 of the License, or + * (at your option) any later version. + * + * Mir 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 Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with the com.oreilly.servlet library, any library + * licensed under the Apache Software License, The Sun (tm) Java Advanced + * Imaging library (JAI), The Sun JIMI library (or with modified versions of + * the above that use the same license as the above), and distribute linked + * combinations including the two. You must obey the GNU General Public + * License in all respects for all of the code used other than the above + * mentioned libraries. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If you do + * not wish to do so, delete this exception statement from your version. + */ + +package mir.util; + +import gnu.regexp.RE; +import gnu.regexp.REException; + +import java.util.List; +import java.util.Vector; + +public class StringRoutines { + + private StringRoutines() { + } + + static int indexOfCharacters(String aString, char[] aCharacters, int aFrom) { + int i; + int result=-1; + int position; + + for (i=0; iseperateString("a:b:c", ":"); will lead to + * a List with 3 Strings: "a", "b" and "c" + * + * @param aString The string to split + * @param aSeparator + * @return + */ + + public static List splitString(String aString, String aSeparator) { + List result= new Vector(); + int previousPosition = 0; + int position; + int endOfNamePosition; + + if (aString!=null) { + while ( (position = aString.indexOf(aSeparator, previousPosition)) >= 0) { + result.add(aString.substring(previousPosition, position)); + previousPosition = position + aSeparator.length(); + } + result.add(aString.substring(previousPosition, aString.length())); + } + + return result; + } + + /** + * Separates a String into at most 2 parts based on a separator: + * + * + * + * @param aString + * @param aSeparator + * @return + */ + public static List separateString(String aString, String aSeparator) { + List result= new Vector(); + int previousPosition = 0; + int position; + int endOfNamePosition; + + if((position = aString.indexOf(aSeparator, previousPosition))>=0) { + result.add(aString.substring(previousPosition, position)); + previousPosition = position + aSeparator.length(); + } + + result.add(aString.substring(previousPosition, aString.length())); + + return result; + } } \ No newline at end of file