Procházet zdrojové kódy

Change non-regex uses of replaceAll to replace

Change-Id: I59d14c6df67668f0389c51b7ae475ce6cc9103f6
Reviewed-on: http://gerrit.dmdirc.com/705
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
Automatic-Compile: Gregory Holmes <greg@dmdirc.com>
tags/0.6.3
Chris Smith před 14 roky
rodič
revize
2f65a30cf6

+ 3
- 3
src/com/dmdirc/addons/freedesktop_notifications/FreeDesktopNotificationsPlugin.java Zobrazit soubor

@@ -129,9 +129,9 @@ public final class FreeDesktopNotificationsPlugin extends Plugin implements
129 129
 	    if (strictescape) {
130 130
                 output = StringEscapeUtils.escapeHtml(output);
131 131
             } else {
132
-                output = output.replaceAll("&", "&amp;");
133
-                output = output.replaceAll("<", "&lt;");
134
-                output = output.replaceAll(">", "&gt;");
132
+                output = output.replace("&", "&amp;");
133
+                output = output.replace("<", "&lt;");
134
+                output = output.replace(">", "&gt;");
135 135
             }
136 136
         }
137 137
         

+ 2
- 2
src/com/dmdirc/addons/identd/IdentClient.java Zobrazit soubor

@@ -186,7 +186,7 @@ public final class IdentClient implements Runnable {
186 186
      * @return Escaped string.
187 187
      */
188 188
     public static String escapeString(final String str) {
189
-        return str.replaceAll("\\\\", "\\\\\\\\").replaceAll(":", "\\\\:").replaceAll(",", "\\\\,").replaceAll(" ", "\\\\ ");
189
+        return str.replace("\\", "\\\\").replace(":", "\\:").replace(",", "\\,").replace(" ", "\\ ");
190 190
     }
191 191
 
192 192
     /**
@@ -196,7 +196,7 @@ public final class IdentClient implements Runnable {
196 196
      * @return Escaped string.
197 197
      */
198 198
     public static String unescapeString(final String str) {
199
-        return str.replaceAll("\\\\:", ":").replaceAll("\\\\ ", " ").replaceAll("\\\\,", ",").replaceAll("\\\\\\\\", "\\\\");
199
+        return str.replace("\\:", ":").replace("\\ ", " ").replace("\\,", ",").replace("\\\\", "\\");
200 200
     }
201 201
 
202 202
     /**

+ 11
- 12
src/com/dmdirc/addons/nowplaying/NowPlayingPlugin.java Zobrazit soubor

@@ -254,30 +254,29 @@ public class NowPlayingPlugin extends Plugin implements ActionListener  {
254 254
         final String time = source.getTime();
255 255
         final String state = source.getState().getNiceName();
256 256
         
257
-        return format.replaceAll("\\$artist", sanitise(artist))
258
-                     .replaceAll("\\$title", sanitise(title))
259
-                     .replaceAll("\\$album", sanitise(album))
260
-                     .replaceAll("\\$app", sanitise(app))
261
-                     .replaceAll("\\$bitrate", sanitise(bitrate))
262
-                     .replaceAll("\\$format", sanitise(filetype))
263
-                     .replaceAll("\\$length", sanitise(length))
264
-                     .replaceAll("\\$state", sanitise(state))
265
-                     .replaceAll("\\$time", sanitise(time));
257
+        return format.replace("$artist", sanitise(artist))
258
+                     .replace("$title", sanitise(title))
259
+                     .replace("$album", sanitise(album))
260
+                     .replace("$app", sanitise(app))
261
+                     .replace("$bitrate", sanitise(bitrate))
262
+                     .replace("$format", sanitise(filetype))
263
+                     .replace("$length", sanitise(length))
264
+                     .replace("$state", sanitise(state))
265
+                     .replace("$time", sanitise(time));
266 266
     }
267 267
 
268 268
     /**
269 269
      * Sanitises the specified String so that it may be used as the replacement
270 270
      * in a call to String.replaceAll. Namely, at present, this method returns
271 271
      * an empty String if it is passed a null value; otherwise the input is
272
-     * quoted for use as a replacement in the
273
-     * {@link String#replaceAll(java.lang.String, java.lang.String)} method.
272
+     * returned as-is.
274 273
      *
275 274
      * @param input The string to be sanitised
276 275
      * @return A sanitised version of the String
277 276
      * @since 0.6.3
278 277
      */
279 278
     protected static String sanitise(final String input) {
280
-        return input == null ? "" : Matcher.quoteReplacement(input);
279
+        return input == null ? "" : input;
281 280
     }
282 281
     
283 282
     /**

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/NewlinesDocumentFilter.java Zobrazit soubor

@@ -60,7 +60,7 @@ public class NewlinesDocumentFilter extends DocumentFilter {
60 60
      */
61 61
     private String sanitise(final String text) {
62 62
         if (text.contains("\n")) {
63
-            return text.replaceAll("\\n", "");
63
+            return text.replace("\n", "");
64 64
         }
65 65
         return text;
66 66
     }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/about/LicenceLoader.java Zobrazit soubor

@@ -85,7 +85,7 @@ public class LicenceLoader extends LoggingSwingWorker<Void, Void> {
85 85
                     final Licence licence = new Licence(licenceStringParts[1],
86 86
                             licenceStringParts[0], "<html><h1>" +
87 87
                             licenceStringParts[1] + "</h1><p>" + readInputStream(
88
-                            entry.getValue()).replaceAll("\n", "<br>") +
88
+                            entry.getValue()).replace("\n", "<br>") +
89 89
                             "</p></html>");
90 90
                     model.add(licence);
91 91
                 }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionDisplayPanel.java Zobrazit soubor

@@ -233,7 +233,7 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
233 233
             }
234 234
             sb.append(" '");
235 235
             if (condition.getTarget() != null) {
236
-                sb.append(condition.getTarget().replaceAll("<", "&lt;"));
236
+                sb.append(condition.getTarget().replace("<", "&lt;"));
237 237
             } else {
238 238
                 sb.append(" ...");
239 239
                 return sb.toString();

+ 2
- 2
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionResponsePanel.java Zobrazit soubor

@@ -109,7 +109,7 @@ public class ActionResponsePanel extends JPanel {
109 109
     public void setResponse(final String[] response) {
110 110
         final StringBuilder sb = new StringBuilder();
111 111
         for (String responseLine : response) {
112
-            responseLine = responseLine.replaceAll("\n", "\\\\n");
112
+            responseLine = responseLine.replace("\n", "\\n");
113 113
             sb.append(responseLine).append('\n');
114 114
         }
115 115
 
@@ -143,7 +143,7 @@ public class ActionResponsePanel extends JPanel {
143 143
     public String[] getResponse() {
144 144
         final String[] text = response.getText().split("\n");
145 145
         for (int i = 0; i < text.length; i++) {
146
-            text[i] = text[i].replaceAll("\\\\n", "\n");
146
+            text[i] = text[i].replace("\\n", "\n");
147 147
         }
148 148
         return text;
149 149
     }

Načítá se…
Zrušit
Uložit