|
@@ -250,8 +250,6 @@ public class IRCReader implements Closeable {
|
250
|
250
|
public ReadLine(final String line, final String... lineTokens) {
|
251
|
251
|
this.line = line;
|
252
|
252
|
|
253
|
|
- String[] tokens = lineTokens;
|
254
|
|
-
|
255
|
253
|
// In the case where TSIRC and message tags are used, the TSIRC tag can appear in 1 of 2 places depending
|
256
|
254
|
// on interpretation of the spec - Either right at the start of the line, or as part of the actual message.
|
257
|
255
|
// EG:
|
|
@@ -259,8 +257,22 @@ public class IRCReader implements Closeable {
|
259
|
257
|
// @tag=value @123@:test ing
|
260
|
258
|
//
|
261
|
259
|
// are both functionally equivalent.
|
262
|
|
-
|
|
260
|
+ //
|
263
|
261
|
// Look for old-style TSIRC timestamp first.
|
|
262
|
+ // Then look for message tags.
|
|
263
|
+ // Then look again for tsirc, as it may be after the message tags.
|
|
264
|
+ this.tokens = checkTSIRC(checkMessageTags(checkTSIRC(lineTokens)));
|
|
265
|
+ }
|
|
266
|
+
|
|
267
|
+ /**
|
|
268
|
+ * Look for TSIRC Timestamp.
|
|
269
|
+ *
|
|
270
|
+ * @param lineTokens Current line tokens
|
|
271
|
+ * @return The line tokens after we have removed the TSIRC Timestamp if
|
|
272
|
+ * there was one, else we return lineTokens as-is.
|
|
273
|
+ */
|
|
274
|
+ private String[] checkTSIRC(final String[] lineTokens) {
|
|
275
|
+ String[] tokens = lineTokens;
|
264
|
276
|
if (!tokens[0].isEmpty() && tokens[0].charAt(0) == '@') {
|
265
|
277
|
final int tsEnd = tokens[0].indexOf('@', 1);
|
266
|
278
|
if (tsEnd > -1) {
|
|
@@ -272,7 +284,18 @@ public class IRCReader implements Closeable {
|
272
|
284
|
}
|
273
|
285
|
}
|
274
|
286
|
|
275
|
|
- // Now look for message tags.
|
|
287
|
+ return tokens;
|
|
288
|
+ }
|
|
289
|
+
|
|
290
|
+ /**
|
|
291
|
+ * Look for Message-Tags
|
|
292
|
+ *
|
|
293
|
+ * @param lineTokens Current line tokens
|
|
294
|
+ * @return The line tokens after we have removed the message-tags if
|
|
295
|
+ * there was any, else we return lineTokens as-is.
|
|
296
|
+ */
|
|
297
|
+ private String[] checkMessageTags(final String[] lineTokens) {
|
|
298
|
+ String[] tokens = lineTokens;
|
276
|
299
|
if (!tokens[0].isEmpty() && tokens[0].charAt(0) == '@') {
|
277
|
300
|
final String[] lineTags = tokens[0].substring(1).split(";");
|
278
|
301
|
for (final String keyVal : lineTags) {
|
|
@@ -286,19 +309,7 @@ public class IRCReader implements Closeable {
|
286
|
309
|
System.arraycopy(lineTokens, 1, tokens, 0, lineTokens.length - 1);
|
287
|
310
|
}
|
288
|
311
|
|
289
|
|
- // Look again for tsirc, as it may be after the message tags.
|
290
|
|
- if (!tokens[0].isEmpty() && tokens[0].charAt(0) == '@') {
|
291
|
|
- final int tsEnd = tokens[0].indexOf('@', 1);
|
292
|
|
- if (tsEnd > -1) {
|
293
|
|
- try {
|
294
|
|
- final long ts = Long.parseLong(tokens[0].substring(1, tsEnd));
|
295
|
|
- tags.put("tsirc date", tokens[0].substring(1, tsEnd));
|
296
|
|
- tokens[0] = tokens[0].substring(tsEnd + 1);
|
297
|
|
- } catch (final NumberFormatException nfe) { /* Not a timestamp. */ }
|
298
|
|
- }
|
299
|
|
- }
|
300
|
|
-
|
301
|
|
- this.tokens = tokens;
|
|
312
|
+ return tokens;
|
302
|
313
|
}
|
303
|
314
|
|
304
|
315
|
/**
|