add in query_.. parameters to the delete request url so that we come back to the...
[mir.git] / source / mir / util / HTMLRoutines.java
index 076f4ce..53bced3 100755 (executable)
@@ -40,34 +40,16 @@ public class HTMLRoutines {
   }
 
   public static String encodeHTML(String aText) {
-    final char[] CHARACTERS_TO_ESCAPE = { '&', '<', '>', '"', '\'' };
-    final String[] ESCAPE_CODES = { "&amp;", "&lt;", "&gt;", "&quot;", "&apos;" };
-
-    int position, nextPosition;
-    int i;
-    StringBuffer result = new StringBuffer();
-
-    position=0;
-
-    do {
-      nextPosition = StringRoutines.indexOfCharacters(aText, CHARACTERS_TO_ESCAPE, position);
+    final char[] CHARACTERS_TO_ESCAPE = { '&', '<', '>', '"' };
+    final String[] ESCAPE_CODES = { "&amp;", "&lt;", "&gt;", "&quot;" };
 
-      if (nextPosition<0)
-        nextPosition = aText.length();
-
-      result.append(aText.substring(position, nextPosition));
+    return StringRoutines.replaceStringCharacters(aText, CHARACTERS_TO_ESCAPE, ESCAPE_CODES);
+  }
 
-      if (nextPosition<aText.length())
-        for (i=0; i<CHARACTERS_TO_ESCAPE.length; i++) {
-          if (CHARACTERS_TO_ESCAPE[i] == aText.charAt(nextPosition)) {
-            result.append(ESCAPE_CODES[i]);
-            break;
-          }
-        }
-      position=nextPosition+1;
-    }
-    while (nextPosition<aText.length()) ;
+  public static String encodeXML(String aText) {
+    final char[] CHARACTERS_TO_ESCAPE = { '&', '<', '>', '"', '\'' };
+    final String[] ESCAPE_CODES = { "&amp;", "&lt;", "&gt;", "&quot;", "&apos;" };
 
-    return result.toString();
+    return StringRoutines.replaceStringCharacters(aText, CHARACTERS_TO_ESCAPE, ESCAPE_CODES);
   }
 }
\ No newline at end of file