Bläddra i källkod

Deprecate and stop using StringTranscoder

Fixes CLIENT-68

Change-Id: I3d5b8625f202c7914c76a62100145597ef9fe523
Reviewed-on: http://gerrit.dmdirc.com/1779
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.5rc1
Chris Smith 13 år sedan
förälder
incheckning
7040726e21

+ 3
- 3
src/com/dmdirc/Channel.java Visa fil

@@ -154,7 +154,7 @@ public class Channel extends MessageTarget<ChannelWindow> implements ConfigChang
154 154
         final ClientInfo me = server.getParser().getLocalClient();
155 155
         final String[] details = getDetails(channelInfo.getChannelClient(me));
156 156
 
157
-        for (String part : splitLine(getTranscoder().encode(line))) {
157
+        for (String part : splitLine(line)) {
158 158
             if (!part.isEmpty()) {
159 159
                 final StringBuffer buff = new StringBuffer("channelSelfMessage");
160 160
 
@@ -199,9 +199,9 @@ public class Channel extends MessageTarget<ChannelWindow> implements ConfigChang
199 199
                     this, channelInfo.getChannelClient(me), action);
200 200
 
201 201
             addLine(buff, details[0], details[1], details[2], details[3],
202
-                    getTranscoder().encode(action), channelInfo);
202
+                    action, channelInfo);
203 203
 
204
-            channelInfo.sendAction(getTranscoder().encode(action));
204
+            channelInfo.sendAction(action);
205 205
         }
206 206
     }
207 207
 

+ 3
- 11
src/com/dmdirc/FrameContainer.java Visa fil

@@ -39,7 +39,6 @@ import com.dmdirc.util.ListenerList;
39 39
 import com.dmdirc.util.StringTranscoder;
40 40
 
41 41
 import java.awt.Color;
42
-import java.nio.charset.Charset;
43 42
 import java.util.Collection;
44 43
 import java.util.Collections;
45 44
 import java.util.Date;
@@ -122,16 +121,7 @@ public abstract class FrameContainer<T extends Window> {
122 121
         this.title = title;
123 122
         this.windowClass = windowClass;
124 123
 
125
-        // Can't assign directly to transcoder as it's final, and Java doesn't
126
-        // like the two paths in the try/catch.
127
-        StringTranscoder tempTranscoder;
128
-        try {
129
-            tempTranscoder = new StringTranscoder(Charset.forName(
130
-                    config.getOption("channel", "encoding")));
131
-        } catch (IllegalArgumentException ex) {
132
-            tempTranscoder = new StringTranscoder(Charset.forName("UTF-8"));
133
-        }
134
-        transcoder = tempTranscoder;
124
+        transcoder = new StringTranscoder(null);
135 125
 
136 126
         setIcon(icon);
137 127
     }
@@ -244,9 +234,11 @@ public abstract class FrameContainer<T extends Window> {
244 234
      * Retrieves the {@link StringTranscoder} used to transcode this frame's
245 235
      * text.
246 236
      *
237
+     * @deprecated Encoding is now handled by parsers, do not use.
247 238
      * @return This frame's transcoder
248 239
      * @since 0.6.4
249 240
      */
241
+    @Deprecated
250 242
     public StringTranscoder getTranscoder() {
251 243
         return transcoder;
252 244
     }

+ 2
- 3
src/com/dmdirc/Query.java Visa fil

@@ -129,7 +129,7 @@ public class Query extends MessageTarget<QueryWindow> implements PrivateActionLi
129 129
             return;
130 130
         }
131 131
 
132
-        for (String part : splitLine(getTranscoder().encode(line))) {
132
+        for (String part : splitLine(line)) {
133 133
             if (!part.isEmpty()) {
134 134
                 server.getParser().sendMessage(target, part);
135 135
 
@@ -177,8 +177,7 @@ public class Query extends MessageTarget<QueryWindow> implements PrivateActionLi
177 177
         final int maxLineLength = server.getParser().getMaxLength("PRIVMSG", host);
178 178
 
179 179
         if (maxLineLength >= action.length() + 2) {
180
-            server.getParser().sendAction(getNickname(),
181
-                    getTranscoder().encode(action));
180
+            server.getParser().sendAction(getNickname(), action);
182 181
 
183 182
             doNotification("querySelfAction", CoreActionType.QUERY_SELF_ACTION,
184 183
                     client, action);

+ 1
- 1
src/com/dmdirc/Raw.java Visa fil

@@ -119,7 +119,7 @@ public final class Raw extends WritableFrameContainer<InputWindow>
119 119
     @Override
120 120
     public void sendLine(final String line) {
121 121
         if (!line.isEmpty()) {
122
-            sendLine(getTranscoder().encode(line));
122
+            sendLine(line);
123 123
         }
124 124
     }
125 125
 

+ 1
- 1
src/com/dmdirc/Server.java Visa fil

@@ -935,7 +935,7 @@ public class Server extends WritableFrameContainer<ServerWindow> implements Conf
935 935
                 parserLock.readLock().lock();
936 936
                 if (parser != null && !line.isEmpty()
937 937
                         && myState.getState() == ServerState.CONNECTED) {
938
-                    parser.sendRawMessage(getTranscoder().encode(line));
938
+                    parser.sendRawMessage(line);
939 939
                 }
940 940
             } finally {
941 941
                 parserLock.readLock().unlock();

+ 0
- 2
src/com/dmdirc/config/prefs/PreferencesManager.java Visa fil

@@ -203,8 +203,6 @@ public final class PreferencesManager {
203 203
         category.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
204 204
                 "ui", "inputbuffersize", "Input buffer size",
205 205
                 "Number of items of input history to keep"));
206
-        category.addSetting(new PreferencesSetting("channel", "encoding",
207
-                "Encoding", "Encoding to use", charsetMap));
208 206
 
209 207
         ActionManager.processEvent(CoreActionType.CLIENT_PREFS_REQUESTED, null,
210 208
                 category, Boolean.FALSE);

+ 9
- 2
src/com/dmdirc/util/StringTranscoder.java Visa fil

@@ -27,8 +27,11 @@ import java.nio.charset.Charset;
27 27
 /**
28 28
  * Facilitates easy transcoding of strings.
29 29
  *
30
+ * @deprecated This kind of transcoding is not technically possible. This class
31
+ * should not be used and now makes no attempt to transcode.
30 32
  * @author Chris
31 33
  */
34
+@Deprecated
32 35
 public class StringTranscoder {
33 36
 
34 37
     /** The charset that is used by this transcoder. */
@@ -50,9 +53,11 @@ public class StringTranscoder {
50 53
      *
51 54
      * @param string The string to be transcoded
52 55
      * @return A new string of the appropriate charset
56
+     * @deprecated Does not function. Do not use this class.
53 57
      */
58
+    @Deprecated
54 59
     public String encode(final String string) {
55
-        return new String(string.getBytes(charset));
60
+        return string;
56 61
     }
57 62
 
58 63
     /**
@@ -61,9 +66,11 @@ public class StringTranscoder {
61 66
      *
62 67
      * @param string The string to be transcoded
63 68
      * @return A new string of the appropriate charset
69
+     * @deprecated Does not function. Do not use this class.
64 70
      */
71
+    @Deprecated
65 72
     public String decode(final String string) {
66
-        return new String(string.getBytes(), charset);
73
+        return string;
67 74
     }
68 75
 
69 76
 }

Laddar…
Avbryt
Spara