1.1 restoration
[mir.git] / source / mir / util / StringRoutines.java
index 0627dbc..a7a41b6 100755 (executable)
@@ -32,7 +32,7 @@ package mir.util;
 import gnu.regexp.RE;
 
 import java.util.List;
-import java.util.Vector;
+import java.util.ArrayList;
 
 public class StringRoutines {
 
@@ -86,12 +86,6 @@ public class StringRoutines {
     return result.toString();
   }
   /**
-   *
-   * @param aText
-   * @param anEscapeCharacater
-   * @param aCharactersToReplace
-   * @param aStringsToSubstitute
-   * @return
    */
 
   public static String replaceEscapedStringCharacters(String aText, char anEscapeCharacter, char[] aCharactersToReplace, String[] aStringsToSubstitute) {
@@ -139,7 +133,7 @@ public class StringRoutines {
       return (String) aValue;
 
     if (aValue instanceof Integer)
-      return ((Integer) aValue).toString();
+      return aValue.toString();
 
     if (aValue == null)
       return "";
@@ -162,16 +156,7 @@ public class StringRoutines {
     throw new Exception("Integer expected, "+aValue+" found");
   }
 
-  /**
-   *
-   * @param aSource
-   * @param aSearchExpression
-   * @param aReplacement
-   * @return
-   * @throws Exception
-   */
-  public static String performRegularExpressionReplacement(String aSource,
-      String aSearchExpression, String aReplacement) throws UtilExc {
+  public static String performRegularExpressionReplacement(String aSource, String aSearchExpression, String aReplacement) {
     try {
       RE regularExpression;
 
@@ -184,8 +169,7 @@ public class StringRoutines {
     }
   }
 
-  public static String performCaseInsensitiveRegularExpressionReplacement(String aSource,
-      String aSearchExpression, String aReplacement) throws UtilExc {
+  public static String performCaseInsensitiveRegularExpressionReplacement(String aSource, String aSearchExpression, String aReplacement) {
     try {
       RE regularExpression;
 
@@ -198,15 +182,7 @@ public class StringRoutines {
     }
   }
 
-  /**
-   *
-   * @param aSource
-   * @param aSearchExpression
-   * @return
-   * @throws REException
-   */
-  public static boolean performRegularExpressionSearch(String aSource,
-      String aSearchExpression) throws UtilExc {
+  public static boolean performRegularExpressionSearch(String aSource, String aSearchExpression) {
     try {
       RE regularExpression;
 
@@ -230,10 +206,9 @@ public class StringRoutines {
    */
 
   public static List splitString(String aString, String aSeparator) {
-    List result= new Vector();
+    List result= new ArrayList();
     int previousPosition = 0;
     int position;
-    int endOfNamePosition;
 
     if (aString!=null) {
       while ( (position = aString.indexOf(aSeparator, previousPosition)) >= 0) {
@@ -263,7 +238,7 @@ public class StringRoutines {
    * @return
    */
   public static List separateString(String aString, String aSeparator) {
-    List result= new Vector();
+    List result= new ArrayList();
     int previousPosition = 0;
     int position;
 
@@ -288,13 +263,13 @@ public class StringRoutines {
    */
 
   public static List splitStringWithEscape(String aString, char aSeparator, char anEscape) {
-    List result= new Vector();
+    List result= new ArrayList();
     int previousPosition = 0;
     int position;
-    int endOfNamePosition;
+
     StringBuffer currentItem = new StringBuffer();
 
-    if (aString!=null) {
+    if (aString!=null && aString.length()>0) {
       while ((position = indexOfCharacters(aString, new char[] {aSeparator, anEscape}, previousPosition))>=0) {
         currentItem.append(aString.substring(previousPosition, position));
 
@@ -303,11 +278,13 @@ public class StringRoutines {
           currentItem.delete(0, currentItem.length());
         }
         else {
-          currentItem.append(aString.charAt(position));
           if (aString.length()>position+1) {
             position=position+1;
             currentItem.append(aString.charAt(position));
           }
+          else {
+            currentItem.append(aString.charAt(position));
+          }
         }
         previousPosition = position + 1;
       }