From a3d9921d99a094c86c48531444b28ad650c849ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 9 Nov 2013 01:00:01 +0100 Subject: [PATCH] Extract removal of trailing whitespace parts into its own method. --- src/main/java/net/pterodactylus/sone/text/SoneTextParser.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index 313758e..78d9bdc 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -298,6 +298,11 @@ public class SoneTextParser implements Parser { 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 { } parts.removePart(partIndex); } - return parts; } private int findNextWhitespace(String line) { -- 2.7.4