Extract removal of trailing whitespace parts into its own method.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 9 Nov 2013 00:00:01 +0000 (01:00 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:57 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/text/SoneTextParser.java

index 313758e..78d9bdc 100644 (file)
@@ -298,6 +298,11 @@ public class SoneTextParser implements Parser<SoneTextParserContext> {
                                Closer.close(bufferedReader);
                        }
                }
+               removeTrailingWhitespaceParts(parts);
+               return parts;
+       }
+
+       private void removeTrailingWhitespaceParts(PartContainer parts) {
                for (int partIndex = parts.size() - 1; partIndex >= 0; --partIndex) {
                        Part part = parts.getPart(partIndex);
                        if (!(part instanceof PlainTextPart) || !"\n".equals(part.getText())) {
@@ -305,7 +310,6 @@ public class SoneTextParser implements Parser<SoneTextParserContext> {
                        }
                        parts.removePart(partIndex);
                }
-               return parts;
        }
 
        private int findNextWhitespace(String line) {